Skip to content
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

Division by Zero in LocalOutlierFactor #334

Closed
dmnc opened this issue May 22, 2024 · 2 comments
Closed

Division by Zero in LocalOutlierFactor #334

dmnc opened this issue May 22, 2024 · 2 comments

Comments

@dmnc
Copy link
Contributor

dmnc commented May 22, 2024

The LocalOutlierFactor anomaly detector sometimes sets the k-distance to INF at https://github.com/RubixML/ML/blob/master/src/AnomalyDetectors/LocalOutlierFactor.php#L215.

Then, when using contamination and running localReachabilityDensity we take a max of the k-distances https://github.com/RubixML/ML/blob/master/src/AnomalyDetectors/LocalOutlierFactor.php#L317 and divide 1 by it, giving zero.

Lastly, this zero is used for division at https://github.com/RubixML/ML/blob/master/src/AnomalyDetectors/LocalOutlierFactor.php#L295 which gives a division by zero error.

I'm struggling to understand why I ended up with the infinite k-distance, and if it is a problem (or a peculiarity) with my data, but I keep running into this issue.

@dmnc
Copy link
Contributor Author

dmnc commented May 22, 2024

Changing to use an EPSILON if the local reachability density is zero, seems to give sensible results. I'll raise a PR in case that's an approach you'd like to take.

@andrewdalpino
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants