⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 computeap.m

📁 一款数据挖掘的软件
💻 M
字号:
% ComputeAP: calculate the average precision
% 
% Parameters:
% Y_prob: array of predicted probability
% Y_test: array of true labels
% class_set: set of all possible labels

function AvgPrec = ComputeAP(Y_prob, Y_test, class_set)

[junk, Index] = sort(-Y_prob);
TrueLabel = Y_test(Index);
AvgPrec = 0;
NumPos = 0;
for j = 1:length(TrueLabel)
    NumPos = NumPos + (TrueLabel(j) == class_set(1));
    AvgPrec = AvgPrec + (TrueLabel(j) == class_set(1)) * NumPos / j;
end;
if (sum(TrueLabel == class_set(1)) ~= 0) 
	AvgPrec = AvgPrec / sum(TrueLabel == class_set(1));
end;
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -