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

11 ビュー (過去 30 日間)
Salma Hassan 2019 年 6 月 16 日

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

サインインしてコメントする。

### 採用された回答

Hiago Brajato 2019 年 11 月 21 日
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.
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
if i==1 %if is the first fold
else
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.
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

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeVisualization and Interpretability についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by