Hi,
I understand that you are trying to view the predicted responses on additional test inputs/observations (feature set) from a network built with the Neural Network Pattern Recognition App.
To view the actual predicted responses by the trained network, I suggest 2 methods.
1st method using the ‘Export Model’ feature of the App:
The App requires that the number of observations in the predictor data must be greater than 10. So, for the predictors of training, I created a random sample of 11 observations, each with 14 features. And for responses of training, I created a random sample of 11 responses each with 2 classification classes.
Make sure that in the imported data, each row of the predictors matrix (here inputs matrix) corresponds to one feature and each column to one observation. So, in your case, the training set with 14 features and ‘n’ observations should be of the dimension 14 x ‘n’ matrix.
Similarly, the corresponding responses matrix (here targets matrix) must be of the dimension 2 x ‘n’ matrix. Here, each row corresponds to one classification class and each column corresponds to the desired/correct response of one input.
After the training is completed, click on ‘Export Model’ --> ‘Export to Workspace’. This will export a structured array containing the trained network and results to the workspace. I named that structured array as ‘DiamondResults’.
This variable ‘DiamondResults’ is of the type ‘struct’. It has the ‘Network’ variable which is the trained network. We can use this ‘Network’ to pass new observations and view the results of the trained network.
Let us create a random matrix (14 x 4) containing 4 more new observations as below.
moreObservations = randi([-21,34],14,4);
We can pass these new observations to the trained network as below and get the responses.
predictedResponses = DiamondResults.Network(moreObservations)
0.1781 0.5932 0.8955 0.7840
0.8219 0.4068 0.1045 0.2160
2nd method using the ‘Generate Code’ feature of the App:
After the network is trained in the App, click on ‘Generate Code’ --> ‘Generate Simple Training Script’. This will create MATLAB code/script to reproduce the training steps of the App. Generally, creating MATLAB code from the App can be helpful to customize the training process. Save this generated MATLAB code as ‘train.m’. A few lines from the generated code is shown below.
Before executing the generated code, we should load ‘inputs’ (14 x 11) and ‘targets’ (2 x 11) into the workspace and make these variables accessible to the generated MATLAB code.
Execute the MATLAB file (train.m) containing the generated code from App. This will reproduce the entire training steps done earlier through the UI of the App. And the variables created during the training get loaded into the workspace.
Among these variables loaded into the workspace, ‘net’ variable stores the trained network. As seen in the generated code, this ‘net’ variable can be used to test on new input observations and get the actual responses from the network.
[net,tr] = train(net,x,t);
Like the 1st method, create a random matrix (14 x 4) containing 4 more observations. Pass this matrix to the ‘net’ variable to receive the responses of the trained network.
predictedResponses = net(moreObservations)
0.8933 0.5895 0.8724 0.8906
0.1067 0.4105 0.1276 0.1094
References:
- Pattern Recognition with a Shallow Neural Network - MATLAB & Simulink: https://www.mathworks.com/help/deeplearning/gs/pattern-recognition-with-a-shallow-neural-network.html