0

I have a dataset of normal points Xtr and I would like to fit a OneClass-SVM for anomaly detection purposes.

from sklearn.svm import OneClassSVM

#fit
ocsvm = OneClassSVM(nu=NU, kernel='rbf', gamma=GAMMA)
ocsvm.fit(X=Xtr)

Then, I would like to assess if every point in the test set Xts is an anomaly:

ocsvm.predict(Xts)

I would like also to determine a degree of anomaly by calculating the distance from the boundary:

ocsvm.decision_function(Xts)

Everything easy so far, but I would like to understand which feature contributes more to causing an anomaly? How can I determine which of the n variables exceeded the limit of the normality curve defined by the one-class SVM during the training phase?

Should I manually calculate the distance for every x in Xts over all the coordinates (the n features) to understand the actual contribution of each feature? Do there exist some libraries that already do it?

I have checked sklearn and pyod but it seems that this calculation is not implemented.

Pier
  • 97
  • 1
  • 13

0 Answers0