1. Learn
  2. /
  3. Courses
  4. /
  5. Anomaly Detection in Python

Connected

Exercise

LOF with outlier probabilities

As always, double-check that the chosen contamination level is trustworthy by filtering the outliers with a probability threshold. The syntax is the same as with KNN.

LOF estimator has already been imported, and the females_transformed dataset is also available.

Instructions

100 XP
  • Instantiate LOF() with 20 neighbors.
  • Calculate outlier probabilities into probs.
  • Create a boolean mask named is_outlier that returns true values where the outlier probability is over 50%.
  • Use is_outlier to filter the outliers from females_transformed.