资源简介
用MATLAB实现ROC曲线
代码片段和文件信息
function [auc curve] = ROC(score target Lp Ln)
% This function is to calculat the ordinats of points of ROC curve and the area
% under ROC curve(AUC).
% This program was described in Fawcett‘s paper “ROC Graphs: notes and practical
% considerations for researchers“.
%
% Output:
% curve: N*3 matrix.
% the 1st column is FP
% the 2nd column is TP
% the 3rd column is score
% note: the last row etc.the last point is [110]. if output of this
% function is applied to roc_av.m to calculate average curve of roc
% it should be delete
% auc: scale number area under ROC curve.
%
% Input parameters:
% score: output of classifier. high socre denote the pattern is more likely
% to be POSITIVE pattern.
% target: classlabel of each pattern.
% Lp: label of POSITIVE pattern.
% Ln: label of NEGATIVE pattern.
%
%
% QingRen (qingren_ny#126.com)
% 2006-7-20
%
len = length(score); % number of patterns
if len ~= length(target)
error(‘The length of tow input vectors should be equal\n‘);
end
P = 0; % number of Positive pattern
N = 0; % number of Negative pattern
for i = 1:len
if target(i) == Lp
P = P + 1;
elseif target(i) == Ln
N = N + 1;
else
error(‘Wrong target value‘);
end
end
% sort “L“ in decending order by scores
score = score(:);
target = target(:);
L = [score target];
L = sortrows(L1);
index = len:-1:1;
index = index‘; %‘
L = L(index:);
fp = 0; fp_pre = 0; % number of False Positive pattern
tp = 0; tp_pre = 0; % number of True Positive pattern.
score_pre = -10000;
curve = [];
auc = 0;
for i = 1:len
if L(i1) ~= score_pre
curve = [curve; [fp/N tp/P L(i1)]];
auc = auc + trapezoid(fp fp_pre tp tp_pre);
score_pre = L(i1);
fp_pre = fp;
tp_pre = tp;
end
if L(i2) == Lp
tp = tp + 1;
else
fp = fp + 1;
end
end
curve = [curve; [110]];
auc = auc / P / N;
auc = auc + trapezoid(1 fp_pre/N 1 tp_pre/P);
% calculat the area of trapezoid
function area = trapezoid(x1x2y1y2)
a = abs(x1-x2);
b = abs(y1+y2);
area = a * b / 2;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2276 2006-12-24 10:25 roc.m
----------- --------- ---------- ----- ----
2276 1
相关资源
- 压缩感知(Compressed Sensing CS)matlab代
- Matlab功率谱计算
- 纸牌识别Matlab源程序+报告
- dijkstra算法改进的matlab程序能求出两点
- 基于OFDMA系统的多用户资源分配算法,
- matlab图像归一化代码
- EEMD的MATLAB程序
- MATLAB蒸气云爆炸模型VEC
- 提取图片纹理特征能量、熵、惯性矩
- 基于遗传算法的机器人路径规划matl
- BP神经网络实现手写数字识别matlab实现
- PCA人脸识别Eigenface特征脸Matlab
-
Matlab+Simuli
nk-cmi、miller、双相码 - 数字识别matlab源代码
-
MATLAB/simuli
nk短路电流仿真 - matlab2019运动目标检测--数字图像处理
- Allan方差分析MATLAB代码,含MPU6050八小
- 暗通道去雾MATLAB205097
- 自动寻峰谷算法matlab实现
- 基于MATLAB的车牌定位源程序
- 基于sift特征的人民币识别matlab版
- 《MATLAB仿真在现代通信中的应用》徐
- CARS-PLS 用于光谱数据或色谱数据变量
- matlab人脸皮肤分层、图像检测、检测
- CARS matlab 代码
- 基于MATLAB的OFDM系统仿真及性能分析
- AR模型算法的matlab实现和实验分析
- 基于自适应压扩法降低OFDM系统的峰均
- 自抗扰控制ADRC的MATLAB仿真+书籍资料
- matlab模式识别工具箱PRTOOLS及使用说明
评论
共有 条评论