How to obtain the second most frequent label using mode function
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaire
Réponses (1)
Steven Lord
le 6 Sep 2019
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!