How can I calculate the false negatives, false positives and the correctly classified for my seizure prediction model

3 次查看(过去 30 天)
After I passed my test data through my model to receive the predictions I worked out the accuracy, with the code:
acc = sum(Pred == cell_array_channel2_output)./numel(cell_array_channel2_output)
channel2_output contains binary values 1 for seizure, -1 for no seizure
How can I calculate the correctly classified and the false negatives and positives in my EEG signal?

回答(1 个)

Poorna
Poorna 2023-9-21
Hello LOMenz,
I understand that you are interested in calculating the number of false positives, false negatives, and correct predictions from your seizure prediction model.
To begin, false negatives occur when the model predicts false (value of -1), but the ground truth is true (value of 1). On the other hand, false positives occur when the model predicts true (value of 1), but the ground truth is false (value of -1). Correct predictions are instances where both the predictions and ground truth match.
You can calculate these values using relational operators and the sum function, as shown below:
% Calculate the number of correctly classified instances
correct = sum(Pred == cell_array_channel2_output);
% Calculate the number of false negatives (predicted as -1 but actual value is 1)
false_negatives = sum(Pred == -1 & cell_array_channel2_output == 1);
% Calculate the number of false positives (predicted as 1 but actual value is -1)
false_positives = sum(Pred == 1 & cell_array_channel2_output == -1);
Alternatively, you can use the built-in confusionmat function to compute the confusion matrix, which provides a comprehensive summary of the classification results. From the confusion matrix, you can extract the true positives, true negatives, false positives, and false negatives.
% Create the confusion matrix
C = confusionmat(cell_array_channel2_output, Pred);
% Extract the values from the confusion matrix
true_positives = C(1, 1); % Number of true positives
true_negatives = C(2, 2); % Number of true negatives
false_positives = C(2, 1); % Number of false positives
false_negatives = C(1, 2); % Number of false negatives
correct = true_negatives + true_positives;
Please refer to the following documentation for more information on the confusionmat function:
Hope this Helps!

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by