Hi,
You can do:

```
from sklearn.metrics import roc_curve, auc

X_test = np.r_[ND, AD]
pred = clf.predict(X_test)

y_true = np.array([0] * 500 + [1] *  500)

fpr, tpr, thresholds = roc_curve(y_true, scoring)

# then you can plot(fpr, tpr) to get the roc curve and compute the AUC with:
AUC = auc(fpr, tpr)

```

Best,
Nicolas

2015-10-20 3:41 GMT+02:00 Ady Wahyudi Paundu <awpau...@gmail.com>:

> Hi all,
>
> Can I create ROC curve for one_class_SVM classifier?
> If I can, can you give pointer on how to do this? (or a link?)
>
> for example now i have:
> LD: normal data for learning (100 item)
> ND: normal data for evaluation (500 item)
> AD: abnormal data for evaluation (500 item)
>
> one_class_SVM code for evaluation would be something like this (NU and
> GA is user input):
>
> clf = svm.OneClassSVM(nu=float(NU), kernel="rbf", gamma=float(GA))
> clf.fit(LD)
> y_pred_train = clf.predict(LD)
> y_pred_test = clf.predict(ND)
> y_pred_outliers = clf.predict(AD)
> n_error_train = y_pred_train[y_pred_train == -1].size
> n_error_test = y_pred_test[y_pred_test == -1].size
> n_error_outliers = y_pred_outliers[y_pred_outliers == 1].size
>
> how to produce ROC curve from there?
>
> Thanks in advance
> ~Ady
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
------------------------------------------------------------------------------
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to