Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Isolation Forest Implementation | Isolation-Based Methods
Outlier and Novelty Detection in Practice

bookChallenge: Isolation Forest Implementation

Opgave

Swipe to start coding

You are given a 2D dataset containing normal points and a few outliers. Your goal is to train an Isolation Forest model to detect anomalies, compute anomaly scores, and flag potential outliers.

Steps:

  1. Import and initialize IsolationForest from sklearn.ensemble.
  2. Fit the model on the dataset X.
  3. Compute anomaly scores using decision_function(X).
  4. Predict labels using .predict(X) — note:
    • 1 → inlier
    • -1 → outlier
  5. Print the number of detected outliers and show example scores.
  6. Use parameters: contamination=0.15, random_state=42, and n_estimators=100.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

Awesome!

Completion rate improved to 4.55

bookChallenge: Isolation Forest Implementation

Stryg for at vise menuen

Opgave

Swipe to start coding

You are given a 2D dataset containing normal points and a few outliers. Your goal is to train an Isolation Forest model to detect anomalies, compute anomaly scores, and flag potential outliers.

Steps:

  1. Import and initialize IsolationForest from sklearn.ensemble.
  2. Fit the model on the dataset X.
  3. Compute anomaly scores using decision_function(X).
  4. Predict labels using .predict(X) — note:
    • 1 → inlier
    • -1 → outlier
  5. Print the number of detected outliers and show example scores.
  6. Use parameters: contamination=0.15, random_state=42, and n_estimators=100.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

some-alt