分類学習機アプリで学習させた結果の出力方法

2 views (last 30 days)
Yumi Iwakami
Yumi Iwakami on 22 Aug 2022
Commented: Yumi Iwakami on 22 Sep 2022
分類学習機アプリで5交差検証法を使って学習させた結果を一覧出力しようとしています.
混同行列やモデルの出力は出来たのですが,どのデータの予測が正解でどのデータの予測が誤りだったのか検証したいと考えています.
イメージとしては,以下の様になるのが理想です.
被験者ID  分類ラベル  予測結果
  1    Positive   Positive
  2    Positive   Negative

Accepted Answer

Kojiro Saito
Kojiro Saito on 22 Sep 2022
モデルをエクスポートした後に元データと予測結果からtableを作ればできるかと思います。
ドキュメントの例に含まれているフィッシャーのアヤメデータを使ってサンプルを書きます。
t = readtable('fisheriris.csv');
% ID列を追加
t.ID = (1:height(t))';
% 分類学習器を起動
% classificationLearner
% 学習させたモデルを「コンパクトモデルのエクスポート」でcompactTrainedModelという変数でワークスペースで保存
% ここではmatファイルに出力したものを読み込みます
load compactTrainedModel
yPred = compactTrainedModel.predictFcn(t);
resultTable = table(t.ID, t.Species, yPred, 'VariableNames', {'ID', '分類ラベル', '予測結果'});
disp(resultTable)
ID 分類ラベル 予測結果 ___ ______________ ______________ 1 {'setosa' } {'setosa' } 2 {'setosa' } {'setosa' } 3 {'setosa' } {'setosa' } 4 {'setosa' } {'setosa' } 5 {'setosa' } {'setosa' } 6 {'setosa' } {'setosa' } 7 {'setosa' } {'setosa' } 8 {'setosa' } {'setosa' } 9 {'setosa' } {'setosa' } 10 {'setosa' } {'setosa' } 11 {'setosa' } {'setosa' } 12 {'setosa' } {'setosa' } 13 {'setosa' } {'setosa' } 14 {'setosa' } {'setosa' } 15 {'setosa' } {'setosa' } 16 {'setosa' } {'setosa' } 17 {'setosa' } {'setosa' } 18 {'setosa' } {'setosa' } 19 {'setosa' } {'setosa' } 20 {'setosa' } {'setosa' } 21 {'setosa' } {'setosa' } 22 {'setosa' } {'setosa' } 23 {'setosa' } {'setosa' } 24 {'setosa' } {'setosa' } 25 {'setosa' } {'setosa' } 26 {'setosa' } {'setosa' } 27 {'setosa' } {'setosa' } 28 {'setosa' } {'setosa' } 29 {'setosa' } {'setosa' } 30 {'setosa' } {'setosa' } 31 {'setosa' } {'setosa' } 32 {'setosa' } {'setosa' } 33 {'setosa' } {'setosa' } 34 {'setosa' } {'setosa' } 35 {'setosa' } {'setosa' } 36 {'setosa' } {'setosa' } 37 {'setosa' } {'setosa' } 38 {'setosa' } {'setosa' } 39 {'setosa' } {'setosa' } 40 {'setosa' } {'setosa' } 41 {'setosa' } {'setosa' } 42 {'setosa' } {'setosa' } 43 {'setosa' } {'setosa' } 44 {'setosa' } {'setosa' } 45 {'setosa' } {'setosa' } 46 {'setosa' } {'setosa' } 47 {'setosa' } {'setosa' } 48 {'setosa' } {'setosa' } 49 {'setosa' } {'setosa' } 50 {'setosa' } {'setosa' } 51 {'versicolor'} {'versicolor'} 52 {'versicolor'} {'versicolor'} 53 {'versicolor'} {'versicolor'} 54 {'versicolor'} {'versicolor'} 55 {'versicolor'} {'versicolor'} 56 {'versicolor'} {'versicolor'} 57 {'versicolor'} {'versicolor'} 58 {'versicolor'} {'versicolor'} 59 {'versicolor'} {'versicolor'} 60 {'versicolor'} {'versicolor'} 61 {'versicolor'} {'versicolor'} 62 {'versicolor'} {'versicolor'} 63 {'versicolor'} {'versicolor'} 64 {'versicolor'} {'versicolor'} 65 {'versicolor'} {'versicolor'} 66 {'versicolor'} {'versicolor'} 67 {'versicolor'} {'versicolor'} 68 {'versicolor'} {'versicolor'} 69 {'versicolor'} {'versicolor'} 70 {'versicolor'} {'versicolor'} 71 {'versicolor'} {'virginica' } 72 {'versicolor'} {'versicolor'} 73 {'versicolor'} {'versicolor'} 74 {'versicolor'} {'versicolor'} 75 {'versicolor'} {'versicolor'} 76 {'versicolor'} {'versicolor'} 77 {'versicolor'} {'versicolor'} 78 {'versicolor'} {'virginica' } 79 {'versicolor'} {'versicolor'} 80 {'versicolor'} {'versicolor'} 81 {'versicolor'} {'versicolor'} 82 {'versicolor'} {'versicolor'} 83 {'versicolor'} {'versicolor'} 84 {'versicolor'} {'virginica' } 85 {'versicolor'} {'versicolor'} 86 {'versicolor'} {'versicolor'} 87 {'versicolor'} {'versicolor'} 88 {'versicolor'} {'versicolor'} 89 {'versicolor'} {'versicolor'} 90 {'versicolor'} {'versicolor'} 91 {'versicolor'} {'versicolor'} 92 {'versicolor'} {'versicolor'} 93 {'versicolor'} {'versicolor'} 94 {'versicolor'} {'versicolor'} 95 {'versicolor'} {'versicolor'} 96 {'versicolor'} {'versicolor'} 97 {'versicolor'} {'versicolor'} 98 {'versicolor'} {'versicolor'} 99 {'versicolor'} {'versicolor'} 100 {'versicolor'} {'versicolor'} 101 {'virginica' } {'virginica' } 102 {'virginica' } {'virginica' } 103 {'virginica' } {'virginica' } 104 {'virginica' } {'virginica' } 105 {'virginica' } {'virginica' } 106 {'virginica' } {'virginica' } 107 {'virginica' } {'virginica' } 108 {'virginica' } {'virginica' } 109 {'virginica' } {'virginica' } 110 {'virginica' } {'virginica' } 111 {'virginica' } {'virginica' } 112 {'virginica' } {'virginica' } 113 {'virginica' } {'virginica' } 114 {'virginica' } {'virginica' } 115 {'virginica' } {'virginica' } 116 {'virginica' } {'virginica' } 117 {'virginica' } {'virginica' } 118 {'virginica' } {'virginica' } 119 {'virginica' } {'virginica' } 120 {'virginica' } {'virginica' } 121 {'virginica' } {'virginica' } 122 {'virginica' } {'virginica' } 123 {'virginica' } {'virginica' } 124 {'virginica' } {'virginica' } 125 {'virginica' } {'virginica' } 126 {'virginica' } {'virginica' } 127 {'virginica' } {'virginica' } 128 {'virginica' } {'virginica' } 129 {'virginica' } {'virginica' } 130 {'virginica' } {'virginica' } 131 {'virginica' } {'virginica' } 132 {'virginica' } {'virginica' } 133 {'virginica' } {'virginica' } 134 {'virginica' } {'virginica' } 135 {'virginica' } {'virginica' } 136 {'virginica' } {'virginica' } 137 {'virginica' } {'virginica' } 138 {'virginica' } {'virginica' } 139 {'virginica' } {'virginica' } 140 {'virginica' } {'virginica' } 141 {'virginica' } {'virginica' } 142 {'virginica' } {'virginica' } 143 {'virginica' } {'virginica' } 144 {'virginica' } {'virginica' } 145 {'virginica' } {'virginica' } 146 {'virginica' } {'virginica' } 147 {'virginica' } {'virginica' } 148 {'virginica' } {'virginica' } 149 {'virginica' } {'virginica' } 150 {'virginica' } {'virginica' }
  1 Comment
Yumi Iwakami
Yumi Iwakami on 22 Sep 2022
コード付きの詳しい説明,ありがとうございます.
MATLABによる機械学習についてもうすこし勉強してみたいと思います.

Sign in to comment.

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox 入門 in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!