How to draw each ROC curve of an SVM model with cross validation
I would like to make a graph like the following in python:
That is, one curve for each fold.
I have the following code where I use an SVM model to classify some data
kf = KFold(n_splits=10)
a, fma, fmi = [], [], []
for train, eval in kf.split(x_train):
x_train_i, x_eval_i, y_train_i, y_eval_i = x_train[train], x_train[eval], y_train[train], y_train[eval]
c = svm.SVC(kernel='rbf', gamma='scale', C=40).fit( x_train_i, y_train_i )
p = c.predict(x_eval_i)
acc = c.score(x_eval_i, y_eval_i)
f1ma = f1_score(y_eval_i, p, average='macro')
f1mi = f1_score(y_eval_i, p, average='micro')
a.append(acc)
fma.append(f1ma)
fmi.append(f1mi)
Would anyone know what to add in the loop to display a graph like the one above? Thank you very much.
Topic roc evaluation scikit-learn python machine-learning
Category Data Science