|
Post by Carl Gundel on Feb 25, 2022 14:21:52 GMT -5
I have looked at a few tutorials now. It's kinda funny. Despite the definition stating that the computer should learn, most examples start off with a slew of maths and statistical analysis that a human needs to learn. They then move on to strategies, err..... isn't that the computers job? My interest in this stems primarily from my impression that many schools expect their choice of programming language to support some sort of machine learning. So, even if it is a super simple example (in fact perhaps this is best), I'd like to include something with LB5.
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Feb 25, 2022 14:44:38 GMT -5
Probably don't need a language so much as a proper library.
Then coders need that background Rod mentioned for understanding the library, given they understand the language the library is written in.
|
|
|
Post by Carl Gundel on Feb 25, 2022 15:41:18 GMT -5
Probably don't need a language so much as a proper library. Then coders need that background Rod mentioned for understanding the library, given they understand the language the library is written in. An example written in LB would be ideal. A super simple and understandable tiny machine learning example.
|
|
|
Post by bluatigro on Mar 1, 2022 4:48:51 GMT -5
i made some time ago a 'polar bears' program that was using a genetic algoritm i do not know if it was on this or the JB forum
mayby it is better to have a AI page then a ML one
|
|
|
Post by bluatigro on Mar 1, 2022 4:59:46 GMT -5
carl : you may use this as ml example
'' bluatigro 13 aug 2018 '' k means algoritm : '' put points in random set '' while point moved '' comput centum of sets '' move eatch point into closest set
global pointmax , setmax pointmax = 9 setmax = 2
dim x( pointmax ) , y( pointmax ) , set( pointmax ) dim setx( setmax ) , sety( setmax ) , set2( pointmax ) dim a( setmax ) , b( setmax )
for i = 0 to pointmax read a , b x( i ) = a y( i ) = b set( i ) = int( rnd(0) * ( setmax + 1 ) ) next i data 73.0 , 72.6 data 61.0 , 54.4 data 67.0 , 99.9 data 68.0 , 97.3 data 62.0 , 59.0 data 75.0 , 81.6 data 74.0 , 77.1 data 66.0 , 97.3 data 68.0 , 93.3 data 61.0 , 59.0 WindowWidth = 600 WindowHeight = 600 nomainwin open "k clustering ." for graphics as #m #m "trapclose [quit]" call showdata #m "when leftButtonDown [leftdown]" #m "setfocus" wait [leftdown] pointmove = 1 while pointmove = 1 pointmove = 0 '' calc centrum of eatch set for i = 0 to setmax a( i ) = 0 b( i ) = 0 next i for i = 0 to pointmax setx( set( i ) ) = setx( set( i ) ) + x( i ) a( set( i ) ) = a( set( i ) ) + 1 sety( set( i ) ) = sety( set( i ) ) + y( i ) b( set( i ) ) = b( set( i ) ) + 1 next i for i = 0 to setmax setx( i ) = setx( i ) / ( a( i ) + 1 ) sety( i ) = sety( i ) / ( b( i ) + 1 ) next i '' see whitch setcentrum is closest to point for i = 0 to pointmax q = 10000 q2 = -1 for s = 0 to setmax q3 = dist( x(i) , y(i) , setx(s) , sety(s) ) if q3 < q then q = q3 q2 = s end if next s '' move point to closest set set2(i) = set(i) if q2 <> set(i) then pointmove = 1 set2(i) = q2 end if next i for i = 0 to pointmax set(i) = set2(i) next i wend call showdata notice "ready" wait function dist( x1 , y1 , x2 , y2 ) dist = sqr( ( x1 - x2 ) ^ 2 + ( y1 - y2 ) ^ 2 ) end function sub showdata #m "fill black" for i = 0 to pointmax #m "goto " ; x( i ) * 10 - 300 _ ; " " ; y( i ) * 6 - 300 select case set( i ) case 0 #m "backcolor red" case 1 #m "backcolor green" case else #m "backcolor blue" end select #m "down" #m "circlefilled 10" #m "up" next i end sub [quit] close #m end
|
|
debluzz
Junior Member
Thanks tsh73 I'll work with it.
Posts: 57
|
Post by debluzz on Mar 20, 2022 10:28:45 GMT -5
Thanks for the info on machine learning. need some help on sorting if there are pairs in the sort. The problem is it does not pick the pairs up.( run sort-see line 5 & 6 data 1 24 10 30 33 2 13 4 1.5 18 3 22 22 12 30 4 23 26 15 32 5 18 6 3 22 6 18 14 4 24 for i= 1 to 1 'dim an 8x8 array to hold the row and column data col=5 row=8 'give the array index values a name bx=1 total=2 strfn=3 score=4 maintotal=5 'now dim a numeric array since all your data is numeric 'lose the # character before the box number it spoils the numeric data dim r(row,col) open "finish1.txt" for input as #f for r=1 to row 'get the first line from finish1.txt line input #f,l$ for c=1 to col 'break that line into columns 'note that it is fetched as a string 'but converted to plain old numeric with val() r(r,c)=val(word$(l$,c)) next next close #f 'print the array as loaded print "______________The array as loaded________________" gosub
gosub [listit]
'desending order needed
'SORT arrayName(), start, end, [column]
'So to sort rows 1 to 8 on gradeavg
print "_______________The array as loaded_______________"
CLS
sort r(),1,6,total
print " "
print " >>total<<"
gosub [listit]
sort r(),1,6,strfn
print " "
print " >>strfn<< "
gosub
sort r(),1,6,score
print " "
print " >>score<<"
gosub [listit]
sort r(),1,6,maintotal
print " "
print " >>maintotal<< "
gosub [listit]
wait
print " # "
for r=1 to 3
for c= 1 to col
print using("###.", r(r,c));
next
print
next
return
next i
wait
[listit]
print " # "
for r=1 to 4
for c= 1 to col
print using("###.", r(r,c));
next
print
next
return
'THE TEXTFILE MUST HAVE DATA IN THE ORDER OF TH ABOVE PRINT STATEMENT
|
|
|
Post by Rod on Mar 20, 2022 11:40:14 GMT -5
The code you post wont run. So I guess. When you say the sort does not pick up the pairs do you mean that other columns are not sorted as you expect? The pairs will always be sorted together. So a pair of 22's will sit side by side. But do you mean that a column of data other than the 22 is not in order?
If you expect more than one column to be ordered together such as 22 21 and 22 24 not 22 24 and 22 21 then you have to build a sorting column that includes all the info that you want to sort on. So the sorting column needs to contain multiple column info, "2221" and "2224" for the two columns to be sorted correctly and not just the 22's
But I guess, so either make the code run or tell us a bit more.
|
|
debluzz
Junior Member
Thanks tsh73 I'll work with it.
Posts: 57
|
Post by debluzz on Mar 20, 2022 11:50:23 GMT -5
Ya , sorry I just put a new post in NOVICE That should work Let Me Know Thanks
|
|
|
Post by Rod on Mar 20, 2022 12:33:16 GMT -5
Still needs A file I don’t have. Are you intending to creating that file with the data? If so it isn’t working.
|
|
|
Post by Carl Gundel on Mar 20, 2022 13:34:13 GMT -5
carl : you may use this as ml example Thank you, but could you explain how this is machine learning? It appears to be some sort of sorting algorithm. -Carl
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 20, 2022 13:47:50 GMT -5
Still needs A file I don’t have. Are you intending to creating that file with the data? If so it isn’t working. I fixed it so it doesn't need file, see post under Novice.
|
|
|
Post by tenochtitlanuk on Mar 24, 2022 16:56:58 GMT -5
Have posted a page about sorting irises and penguins using AI and the k-means method. See penguins
|
|
|
Post by knoware on Mar 25, 2022 5:14:47 GMT -5
Not sure this is any help. But there is a program that uses Multiple Linear Regression here: MLR
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 25, 2022 17:10:03 GMT -5
Yes I can see such a tool being helpful in training a machine.
|
|