【问题标题】:Inputs for the ROC curveROC 曲线的输入
【发布时间】:2015-05-04 04:35:05
【问题描述】:

我有一个 2 列矩阵,其中每一行是健康(第 1 列)和不健康(2 列)患者的观察结果。另外,我有 5 个分区值应该用于绘制 ROC 曲线。 您能否帮助我了解如何从这些数据中获取 perfcurve 函数的输入?

感谢您的回复!

【问题讨论】:

    标签: matlab curve roc


    【解决方案1】:

    我制作了一个小脚本,显示给定两列矩阵输入的性能曲线的基础知识。如果您在 MATLAB 中执行此操作并仔细查看,那么使用 perfcurve 应该没有问题

    %Simulate your data as Gaussian data with 1000 measurements in each group. 
    %Lets give them a mean difference of 1 and a standard deviation of 1.
    Data = zeros(1000,2);
    Data(:,1) = normrnd(0,1,1000,1);
    Data(:,2) = normrnd(1,1,1000,1);
    
    %Now the data is reshaped to a vector (required for perfcurve) and  I create the labels.
    Data = reshape(Data,2000,1);
    Labels = zeros(size(Data,1),1);
    Labels(end/2+1:end) = 1; 
    %Your bottom half of the data (initially second column) is now group 1, the
    %top half is group 0. 
    %Lets set the positive class to group 1.
    PosClass = 1;
    
    %Now we have all required variables to call perfcurve. We will give
    %perfcurve the 'Xvals' input to define the values at which the ROC curve is
    %calculated. This parameter can be left out to let matlab calculate the
    %curve at all values. 
    [X Y] = perfcurve(Labels,Data,PosClass, 'Xvals', 0:0.25:1);
    
    %Lets plot this
    plot(X,Y)
    
    %One limitation in scripting it like this is that you must have equal group
    %sizes for healthy and sick. If you reshape your Data matrix to a vector
    %and keep a seperate labels vector then you can also handle groups of
    %different sizes. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-27
      • 2018-01-03
      • 2019-12-26
      • 2014-07-20
      • 2012-05-02
      • 2018-04-25
      • 2019-02-09
      • 1970-01-01
      相关资源
      最近更新 更多