Challenge: Isolation Forest Implementation
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 4
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Awesome!
Completion rate improved to 4.55
Challenge: Isolation Forest Implementation
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 4
single