irllabs / ml-lib

A machine learning library for Max and Pure Data
Other
274 stars 40 forks source link

How to add N-dimesional time series data in ml.dtw #142

Closed graphographer closed 6 years ago

graphographer commented 6 years ago

The documentation isn't clear on how to practically do this with [add <vector 1> <vector 2>(

Say I have 3-dimensional data coming from an accelerometer. How do I do this? Is it a series of "add" messages, [add 1 1 2 3(, [add 1 4 5 6(. In which case, how do I indicate the end of one gesture for a feature, and a new one during training? If I had to guess before you're able to respond, I might try train. Or I suppose I can try "reverse-engineering" by examining saved data.

Please advise! Thank you. Once I understand how this works, I'm happy to create up-to-date help patches for the project.

graphographer commented 6 years ago

By extension, of course, I have similar questions about how to actually classify a feature with [map(.

graphographer commented 6 years ago

OK, I'm getting closer.

The [record( feature seems largely undocumented, but easy enough to figure out.

Next stop, [map(

graphographer commented 6 years ago

Oh! I just discovered the sub-patch in ml.svm-help.pd... But still, I guess this is mostly an issue about documentation.

jamiebullock commented 6 years ago

Hi, I can reply a bit more to these tomorrow but sending “help” to any of the objects left inlet will list all supported messages with a description. I think this will answer some of your questions.

Also, the canonical paper explains a bit including the “record” message for time series https://nime2015.lsu.edu/proceedings/201/0201-paper.pdf

On the plus side the objects are very consistent so once you understand the main messages, they apply to most objects.

jamiebullock commented 6 years ago

Hi @graphographer I've just had a look at this, and there is actually a ml.dtw.maxhelp, which seems to be quite up-to-date, with the exception of save load vs the correct write read. Did you manage to find that one? Essentially, the save/write seems to be the main issue with the help files.

The way the map message works is you prepend it to your "unclassified" data vector.

So if you trained with e.g.

add 1 0 2 0 add 2 1 0 1

Where 1 and 2 are your class IDs then

map 0 2 0 should yield 1

and

map 1 0 1 should yield 2

The same principle applies to time series. If you recorded a triangle wave series labelled 1 and a square wave series labelled 2 then prepending map for the corresponding unclassified time series (triangle wave, square wave) should yield outputs of 1 and 2

Does this answer the questions?

graphographer commented 6 years ago

Unfortunately I don't have Max/MSP and I haven't any experience converting patches (apparently it's possible with a Supercollider patch, but that's a bit of a rabbit hole for me at the moment).

So my question about "map" then really is more like, do I just prepend an incoming stream of lists (as in the pure data example for ml.dtw) with "map"? I have been trying this and I'm having difficult getting it to output anything but the null class (0).

Do I need to set some of the settings to things other than default in order to get results from real-world data?

jamiebullock commented 6 years ago

Hi @graphographer, sorry for the slow reply on this.

I think what may not be clear from the above is that when mapping, you also need to segment your data with record 1 record 0

So if you have a 3 dimensional input, you would do something like:

record 1 add 1 0 0 1 add 1 0 0 0 record 0

record 1 add 2 3 2 1 add 2 4 3 2 record 0

train

record 1 map 0 0 1 -> 1 map 0 0 0 -> 1 record 0

record 1 map 3 2 1 -> 2 map 4 3 2 -> 2 record 0

Let me know if this answers the question.

I explain a bit more the process in #145