How to obtain the second most frequent label using mode function

2 ビュー (過去 30 日間)
MUHAMMAD SYAHIN IHSAN NOR'EN
MUHAMMAD SYAHIN IHSAN NOR'EN 2019 年 9 月 6 日
回答済み: Steven Lord 2019 年 9 月 6 日
% Get groups of rows corresponding to each filename
[Fidx,Filenames] = findgroups(featuresTest.Filename);
result = table();
for idx = 1:length(Filenames)
T = featuresTest(Fidx==idx,2:end); % Rows that correspond to one file
predictedLabels = string(predict(trainedClassifier,T(:,1:15))); % Predict
totalVals = size(predictedLabels,1);
[predictedLabel, freq] = mode(categorical(predictedLabels)); % Find most frequently predicted label
match1 = freq/totalVals*100;
  1 件のコメント
Adam
Adam 2019 年 9 月 6 日
Do a setdiff to remove the mode and then run the mode again.

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2019 年 9 月 6 日
Do you need to do this using the mode function?
If you're looking to compute the K most frequently predicted labels, I'd use histcounts in conjunction with maxk.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by