How to add one specific condition in my trained Neural Network
1 view (last 30 days)
I have 3 types of condition in my Neural Network (662790, 667606, 672067) as you can see in the image below:
I used 3s vector of data for each type to create the FeatureTable and the trainedmodel. I am attaching both variable.
I would like the trainedmodel to identify my new data as type 662790, 667606 or 672067 just if is really similar(95% for example) if the new data (new table feature) that I will process is not similar, I would like to be recognized as 0 (zero). The reason for that is that I have sometimes a vector that is just constant 5 (or any other number of function that is create not one of this 3 real type) and at the moment my trained model will recognize as one of the 3 types what is wrong. I wanna all this data, that are clear not my time to be recognized as type 0.
This type zero will be everything that is not 95% similar from my 3 main type.
What shloud i change in my trainedmodel to implement this idea.
Thanks in advance.
Shivam Singh on 6 Dec 2021
My understanding is that you have a trained 3-class classifier and you want to put a threshold on the activation of last layer of the model to classify the output in the 4th class, if maximum activation score is less than the provided threshold.
For doing so, you may access the scores of the final layer of “ClassificationNeuralNetwork” object using predict function. Then, you may obtain the maximum score and put a threshold check on that. You may refer to the following example:
clc; clear all; close all;
%In the inputVector, you can provide the test input Sample
inputVector = [4.97,4.98,1.007,0.406];
[outputClass, scores] = predict (Mdl,inputVector);
maxScore = max(scores);
% "0" is the fourth class
thresholdForQualificationIntoPredifinedClasses = 0.95;
if (maxScore > thresholdForQualificationIntoPredifinedClasses)