ROC – Receiver operating characteristics (đặc tính hoạt động thu nhận).
Dùng metrics.plot_roc_curve(clf, X_test, y_test) để vẽ đường cong ROC.
Các bước
Tạo bài toán phân loại n-class ngẫu nhiên. Ban đầu tạo cụm điểm phân phối chuẩn (std=1) quanh đỉnh hypercube 'n_informative'-chiều cạnh '2*class_sep', gán số cụm bằng nhau cho mỗi class. Giới thiệu sự phụ thuộc giữa đặc trưng và thêm nhiễu. Dùng make_classification().
Chia mảng thành train/test ngẫu nhiên, dùng train_test_split().
Huấn luyện mô hình SVM theo dữ liệu train, dùng fit().
Vẽ đường cong ROC, dùng plot_roc_curve().
Hiển thị figure bằng plt.show().
Ví dụ
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()
Kết quả
