This example illustrates using a neural network as a classifier to identify the sex of crabs from physical dimensions of the crab. Six physical characteristics of a crab are considered: species, frontal-lip, rear-width, length, width and depth. The problem on hand is to identify the sex of a crab given the observed values for each of these 6 physical characteristics.
The crab data-set can be found in Examples-> Classification Example folder under ANNHUB installation folder.
This data-set contains training data-set (CrabTraining.csv) used to train a neural network and test data-set (CrabTest.csv) to test/evaluate the obtained trained neural network. The data structure contains 6 input features (Feature 1 to Feature 6) and two output classes (class 1 (male) means Output1 =0 and Output2=1, and class 2(female) mean Output1=1 and Ouput2=0).
1. Design a neural network using ANNHUB
Step 1: Load the crab training data-set (CrabTraining.csv) into ANNHUB
Step 2: Configure a neural network classifier
Step 3: Train the neural network classifier with the crab training data-set.
Step 4: Evaluate the neural network classifier.
Step 4: Test the trained neural network classifier with test data-set (CrabTest.csv)
2. Export a trained neural network model to weight file
When the trained neural network has been evaluated and tested with new test data-set, it can be exported into a weight file (.ann extension) using Export function in ANNHUB.
3. Using a trained neural network in LabVIEW environment using ANNAPI
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 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 license content, ANNLV.lic, in the working directory.
Note: We only need to get the license content only one time for a given target PC as this license content file can be used in other application running in the same PC.
With a trained neural network model and a license content, we can create a neural network model using Create.vi. 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 a crab to be male or female (output) based on its features (input).