我一直在尝试评估一类SVM的性能。我尝试使用scikit-learn绘制ROC曲线,结果有些奇怪。
X_train, X_test = train_test_split(compressed_dataset,test_size = 0.5,random_state = 42)
clf = OneClassSVM(nu=0.1,kernel = "rbf", gamma =0.1)
y_score = clf.fit(X_train).decision_function(X_test)
pred = clf.predict(X_train)
fpr,tpr,thresholds = roc_curve(pred,y_score)
#绘制roc曲线
plt.figure()
plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)
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('ROC Curve')
plt.legend(loc="lower right")
plt.show()
有人可以帮我这个忙吗?
这个情节有什么奇怪之处?您固定了一组nu和gamma,因此您的模型既不会过度拟合,也不会拟合不足。移动阈值(这是ROC变量)不会导致100%TPR。尝试使用较高的伽玛值和非常小的nu(训练误差上限),您将获得更多的“典型”图。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句