ComeçarComece de graça

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.

Este exercício faz parte do curso

Anomaly Detection in Python

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Instantiate an LOF with 20 neighbors and fit to the data
lof = ____
lof.____

# Calculate probabilities
probs = ____

# Create a boolean mask
is_outlier = ____

# Use the boolean mask to filter the outliers
outliers = ____

print(len(outliers))
Editar e executar o código