Introduction
This example aims to design a classification system that can classify all 3 different IRIS flowers.
Data preparation
In order to classify three IRIS flowers, common features such as petal length, petal width, sepal length, and sepal width are used.
The IRIS data set can be found in the Examples>Classification Example folder under the ANNHUB installation folder.
This data-set contains
Training data set (IRISTraining.csv) used to train a neural network
Test data set (IRISTest.csv) to test/evaluate the obtained trained neural network.
The data structure contains
4 input features (Feature 1 to Feature 4)
3 output classes that are corresponding to three IRIS flower types.
Since 3 types of IRIS flowers are classified, the outputs will be decoded into binary.
For example:
[1,0,0] for Setosa
[0,1,0] for Versicolor
[0,0,1] for Virginica.
The IRIS dataset will be separated into a training set (70%) and a test set (30%).
Design a neural network using ANNHUB.
There are four steps to designing a Neural Network Classifier.
Since the IRIS dataset is small, a Bayesian Neural Network with Regularization is used in this case.
Step 1: Load the IRIS training set
Step 2: Configure the Neural Network
Based on the 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's performance.
Step 3: Train Neural Network
ANNHUB will suggest training parameters and stopping criteria according to the training algorithm configured in Step 2. Early stopping technique and Bayesian Regularization will be handled automatically to prevent overfitting issues during the training process. That will ease the burden of the designer's 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 is trained, it then needs to be evaluated to analyze if it performs well on validation and test sets. In this example, since Bayesian Regularization is used, the validation set is not required. Only 30% of the training dataset is used to evaluate the neural network performance. Both the confusion matrix and ROC curve are supported to give a designer an insight view of the classifier's performance and stability.
Step 5: Test Neural Network performance with a new dataset in ANNHUB
ANNHUB allows the designer to import a 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.
ANNHUB supports breakdown details to aid the inspection of the classifier's performance and robustness.
Step 6: Export trained neural network model to weight file
When the trained neural network has been evaluated and tested with a new test data set, it can be exported into a weight file (.ann extension) using the export function in ANNHUB.
LabVIEW Deployment
At this stage, we already have a trained neural network saved in a text file with .ann extension (for example, TrainModel_lv.ann)
We need to get the License Content by using a valid username and password in GetLicenseContent.vi
Assume that we do not specify any License File Path in GetLicenseContent.vi, so this VI will generate the licensed content, ANNLV.lic, in the working directory.
Note: We only need to get the licensed content only one time for a given target PC as this license content file can be used in other applications running on the same PC.
With a trained neural network model and licensed content, we can create a neural network model using Create.vi. The following block diagram demonstrates 5 steps to use ANNAPI to load a trained neural network and a license content file in order to create a neural network model and classify whether the flower is setosa, versicolor, or virginica (output) based on its features (input).
Conclusion
In this example, the Bayesian Neural Network is used to classify three types of IRIS flowers. Then the Bayesian Neural Network is deployed directly to the LabVIEW application via ANNAPI (ANNHUB_LV) to handle classification tasks and successfully recognize different types of IRIS flowers based on their sepal length, sepal width, petal length, and petal width. This example has demonstrated the capability of ANNHUB that allows designers to deploy a Neural Network on the embedded system easily.
Comments