plot_roc_curve
在sklearn0.22版本中,可以实现一行代码画出ROC-AUC图
sklearn.metrics.plot_roc_curve(estimator, X, y, sample_weight=None, drop_intermediate=True, response_method='auto', name=None, ax=None, **kwargs)
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.plot_roc_curve.html?highlight=plot_roc_#sklearn.metrics.plot_roc_curve
例子:
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, model_selection, svm
X, y = datasets.make_classification(random_state=0)
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, random_state=0)
clf = svm.SVC(random_state=0)
clf.fit(X_train, y_train)
display = metrics.plot_roc_curve(clf, X_test, y_test)
print('type(display):',type(display))
plt.show()
结果:
type(di