Exporting ROC Curve and Confusion Matrix computation code from the Classification Learner App
- ROC CURVE:
- CONFUSION MATRIX
6 Comments
Answers (1)
Your methodology is correct, you should use perfcurve to obtain the ROC curve outside of the app. This will return the tresholds that are used to compute each point in the ROC curve. You can use these thresholds on the validationScores values to classify (one threshold at a time). Then the result of this classification ( the binary predicted class values) can be used in the confusionmat function which contains TP,TN,FP,FN values. The reason that when you run this you get different results then the app, is that the crossval function in here:
partitionedModel = crossval(trainedClassifier.ClassificationSVM, 'KFold', 5);
uses a random partioning of the folds. It then takes 5 "blank" models and trains them on these folds. The randomness produces somewhat different results each time. There is a way to keep the random seed constant if you would want that. For that google something like "matlab set the random seed"
For more info see my answer to this question https://nl.mathworks.com/matlabcentral/answers/346479-how-does-the-classification-learner-app-generate-roc-curves-for-decision-trees-and-how-do-i-tune-the#answer_316364
1 Comment
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!