I tried to add a part of a python code to my R Script. Unfortunately it seems that I can't use a private function for the LocalOutlierFactor in R:
# Sample Data
n <- 5000
n_outlier <- .05 * n
set.seed(11212)
inlier <- mvtnorm::rmvnorm(n, mean = c(0,0))
outlier <- mvtnorm::rmvnorm(n_outlier, mean = c(20, 20))
testdata <- rbind(inlier, outlier)
smp_size <- floor(0.5 * nrow(testdata))
train_ind <- sample(seq_len(nrow(testdata)), size = smp_size)
train_lof <-as.data.frame(testdata[train_ind, ])
test_lof <- as.data.frame(testdata[-train_ind, ])
sklearn.neighbors <- import("sklearn.neighbors")
lof1 <- sklearn.neighbors$LocalOutlierFactor(n_neighbors=15)
lof1$fit(train_lof)
Now I want to predict for test_lof
with help of the private function _decision_function
from LocalOutlierFactor:
lof1$_decision_function(test_lof)
Unfortunately there is not such a function available when using reticulate (in Python the function is there). Does anyone know how to use private functions from reticulate and can help me? Thanks in advance.