I'm working on a classifier to sort out transportation modes based on certain attributes of an activity. I use a nearest neighbor algorithm like this :

2 example sets of training data (let's assume they are the only ones I have)

This set represents a car ride:

Attribute  |  AvgSpeed   TopSpeed   GyroValue 
Value      |  40         80         20

This set represents a walk:

Attribute  |  AvgSpeed   TopSpeed   GyroValue 
Value      |  5          8          90

AvgSpeed, TopSpeed and GyroValue have different weights (e.g. 0.3, 0.3, 0.4)

If I feed the program something like A=25, B=60, C=40, it should be able to predict a car ride.

I'm currently using a k-neighbors classification system for this (more specifically the KNeighborsClassifier algorithm with scikit-learn in python). Would there be a stronger case for another type of ML algorithm here? I'm not convinced this is the best fit for my data, and this is not exactly my field of expertise.

Thank you.


The main problem about choosing a right classier is that, by definition, you cannot know which one will behave the best. However, there are general hints. kNN, SVM, NB,... etc work really well with large number of features.

In your case you have only three variables and they seem to be possible to be classified accurately by rules (e.g., speed > 20 implies NOT walking).

For this reason, I would recommend to you to check any rule-based classifier such as decision trees.

You can see benefits/drawbacks and how to apply them with scikit-learn in here.

  • $\begingroup$ Thanks! I did use a decision tree for a while, but since a lot of transportation modes can have similar values (speed for biking, running and a bus, for example), it only worked for the very obvious cases. $\endgroup$
    – l-r
    Jun 2 '13 at 3:19
  • $\begingroup$ Have you tried [Random Forests] (en.wikipedia.org/wiki/Random_forest) as well? They are based on the combination of decision trees. It might get better results. $\endgroup$ Jun 2 '13 at 10:31
  • $\begingroup$ I haven't! Will try them out. Cheers. $\endgroup$
    – l-r
    Jun 3 '13 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.