Pages: [1]   Go Down
Author Topic: Machine Learning in Arduino?  (Read 3347 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am working on a project that involves recognizing gestures people perform during interaction with a fur-like prototype made up of conductive threads. These gestures could include patting, stroking, scratching, etc. I'd like to try a machine learning approach from my Arduino code (possibly a Hidden Markov model using sequences of circuit resistance as input data, or a neural network using total resistance change and other temporal circuit attributes as features).

First, I was thinking about using Weka, is that a reasonable choice for implementing data mining routines from Arduino?

Second, if it does make sense to use Weka with Arduino, is there any sample code someone could direct me to? I've looked but so far haven't been able to find any myself.

Thank you!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Weka requires a specific version of Java, depending on the version of Weka. I wonder what version of Java runs on the Arduino...
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 42
Posts: 5612
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

While I don't doubt that you could implement some form of artificial intelligence in an Arduino, with only 2K of RAM it would be a tight squeeze (and you wouldn't end up with much).

AnnaFlagg - are you certain that this project isn't just a wee bit beyond your level of expertise? I mean, seriously - how does someone think to themselves "Yeah - I'll implement a machine learning algorithm on a harvard architecture that has only 2 kb of RAM and 32 kb of program space"? I mean, if you have any understanding of how neural networks or other machine learning algorithms are implemented, you would know that attempting such a thing would be verging on madness, if not near impossibility.

Like I said, though - you could probably get something to work, but not likely anything close to your aspirations (and certainly you're not going to be running this in Java on the Arduino - that isn't happenning).
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


What is probably possible is to use the Arduino to get the sensor data and send it over to something more powerfull to process. Thats what Arduino's can do very well.

I can imagine that a first level of processing is done on the Arduino. Gestures are in the order 0.1-10 seconds (I guess) so all signals smaller than 0.1 seconds could be filtered out.

Another thing the arduino can do is add duration tags to gestures. E.g. So the generates records like { duration, wireID } so instead of sending 1000 messages per second that a wire is touched, the Arduino just sends 10 times "100, 5". By maximizing the duration you can tune the sensitiveness.

Another way is to make a record which wire is touched in the last 100 millisec. This would result in something like:

(code is only partial, will not compile)
Code:
int array[14]; // suppose 14 wires; (0..13) but we don't use 0 and 1 as these are the hardware serial port

#define SENDTIMEOUT 100
unsigned long lastSend =0;

void setup()
{
  Serial.begin(115200);
 
  for (int i=0; i< 14; i++) array[i] = 0;
  for (int i=2; i< 14; i++) pinMode(i, INPUT);  // note we don't change pin 0 and 1
}

void loop()
{
  // READWIRES
  for (int i=2; i< 14; i++) if (digitalRead(i) == LOW)  array[i] = 1;  // assume LOW is signal

  // SEND
  if (millis() - lastSend > SENDTIMEOUT )
  {
    lastSend  = millis();
     for (int i=2; i< 14; i++)
     {
        if (array[i] ==1)
        {
           Serial.print(i);
           Serial.print(","); // space as separator
           array[i] = 0; // reset it
        }
        Serial.println();
     }
   }
}

Hopes this helpes,
Rob
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 42
Posts: 5612
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is probably possible is to use the Arduino to get the sensor data and send it over to something more powerfull to process. Thats what Arduino's can do very well.

It's not clear from the OP's post whether that is what they want, or if they want to do all processing on the Arduino; but your approach is certainly a possibility...
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I allways think in possibilities, thats far more fun !!
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies. While I am fairly new to this area, I am aware that Arduino would likely not have enough RAM to carry out the whole project. However this approach was suggested to me, specifically combining Weka with Arduino, with the possibility of connecting to a more powerful processor as well. I'm interested in whether on a high level this approach makes sense, or if I should think along other lines.

Thanks again!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And the sample code is much appreciated! Definitely an approach I will look into.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 42
Posts: 5612
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies. While I am fairly new to this area, I am aware that Arduino would likely not have enough RAM to carry out the whole project. However this approach was suggested to me, specifically combining Weka with Arduino, with the possibility of connecting to a more powerful processor as well. I'm interested in whether on a high level this approach makes sense, or if I should think along other lines.

Thanks again!

The approach of using the Arduino as an interface to a larger system (PC or otherwise), where that PC would be doing the bulk of the processing - wasn't made abundantly clear in your original post. Its a perfectly reasonable solution, though.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
if you have any understanding of how neural networks or other machine learning algorithms are implemented, you would know that attempting such a thing would be verging on madness, if not near impossibility.
I'm not convinced that 2k of RAM is unreasonable for machine learning. Ok, so maybe neural networks would be tricky, but RL? e-greedy doesn't take up that much RAM or program space, as long as your state space isn't huge. e-greedy is also relatively easy to implement.

This is something I've been meaning to play with, so I'm going to try it. If I get around to actually doing it, I'll post the code here.
Logged

Pages: [1]   Go Up
Jump to: