In scikit-learn, one can train a OneClassSVM with rbf kernel; and it will provide a "decision_function" which, when supplying new data to predict, will supposedly tells you the distance from the new data point to the separating hyperplane; (but the interpretation is unimportant to me; more on that here)
Is there an equivalent to this "decision function" in R?
Here is an example from python:
from sklearn import datasets
from sklearn.svm import OneClassSVM
iris = datasets.load_iris()
svm = OneClassSVM(kernel='rbf',random_state=1)
svmTrained = svm.fit(iris.data)
svmPred = svm.predict(iris.data[1,:].reshape(1,-1))
svmDist = svm.decision_function(iris.data[1,:].reshape(1,-1))
I am interested in duplicating this in R, but am stuck on svmDist
... here is a start in R:
attach(iris)
x <- subset(iris, select=-Species)
svmTrained = svm(x, y = NULL, type = "one-classification", kernel = "radial")
svmPred = predict(svmTrained, newdata = x[1,], type = "probability",
decision.values = TRUE)
#svmDist = ?
The answer to this may be buried in trying to translate the C++ here into R. I will putz with that as time permits, but was hoping something may already exist in some obscure package I've never heard of.