It is currently Tue Jun 27, 2017 10:32 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: TIPS:How to execute machine learning on BASIC!
Unread postPosted: Thu Jun 01, 2017 1:59 am 
Offline

Joined: Wed Mar 05, 2014 1:15 am
Posts: 59
Hi all.

I thought that want to test machine learning on BASIC!

I found follows method.

1.Use Brain.js.


2.HTML example.

    Description:

    If follows HTML-file load in BASIC!-HTML-mode then
    Brain.js execute.
    (use HTML.load.url instruction)

    I tested follows data.

    - Learning data is 2 input items and 1 output item.
    All learning data count is 42.

    - Test data is 2 input items only.
    Output item is computed by Brain.js.
    All test data count is 5.

    Test result is displayed textarea.

    HTML-file is here.

Code:
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">

<script src="https://cdnjs.cloudflare.com/ajax/libs/brain/0.6.3/brain.js"></script>

<style>
body {
   font-size: 100%;
   color: #ecf0f1;
   background: #27ae60;
}

#kkaf {
   font-size: 1.5em;
   margin: 10px;
}

</style>

   

  <title>brain.js test</title>

 
   

<style>

div#footer-fixed
{
    position: fixed;
    bottom: 0px;
    left: 0px;
    width: 100%;
    height: 70px;
}


div#body-bk{
    padding: 0px 0 80px 0;}

#out {
  width: 90%;
  font-size: 1em;
};


</style>


 
</head>

<body>
     <h1>brain.js test</h1>


<div id="body-bk">

<div id="kkaf">
<textarea id="out" rows="10"></textarea>
</div>

</div>

<div id="footer-fixed">

simple test html file

</div>

<script>

var outxxx = 'result:\n';
var net = new brain.NeuralNetwork();


// Machine lerning data for Brain
net.train([{input: { gan: 0.621, iryo: 0.7175 }, output: { ben: 0.65 }},
{input: { gan: 0.79, iryo: 0.8175 }, output: { ben: 0.626 }},
{input: { gan: 0.7185, iryo: 0.6575 }, output: { ben: 0.691 }},
{input: { gan: 0.72025, iryo: 0.8475 }, output: { ben: 0.636 }},
{input: { gan: 0.53025, iryo: 0.7775 }, output: { ben: 0.242 }},
{input: { gan: 0.82925, iryo: 0.7175 }, output: { ben: 0.545 }},
{input: { gan: 0.73525, iryo: 0.7075 }, output: { ben: 0.734 }},
{input: { gan: 0.787, iryo: 0.8325 }, output: { ben: 0.584 }},
{input: { gan: 0.69775, iryo: 0.72 }, output: { ben: 0.63 }},
{input: { gan: 0.73075, iryo: 0.79 }, output: { ben: 0.654 }},
{input: { gan: 0.7315, iryo: 0.885 }, output: { ben: 0.615 }},
{input: { gan: 0.7475, iryo: 0.7325 }, output: { ben: 0.714 }},
{input: { gan: 0.723, iryo: 0.86 }, output: { ben: 0.671 }},
{input: { gan: 0.7755, iryo: 0.855 }, output: { ben: 0.685 }},
{input: { gan: 0.85125, iryo: 0.9475 }, output: { ben: 0.482 }},
{input: { gan: 0.82075, iryo: 0.86 }, output: { ben: 0.598 }},
{input: { gan: 0.6265, iryo: 0.62 }, output: { ben: 0.657 }},
{input: { gan: 0.71325, iryo: 0.69 }, output: { ben: 0.69 }},
{input: { gan: 0.87975, iryo: 0.7425 }, output: { ben: 0.686 }},
{input: { gan: 0.8815, iryo: 0.8675 }, output: { ben: 0.597 }},
{input: { gan: 0.7365, iryo: 0.6975 }, output: { ben: 0.675 }},
{input: { gan: 0.6275, iryo: 0.6875 }, output: { ben: 0.778 }},
{input: { gan: 0.81425, iryo: 0.8775 }, output: { ben: 0.568 }},
{input: { gan: 0.97925, iryo: 0.7875 }, output: { ben: 0.645 }},
{input: { gan: 0.845, iryo: 0.6975 }, output: { ben: 0.722 }},
{input: { gan: 0.61975, iryo: 0.6775 }, output: { ben: 0.632 }},
{input: { gan: 0.92275, iryo: 0.7425 }, output: { ben: 0.565 }},
{input: { gan: 0.70575, iryo: 0.6925 }, output: { ben: 0.659 }},
{input: { gan: 0.73675, iryo: 0.815 }, output: { ben: 0.7 }},
{input: { gan: 0.6475, iryo: 0.655 }, output: { ben: 0.668 }},
{input: { gan: 0.72125, iryo: 0.85 }, output: { ben: 0.628 }},
{input: { gan: 0.76225, iryo: 0.8925 }, output: { ben: 0.596 }},
{input: { gan: 0.88125, iryo: 0.885 }, output: { ben: 0.504 }},
{input: { gan: 0.7245, iryo: 0.71 }, output: { ben: 0.695 }},
{input: { gan: 0.87575, iryo: 0.8225 }, output: { ben: 0.633 }},
{input: { gan: 0.9125, iryo: 0.795 }, output: { ben: 0.612 }},
{input: { gan: 0.62675, iryo: 0.8175 }, output: { ben: 0.597 }},
{input: { gan: 0.80575, iryo: 0.88 }, output: { ben: 0.689 }},
{input: { gan: 0.7085, iryo: 0.71 }, output: { ben: 0.702 }},
{input: { gan: 0.75225, iryo: 0.7275 }, output: { ben: 0.709 }},
{input: { gan: 0.81725, iryo: 0.745 }, output: { ben: 0.758 }},
{input: { gan: 0.73075, iryo: 0.7525 }, output: { ben: 0.749 }}]);

// test brain

var input = { gan: 0.75, iryo: 0.92 };
var output = net.run(input); 
console.log(output);

outxxx = outxxx+"----------\n";
outxxx = outxxx+"inp:"+JSON.stringify(input)+"\n";
outxxx = outxxx+"out:"+JSON.stringify(output)+"\n";

var input = { gan: 0.79, iryo: 0.71 };
var output = net.run(input); 
console.log(output);

outxxx = outxxx+"----------\n";
outxxx = outxxx+"inp:"+JSON.stringify(input)+"\n";
outxxx = outxxx+"out:"+JSON.stringify(output)+"\n";

var input = { gan: 0.73, iryo: 0.77 };
var output = net.run(input); 
console.log(output);

outxxx = outxxx+"----------\n";
outxxx = outxxx+"inp:"+JSON.stringify(input)+"\n";
outxxx = outxxx+"out:"+JSON.stringify(output)+"\n";

var input = { gan: 0.85, iryo: 0.90 };
var output = net.run(input); 
console.log(output);

outxxx = outxxx+"----------\n";
outxxx = outxxx+"inp:"+JSON.stringify(input)+"\n";
outxxx = outxxx+"out:"+JSON.stringify(output)+"\n";


var input = { gan: 0.88, iryo: 0.81 };
var output = net.run(input); 
console.log(output);

outxxx = outxxx+"----------\n";
outxxx = outxxx+"inp:"+JSON.stringify(input)+"\n";
outxxx = outxxx+"out:"+JSON.stringify(output)+"\n";

// set result to textarea

document.getElementById('out').innerHTML=outxxx;



</script>


</body>



 

</html>


3.Conclusion

    If you use this method then you can do machine learning on BASIC!.

    And I found to work synaptic.js on BASIC! with almost same method.

    let's enjoy machine lerning on BASIC! :D




Sinagawa1.

_________________
Sinagawa1

BASIC! beginner in Japan.

Sinagawa-ku, Tokyo Japan

URL:BASIC! Youtube video gallery(Japanese Langage Page)
http://www.geocities.jp/a_33/you/gallery.html
-------------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred