Code to combine ROC curves and tell which one is better

3 visualizzazioni (ultimi 30 giorni)
Hi,
I want to make a ROC curve combining the ROC graphs from all the three sheets in the attached excel file into a single ROC curve, comparing the curves to determine which one is better. Below mentioned is the code that I am using to make a ROC curve from one sheet on this excel file. What changes should I make to the following code so that it gives me a ROC curve for all the three sheets in one plot?
>>meanthresh = 0.8:0.1:2.5; % This alters the mean threshold between 0.8 and 2.5 by 0.1
rocTable = readtable('ROC.xlsx','range','$A1:$D17');
%% Beginning the Mean ROC
for a = 1:length(meanthresh) %% the for loop makes it to where the threshold is automatically altered and you do not have to do it manually
positive_a = meanthresh(a) < (rocTable.Average); % declaring an algorithm to determine if the value is greater than the threshold
true = rocTable.FID == 1; %true = if the data in the column is equal to (==) 1
false = rocTable.FID == 0; %false = if the data in the column is equal to (==) 0
TP = sum(positive_a(true)); %true positive = if both the true statement (true) and the positive statement (positive_a) are met, then sum all the true values
FP = sum(positive_a(false)); %false positive = if both the false statement (false) and the positive statement (positive_a) are met, then sum all the false values
FN = sum(true) - TP; %false negative = sum of all true values minus the true positives
TN = sum(false) - FP; %true negative = sum of all false values minus the false positives
sensitivity_a(a) = (TP/(TP+FN)); %%sensitivity equation
specificity_a(a) = (TN/(TN+FP)); %%specificity equation
end %% end of for loop
stdevthresh = 0:0.1:1.7; %This alters the stdev threshold from 0 to 1.7 by 0.1
% Beginning of St Dev ROC
for b = 1:length(stdevthresh)
positive_b = stdevthresh(b) < (rocTable.SD); % declaring an algorithm to determine if the value is greater than the threshold
true = rocTable.FID == 1; %true = if the data in the column is equal to (==) 1
false = rocTable.FID == 0; %false = if the data in the column is equal to (==) 0
TPsd = sum(positive_b(true)); %true positive = if both the true statement (true) and the positive statement (positive_b) are met, then sum all the true values
FPsd = sum(positive_b(false)); %false positive = if both the false statement (false) and the positive statement (positive_b) are met, then sum all the false values
FNsd = sum(true) - TPsd; %false negative = sum of all true values minus the true positives
TNsd = sum(false) - FPsd; %true negative = sum of all false values minus the false positives
sensitivity_b(b) = (TPsd/(TPsd+FNsd)); %%equations for sensitivity and specificity
specificity_b(b) = (TNsd/(TNsd+FPsd));
end
plot(1-specificity_b, sensitivity_b, 'Marker', '.', 'MarkerSize', 16, 'LineWidth', 1); %%this is the standard deviation plot
hold on %%allows more than one graph to be on the same plot--must be followed by "hold off" when done
plot(1-specificity_a, sensitivity_a, 'Marker', '.', 'MarkerSize', 24, 'LineWidth', 1); %%plotting command for the mean ROC
hold off
legend('St. Devs', 'Averages'); %%this puts a legend on the graph--legend('first name', 'second name')
xlabel('False Positive Rate'); %%label on x axis
ylabel('True Positive Rate'); %%label on y axistitle('ROC for Mean Path Length'); %%title of graph
Thanks in advance for your help.

Risposte (1)

Subhadeep Koley
Subhadeep Koley il 9 Gen 2020
Hi, you can use the 'Sheet' Name-Value pair to specify the sheet you want to read data from.
Additionally, using a for loop, you can loop through the various sheets of the Excel file to plot the ROC curves.
rocTable = readtable('ROC.xlsx', 'Sheet', 'BM', 'range', '$A1:$D17');
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by