scikitplot绘制ROC图

https://github.com/reiinakano/scikit-plot

文档:https://scikit-plot.readthedocs.io/en/stable/metrics.html

# The usual train-test split mumbo-jumbo
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB

X, y = load_digits(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
nb = GaussianNB()
nb.fit(X_train, y_train)
predicted_probas = nb.predict_proba(X_test)

# The magic happens here
import matplotlib.pyplot as plt
import scikitplot as skplt
print(y_test.shape, predicted_probas.shape)
skplt.metrics.plot_roc(y_test, predicted_probas)
plt.show()

(594,) (594, 10)

posted @ 2020-11-22 14:41  douzujun  阅读(297)  评论(0编辑  收藏  举报