Challenge: Isolation Forest Implementation
Oppgave
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:
- Import and initialize
IsolationForestfromsklearn.ensemble. - Fit the model on the dataset
X. - Compute anomaly scores using
decision_function(X). - Predict labels using
.predict(X)— note:1→ inlier-1→ outlier
- Print the number of detected outliers and show example scores.
- Use parameters:
contamination=0.15,random_state=42, andn_estimators=100.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 4
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 4.55
Challenge: Isolation Forest Implementation
Sveip for å vise menyen
Oppgave
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:
- Import and initialize
IsolationForestfromsklearn.ensemble. - Fit the model on the dataset
X. - Compute anomaly scores using
decision_function(X). - Predict labels using
.predict(X)— note:1→ inlier-1→ outlier
- Print the number of detected outliers and show example scores.
- Use parameters:
contamination=0.15,random_state=42, andn_estimators=100.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 4
single