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.
The Arduino source code can be downloaded in here
Figure 4: Load IRIS training dataset into ANNHUB.
Step 2: Configure the Neural Network
Figure 5: Configure Neural Network on ANNHUB.
Based on dataset format, ANNHUB will suggest the neural network structure such as training algorithm, number of hidden nodes, training data ratio, preprocessing method, post-processing method, cost function and activation functions for different layers. Advanced users can tweak to achieve the optimal neural network model' performance.
Step 3: Train Neural Network
Figure 6: Train Neural Network on ANNHUB.
ANNHUB will suggest training parameters and stopping criteria for according training algorithm configured in Step 2. Early stopping technique and Bayesian Regularization will be handled automatically to prevent overfitting issue during the training process. That will ease the burden of the designer task. In this example, 70% of the training dataset is used to train the neural network classifier.
Step 4: Evaluate the Neural Network
After the neural network being trained, it then needs to be evaluated to analyze if it performs well on validation and test set. In this example, since Bayesian Regularization is used, validation set is not required. Only 30% of the training dataset is used to evaluate the neural network performance. Both confusion matrix and ROC curve are supported to give a designer an insight view on the classifier's performance and stability.
Figure 7: Evaluate Neural Network on ANNHUB.
ANNHUB allows the design to import completely new dataset to verify the trained model. In this example, 44 data samples, which are not included in the training dataset, are used to test the trained Neural Network Classifier.
Figure 8: Test Neural Network on a new dataset in ANNHUB.
ANNHUB supports breakdown details to aid inspection of the classifier's performance and robustness.
ANNHUB supports exporting trained neural network model directly to Arduino source code (*.ino) as shown in Figure 9.
Figure 9: Export trained Neural Network Classifier into Arduino Sketch format
This source code can then be opened in Arduino IDE directly. The user can modify the source code to meet his/her requirement for any application. No library or dependency is required for compiling and uploading the compiled code into the Arduino device. The source code in this example can be downloaded in here.
Once the trained model is uploaded into the Arduino device, this device will be able to classify an IRIS flower type based on its input's features. To demonstrate it, the simple hardware setup is shown in Figure 10 as follows:
In this setup, a user can input IRIS flower's features (sepal length, sepal width, petal length, petal width) to Arduino Nano via USB (serial communication), the Arduino Nano then interprets these inputs to give a prediction based on trained Neural Network in its firmware. This prediction result will be sent back to PC via USB (serial communication).
The Serial Monitor Window in Arduino IDE can be used as user interface:
Test dataset will be used to verify Arduino prediction results:
Prediction result of Setosa
Prediction result of Versicolor
Prediction result of Virginica