How to Plot the ROC curve for the average of 10 fold cross validation using Matlab

19 vues (au cours des 30 derniers jours)
i used 10 fold cross validation for training the convolution nural network, that each layer was trained 10 times. my question is how can i plot the ROC curve for the average of (10-k fold) to represent the AUC for each layer

Réponse acceptée

Hiago Brajato
Hiago Brajato le 21 Nov 2019
I don`t know if my question will answer your question, but a way you can an average ROC Curve from 10 ROC curves (10 k-folds) for example is to use the function interp1. Below you can see the code responsible for producing the image as follows.
image.png
The idea is that you have to make the interpolation of each ROC Curve (each fold), and divide for the number of folds (k). It is important to remember that interp1 requires unique points (the points in X axis cannot repeat), so is needed to make a little pertubation in the points to achieve a good mean. The code:
intervals= linspace(0, 1, 100);
%beginning of the loop of folds.....
%ROC Curve and AUC (plotting the ROC Curve for each fold and an average of the folds)
[Xroc, Yroc, ~, AUCroc_per_fold(i)]= perfcurve(label_matrix(idx_test, :), scores(:, 1), 'maligna');
plot(Xroc, Yroc, 'LineWidth', 1.5); legends{i}= sprintf('fold %d (AUC = %.2f)', i, AUCroc_per_fold(i)); hold on;
%for getting an average of the ROC curves from each fold
x_adj= adjust_unique_points(Xroc); %interp1 requires unique points
if i==1 %if is the first fold
mean_curve= (interp1(x_adj, Yroc, intervals))/k;
else
mean_curve= mean_curve+ (interp1(x_adj, Yroc, intervals))/k;
end
%end of the loop of folds....
figure(1); plot(intervals, mean_curve, 'Color', 'Black', 'LineWidth', 3.0);
And below you can see the function for making a little pertubation in X axis. You can choose the alternative that is better for you. Probably you will not achieve a good average using the function unique because a lot of information will be lost.
function x= adjust_unique_points(Xroc)
x= zeros(1, length(Xroc));
aux= 0.0001;
for i=1: length(Xroc)
if i~=1
x(i)= Xroc(i)+aux;
aux= aux+0.0001;
end
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by