问题
I have a question about Calculating anomaly score for Anomaly detection using One-Class SVM. My question is that: How can I calculate it using decision_function(X), just the way I calculate anomaly score in Isolation forest? Thanks a lot,
回答1:
In Isolation Forests, anomaly score is a measure of the deviation of average length of the path required to single out a particular observation from the average length of path required to single out a "normal" observation
The average here is taken over all the different trees that are used. Since SVM is not an ensemble method - this notion of anomaly score does not directly apply.
One way, and I don't know how statistically/scientifically sound this is, of measuring an anomaly score is to build multiple SVM classifiers based on a subset of predictors. You could then use the percentage of times a particular point is classified as an outlier as a proxy for an anomaly score.
回答2:
Yes, you have to use decision_function()
as the measure of anomaly score in one class SVM.
Have a look at this example, you might get better understanding.
clf.decision_function(X_test)
# returns the signed distance to the separating hyperplane.
# Signed distance is positive for an inlier and negative for an outlier.
来源:https://stackoverflow.com/questions/53956538/calculating-anomaly-score-for-anomaly-detection-using-one-class-svm