IRIS Flower Classification using Arduino Nano device
This example aims to design a classification system deployed in Arduino Nano (https://store.arduino.cc/usa/arduino-nano) that can classify all 3 different IRIS flowers.
Figure 4.41: Three IRIS flowers.
Data preparation and feature extraction
In order to classify three IRIS flowers, common features such petal length, petal width, sepal length and sepal width are used. The IRIS flowers' data-set can be obtained via Wikipedia (https://en.wikipedia.org/wiki/Iris_flower_data_set). The data-set contains a set of 150 records under five attributes as follows:
Figure 4.42: IRIS flowers' data-set under 5 attributes: Sepal Length, Sepal Width, Petal Length, Petal Width and Species.
Since 3 types of IRIS flowers being classified, the Neural Network classifier will contain 3 outputs as shown in Figure 4.43.
Figure 4.43: Neural Network Classifier for IRIS flowers.
The IRIS data-set will be separated into training set (106 samples) and test set (44 samples) as following format (csv extension).
Figure 4.44: IRIS flower training set.
Three outputs are mapped by binary code that is [1 0 0] will be Setosa, [0 1 0] will be Versicolor and [0 0 1] will be Virginica.
Design Bayesian Neural Network Classifier using ANNHUB
First the ANNHUB is used to design the Neural Network classifier in 4 steps. The Bayesian Neural Network is used in this case as the data-set is small.
Figure 4.45: Design Bayesian Neural Network Classifier for IRIS classification.
Test Bayesian Neural Network Classifier with test data-set (44 data samples)
Figure 4.46: Evaluate Bayesian Neural Network Classifier with test data-set.
Export trained Neural Network Classifier into Arduino source code.
Figure 4.47: Export trained Neural Network Classifier into Arduino Sketch format
Import Arduino source code into Arduino IDE
Figure 4.48: Load Arduino Sketch format into Arduino IDE.
This Arduino source code (sketch) can be compiled and uploaded directly to Arduino device (Arduino Nano).
Figure 4.49: Compile and upload Arduino Sketch into Arduino device (Arduino Nano) via USB port.
Test Arduino Nano based Neural Network Classifier
Figure 4.50:Communication between Laptop PC and Arduino device (Arduino Nano) via USB port.
To demonstrate the prediction capability of the trained Neural Network deployed in Arduino Nano, the hardware setup is shown in Figure 4.50. In this setup, the Laptop PC sends inputs (sepal length, sepal width, petal length, petal width) to Arduino Nano via USB (serial communication), the Arduino Nano then interprets these inputs to give prediction based on trained Neural Network in its firmware. This prediction result will be sent back to PC via USB (serial communication).
Figure 4.51:Serial communication interface between Laptop PC and Arduino device (Arduino Nano) via USB port.
1. Prediction of Setosa
2. Prediction of Versicolor
3. Prediction of Virginica
In this example, Bayesian Neural Network is used to classify three types of IRIS flowers. This Bayesian Neural Network then is deployed directly to Arduino Nano (with limited RAM memory - 2kB only). The Arduino Nano based AI device can handle classification task that can successfully recognise different types of IRIS flowers based on theirs sepal length, sepal width, petal length and petal width.
This example also demonstrates the capability of ANNHUB that allows designers deploying a Neural Network on embedded system easily.