This document summarizes a master's thesis that implemented machine learning training examples in Python on a Raspberry Pi. The goals were to build a library of examples in Python and test performance on a Raspberry Pi. Nine algorithms were included, such as KNN, Naive Bayes, decision trees, neural networks, and support vector machines. An optical character recognition example was used to compare support vector machines and artificial neural networks. Support vector machines had better validation performance and learning curves for character recognition. Overall, the goals of creating a Python library and testing examples on Raspberry Pi were achieved, though the Pi had slower speeds than other hardware.
Implementation of a Library of Machine Learning Algorithms in Python on Raspberry Pi
1. Implementation of a Library of training examples in Python
on Raspberry pi
Supervised by:
Dr. phil. habil. Andreas Pester
Submitted in Partial Fulfillment of the Requirements of the Academic Degree
Master of Science in Engineering, Msc
Author: B.Sc, Muhammad Zaighum Farooq
Registration Number: 1410673016
MASTER THESIS
2. Presentation Outline
Goal and Purpose
Machine Learning
The General Approach for every ML-Problem
Artificial Neural Networks
Support Vector Machine
Optical Character Recognition Example
Validation and Learning Curves
Comparing the Performance of SVM and ANN for OCR
Conclusion
3. Goal and purpose
To transform and adapt the machine learning training examples to
Python programming language thus building a library.
To test the transformed machine learning algorithms on Raspberry-
Pi3 for the training and evaluation phases.
To measure the quality of the performance of algorithms.
4. Machine Learning
• A computer program is said to learn from experience E with respect to
some class of tasks T and performance measure P, if its performance at
tasks T, as measured by P, improves with experience E.
Computer Science
Mathematics
Engineering StatisticsMachine
Learning
5. The general approach for
every ML-algorithm
Data
Collection
Data
Preparation
Training
Algorithm
Evaluation on
Test set
Performance
Improvement
6. Library and Raspberry Pi Setup
Raspberry Pi Setup
9 Training
Examples
using
different
algorithms
K-Nearest
Neighbors
Naïve
Bayes
Decision
Trees
Rule
Learners
K-means
Linear
Regression
Regression
Trees
Neural
Networks
Support
Vector
Machine
Software VNC client-server,
FILEZILLA, and Nmap.
7. Artificial Neural Networks
Artificial Neural Networks (ANNs) are models that maps a set of
inputs to output(s).
Neural network consists of an activation function and a network
topology.
The building block of a neural network is a neuron represented by
below Equation.
8. Activation Functions
Characteristic of the (artificial)
neuron.
Transforms input to output by
applying an activation function.
Activation functions e.g. Sigmoid,
Gaussian. Biological and artificial neurons.
The number of layers
The number of nodes in each layer
Training Algorithm
Network Topology
Network of neurons
9. Support Vector Machine
Support Vector Machine (SVM): A surface that defines a boundary
between various points of data.
Separation b/w classes
10. Maximum Margin Fit
Maximum Margin fit
Separation with the greatest
margin.
The maximum margin hyperplane
(MMH) is the perpendicular
bisector of the shortest line.
linearly separable data
Kernel functions linearizes the
relationship between predictors
and output.
Non-linearly separable data
11. Classification Problem.
To recognize hand written letters.
Multi-class (26 alphabets)
OCR Letters examples[1]
Optical Character
Recognition
[1] Letter recognition using Holland-style adaptive classifiers, Machine
Learning, Vol. 6, pp. 161-182, by W. Frey and D.J. Slate (1991).
12. Validation Curves of OCR
Validation curves are plots of training
score and cross-validation score.
Task Notebook Raspberry Pi
SVM Training 12 - 22 s 129 -146 s
ANN Training 58 - 82 s 29.03 min
SVM Validation 19.2 min 2.32 h
ANN Validation 25.71 min > 8 h
SVM Learning 2.76 min 22.25 min
ANN Learning 9.3 min 3.60 h
Time comparison table
Validation Curves
13. Learning Curves of OCR
A learning curve is a plot of the training and cross-validation score.
Learning Curves
Validation score of SVM is better than ANN for OCR
16. Conclusion
Goals Achieved
9 different training examples are
implemented in Python.
Performance is measured.
Leaning and Validation curves analyzed.
Library tested on Raspberry-Pi3
Observations
Slower Raspberry Pi speed.
Performance of SVM is better than ANN for
OCR Training Example.
9 Machine
Learning
Training
Examples
K-Nearest
Neighbors
Naive
Bayes
Decision
Trees
Rule
Learners
K-means
Linear
Regression
Regression
Trees
Neural
Networks
Support
Vector
Machine