ROC − Receiver Operating Characteristics (ROC) Curve
โดยใช้เมธอด metrics.plot_roc_curve(clf, X_test, y_test) เราสามารถวาดเส้น ROC Curve ได้
ขั้นตอน
สร้างปัญหาการจำแนกคลาส n-class แบบสุ่ม เริ่มต้นสร้างกลุ่มจุดที่กระจายแบบ Normal (std=1) รอบยอดของ hypercube ขนาด n_informative มิติ ด้วยความยาวด้าน 2*class_sep และกำหนดจำนวนกลุ่มเท่ากันให้แต่ละคลาส ใช้เมธอด
make_classification()แบ่ง Arrays หรือ Matrices เป็น Train/Test แบบสุ่ม ใช้เมธอด
train_test_split()Fit โมเดล SVM ตามข้อมูลฝึก ใช้เมธอด
fit()วาด Receiver Operating Characteristic (ROC) Curve ใช้เมธอด
plot_roc_curve()ใช้
plt.show()แสดงกราฟ
ตัวอย่าง
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) metrics.plot_roc_curve(clf, X_test, y_test) plt.show()
ผลลัพธ์
