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

Exercise

Choosing contamination

Even though the code implementation only takes a few lines, finding the suitable contamination requires attention.

Recall that contamination parameter only affects the results of IForst. Once IForest generates raw anomaly scores, contamination is used to chose the top n% of anomaly scores as outliers. For example, 5% contamination will choose the observations with the highest 5% of anomaly scores as outliers.

Although we will discuss some tuning methods in the following video, for now, you will practice setting an arbitrary value to the parameter.

The data is loaded as big_mart.

Instructions

100 XP
  • Instantiate an IForest() estimator with 5% contamination.
  • Fit the instance to the Big Mart sales data.