Create confusion matrix from LDA model

조회 수: 4 (최근 30일)
Leon
Leon 2024년 2월 23일
편집: Leon 2024년 2월 26일
It is easy to train an LDA model and find its accuracy by cross-validation as below:
Mdl = fitcdiscr(data, "Response_var_name", CrossVal="on");
validationAccuracy = 1 - kfoldLoss(Mdl, 'LossFun', 'ClassifError');
However, what is the easiest/best way to get the confusion matrix?
Thanks.

채택된 답변

the cyclist
the cyclist 2024년 2월 23일
The ClassificationDiscrimant class has a predict function. You can input the predicted and actual labels into the confusionchart function.
  댓글 수: 4
Leon
Leon 2024년 2월 23일
편집: Leon 2024년 2월 26일
Good to know. Maybe I would be better to use kfoldPredict(), then?
the cyclist
the cyclist 2024년 2월 23일
Yes, I think that is sensible.
I have to admit, though, that I don't fully comprehend how kfoldPredict goes from this statement (from the documentation)
========================================================================
"For every fold, kfoldPredict predicts class labels for validation-fold observations using a classifier trained on training-fold observations."
========================================================================
-- to a single prediction for the model (as opposed to a prediction per fold, which is how I read that statement). It is presumably possible to use the debugger to step into the function and see exactly what it is doing, but I have not done that.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discriminant Analysis에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by