Calculate Sensitivity and Specificity from Code generated from Classification Learner

73 views (last 30 days)
Sarah Ayyad
Sarah Ayyad on 27 Sep 2021
Commented: Raghdah Wadion 10 Mar 2022 at 12:07
I have trained my dataset in the classification learner app and tried to calculate classification performance using leave-one-out cross-validation. Since classification learner doesn't support this configuration of K-fold, I used the way of generating the code for training the currently selected model.
我试图计算敏感性和特异性,但我发现的所有方式都依赖于预测的类标签,并且我无法获得生成的类标签,因为它不是新数据集。我只想评估训练有素的模型。
Is any way to evaluate the sensitivity and specifity or the confusion matrix from Classification Learner App Code generated?

Accepted Answer

Sarah Ayyad
Sarah Ayyad on 28 Sep 2021
Edited:Sarah Ayyad on 28 Sep 2021
I computed all performance metrics by the following way
[validationPredictions, validationScores] = kfoldPredict(partitionedModel);
Confmat = Confusionmat(响应,验证预报)%响应是代表类的数据集中的最后一列
TP = confmat(2, 2);
TN = confmat(1, 1);
FP = confmat(1, 2);
FN = confmat(2, 1);
Accuracy = (TP + TN) / (TP + TN + FP + FN);
Sensitivity = TP / (FN + TP);
specificity = TN / (TN + FP);
z = FP / (FP+TN);
X = [0;Sensitivity;1];
Y = [0;z;1];
AUC = trapz(Y,X);% This way is used for only binary classification

More Answers (0)

Community Treasure Hunt

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

Start Hunting!