-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Local outlier factor gives incorrect results #9874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have also just compared the scikit result with the R package 'Rlof', which also gives me a result of: c = matrix(c(0,0,0,1,1,1,3,0),nrow=4, ncol=2,byrow=TRUE)
> lof(c, 2, method="manhattan")
[1] 0.875000 1.333333 0.875000 2.000000 So there is definitely something wrong with the scikit implementation. |
The LOFs of the training samples are given by import numpy as np
from sklearn.neighbors import LocalOutlierFactor
c=np.array([[0,0],[0,1],[1,1],[3,0]])
k=2 #numNeighbours
clf = LocalOutlierFactor(n_neighbors=k, n_jobs=-1,algorithm='brute',metric='manhattan').fit(c)
Z = clf.negative_outlier_factor_
print(-Z)
[ 0.875 1.33333333 0.875 2. ] The private |
@jeroneandrews have you tried using |
... |
@albertcthomas @ngoix |
Steps/Code to Reproduce
However, the result should be: [ 0.875 1.333 0.875 2. ] if you work it out by hand (assuming a sample can't be the 1st nearest neighbour to itself). So, I think there is something wrong with the LOF implementation. Could somebody confirm either way?
The text was updated successfully, but these errors were encountered: