function [auc, hCurve] = rocplot(actual, predScore, names, posclass)
% Receiver Operating Characteristic Plot
%
% rocplot(actual, predScore, names, [posclass])

% Copyright 2014 MathWorks, Inc.

if nargin < 4, posclass = 1; end

N = size(predScore,2);
cla;
color = lines(N);
hCurve = zeros(1,N);
auc = zeros(1,N);
if size(actual,2) == 1 % Binary classification
    actual = repmat(actual, 1, N);
end
for i = 1:N
    [rocx, rocy, ~, auc(i), rocPt] = perfcurve(actual(:,i), predScore(:,i), posclass); 
    hCurve(i) = line(rocx, rocy, 'Color', color(i,:));
    line(rocPt(1), rocPt(2), 'Color', color(i,:), 'Marker', '.', 'MarkerSize', 3);
end
legend(hCurve, names, 'interpreter','none');
title('ROC Performance Curves'); grid on; 
xlabel('False Positive Rate (1-Specificity)'); ylabel('True Positive Rate (Sensitivity)');