How to plot confusion matrix?

5 ビュー (過去 30 日間)
Niculai Traian
Niculai Traian 2018 年 10 月 6 日
回答済み: Purvaja 2025 年 2 月 17 日
Hello, i want to plot a confusion matrix, but i don't know witch are the true labels target and witch are predicted labels outputs.
plotconfusion(targets,outputs) plots a confusion matrix for the true labels targets and predicted labels outputs. Specify the labels as categorical vectors, or in one-of-N (one-hot) form.
Please help.

回答 (1 件)

Purvaja
Purvaja 2025 年 2 月 17 日
According to your question, you want to know which variables would be the right arguments for “plotconfusionfunction.
As mentioned in documentation:
plotconfusion(targets,outputs) plots a confusion matrix for the true labels targets and predicted labels outputs.”
After observing your workspace variables, I have observed that you have YTest” and “YPred” variables, which would signify targets and outputs arguments for “plotconfusion” function.
So you can implement your function as follows:
plotconfusion(YTest, YPred);
For more clarification, the following documentation links would be helpful:
You can also try “confusionmatfunction :
You can try this command in your MATLAB command window for specific release documentation:
web(fullfile(docroot, 'images/ref/plotconfusion.html'))
For examples enter following command in your command window:
openExample('nnet/PlotConfusionMatrixUsingCategoricalLabelsExample')
Hope this helps you!

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by