bytefish.de

Machine Learning with OpenCV

Machine Learning is a branch of Artificial Intelligence and concerned with the question how to make machines able to learn from data. The core idea is to enable a machine to make intelligent decisions and predictions based on experiences from the past. Algorithms of Machine Learning require interdisciplinary knowledge and often intersect with topics of statistics, mathematics, physics, pattern recognition and more.

OpenCV (Open Source Computer Vision) is a library for computer vision and comes with a machine learning library for:

  • Decision Trees
  • Boosting
  • Support Vector Machines
  • Expectation Maximization
  • Neural Networks

Finding simple examples to get started is difficult, so I wrote a document and a program for the C++ Machine Learning API of OpenCV. You can download it from my github account at: https://github.com/bytefish/opencv/.

Experiments

Parameter Value
Trainingdata size 200
Testdata size 2000

y = 2x

Predictor Accuracy
Support Vector Machine 0.99
Multi Layer Perceptron (2, 10, 15, 1) 0.994
k-Nearest-Neighbor (k = 3) 0.9825
Normal Bayes 0.9425
Decision Tree 0.923

Plot

classifier on linear data

y = sin(10x)

Predictor Accuracy
Support Vector Machine 0.913
Multi Layer Perceptron (2, 10, 15, 1) 0.6855
k-Nearest-Neighbor (k = 3) 0.9
Normal Bayes 0.632
Decision Tree 0.886

Plot

classifier on non-linear data sin(10x)

y = tan(10x)

Predictor Accuracy
Support Vector Machine 0.7815
Multi Layer Perceptron (2, 10, 15, 1) 0.5115
k-Nearest-Neighbor (k = 3) 0.8195
Normal Bayes 0.542
Decision Tree 0.9155

Plot

classifier on non-linear data tan(10x)