필터 지우기
필터 지우기

How do I change the class label of the confusion matrix?

조회 수: 54 (최근 30일)
tinkiewinkie
tinkiewinkie 2020년 3월 5일
댓글: the cyclist 2022년 9월 17일
Hi suppose I used the code below and the class label of the confusion matrix is 1,2,3. How to I change the class label to 'apple' , 'watermelon' and 'pear'?
cm = confusionchart([1 3 5; 2 4 6; 11 7 3]);
cm.Title = 'My Confusion Matrix Title';

채택된 답변

the cyclist
the cyclist 2020년 3월 5일
편집: the cyclist 2020년 3월 5일
According to the documentation:
cm = confusionchart([1 3 5; 2 4 6; 11 7 3],{'apple','watermelon','pear'});
cm.Title = 'My Confusion Matrix Title';
  댓글 수: 2
Elysi Cochin
Elysi Cochin 2022년 9월 17일
How will it work for the below line
confusionchart(trueClass, predictedClass);
The below code is showing error
cm = confusionchart(trueClass, predictedClass, {'Class1', 'Class2'});
the cyclist
the cyclist 2022년 9월 17일
Your case has an important difference from the original question, in that they had the confusion matrix already calculated. So, it works a bit differently.
For you, it depends on what does your data look like. You can work on characters directly.
trueClass = {'Class1','Class1','Class2','Class2'};
predictedClass = {'Class1','Class1','Class2','Class1'};
confusionchart(trueClass, predictedClass);
If your data are numeric, I think the easiest is to convert the input data into character arrays.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by