python - Roc curve multiclass cross validated data set -


i try compute multiclass roc curve on cross validated data set. have no train , test set.

now, line fpr[i], tpr[i], _ = roc_curve(y[:, i], y_pred[:, i]) gives me following error:indexerror: many indices array. tried fpr[i], tpr[i], _ = roc_curve(y, y_pred). error: valueerror: data not binary , pos_label not specified.

can see problem?

vec = dictvectorizer() x = vec.fit_transform(instances) scaler = standardscaler(with_mean=false) x_scaled = scaler.fit_transform(x)  enc = labelencoder() y = enc.fit_transform(labels)   n_classes = 3  feat_sel = selectkbest(mutual_info_classif, k=200) x_fs = feat_sel.fit_transform(x_scaled, y)   clf = onevsrestclassifier(logisticregression(solver='newton-cg',  multi_class='multinomial')) clf.fit(x_fs,y) clf.label_binarizer_ y_pred = model_selection.cross_val_predict(clf, x_fs, y, cv=10)   fpr = dict() tpr = dict() roc_auc = dict() in range(n_classes):     fpr[i], tpr[i], _ = roc_curve(y[:, i], y_pred[:, i])     roc_auc[i] = auc(fpr[i], tpr[i])  # plot of roc curve specific class  in range(n_classes):     plt.figure()     plt.plot(fpr[i], tpr[i], label='roc curve (area = %0.2f)' % roc_auc[i])     plt.plot([0, 1], [0, 1], 'k--')     plt.xlim([0.0, 1.0])     plt.ylim([0.0, 1.05])     plt.xlabel('false positive rate')     plt.ylabel('true positive rate')     plt.title('receiver operating characteristic example')     plt.legend(loc="lower right")     plt.show()`enter code here` 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -