How to obtain the second most frequent label using mode function
조회 수: 2 (최근 30일)
이전 댓글 표시
% 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
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!