Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [Math] Comparing data

This thread is locked; no one can reply to it. rss feed Print
[Math] Comparing data
Erin Maus
Member #7,537
July 2006
avatar

Hi,

I'm trying to compare certain types of physical movement. I have data (acceleration, velocity, and position) from a physical source for a variety of actions. I would like to compare different actions for similarity.

For example, a good comparison would be hand movement, such as when moving a pen to draw lines and other simple shapes. No two movements will be identical, even for the same shape, but different movements will be similar for the same shape. (This is one of the sources of movement I would like to test).

How would I compare data in such a case to determine if two movements are similar? Furthermore, how do I take into account things like scaling (e.g., drawing a big circle and a little circle)? I don't need to take into account rotation, and I assume I can simply start at origin so translation won't be an issue.

(The application is for a silly game idea. I want to have a little robot-of-sorts mimic the player's drawing behavior over time. I need to create a model that accurately simulates the player's movements closely enough. Thus I have to be able to compare movements to create a reliable model, and also to create inputs to the model in the game. Accuracy is necessary, and I also need to be able to tweak inputs for other characters in the game so they have different movements.)

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

bamccaig
Member #7,536
July 2006
avatar

SiegeLord
Member #7,827
October 2006
avatar

Use machine learning.

If you don't know it, then it's a good thing to learn as your non-machine learning job will soon become obsolete.

I'd suggest either doing something simple like using random forests, or writing a full blown neural network to do it (plenty of C++ compatible libraries for both). For the former, I recall doing a similar task (classifying exercise type given accelerometer data) using random forests in an machine learning class. For the latter, it's reminiscent of https://quickdraw.withgoogle.com/ although I don't know how many details of that are public.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Erin Maus
Member #7,537
July 2006
avatar

Problem is, I have literally no idea where to start with machine learning. I have no idea how to create a neural network, or train it, or use it to generate outputs. Do you have any suggestions?

Also, wouldn't I still need to be able to compare two different movements? I want to prove the accuracy of the simulated to the real movements.

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

LennyLen
Member #5,313
December 2004
avatar

Have you looked into how they recognize writing with a stylus on a touch-screen? I imagine it's not too different from what you're trying to do.

Chris Katko
Member #1,881
January 2002
avatar

Neural net for classification. For example.

Pick up a book on Machine Learning. It's a very large field, but an introductory text will help you understand what's going on.

You're looking for a "classification" algorithm. You want to "classify" whether or not something fits the criteria "is this an X movement?" given variables such as mouse position, velocity, acceleration, and time-from-start. You'll likely "train it." So you give it a ton of (human-made) examples self-categorized as "yes/no" and then the neural net is "trained" based on a subset of these examples. Then you repeat the training using a different subset of those examples so that the neural net doesn't become over-fit (curve fitting to erronious data in the sets from your humanness leaking in).

https://en.wikipedia.org/wiki/Overfitting

This is the book I had for my first semester grad-school machine learning class:

https://www.amazon.com/Foundations-Machine-Learning-Adaptive-Computation/dp/026201825X/ref=sr_1_28?ie=UTF8&qid=1484264769&sr=8-28&keywords=Machine+Learning

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Erin Maus
Member #7,537
July 2006
avatar

Classification is only one step. Is it possible get movements from the neural network, though? I want the robot/golem character to be able to draw stuff, too.

I found a copy of that book online and will give it a read soon.

---
ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

ks
Member #1,086
March 2001

Consider that the number of points/observations per movement will differ within and between movement types which likely means having to first normalize to a specific length. Thereafter, classification could be through various statistical or machine learning techniques. Tonnes of resources but have a look at http://www-bcf.usc.edu/~gareth/ISL/ for a free book then find the accompanying Youtube videos.

You could get started with correlations.

Regenerating trajectories could likely be performed with variations of recurrent neural networks. Maybe.

Now, if you really wish to dive into this specific type of data then consider Funcational Data Analysis (http://www.psych.mcgill.ca/misc/fda/). An R package can be found on CRAN.

Go to: