Skip to content

Instantly share code, notes, and snippets.

@FelixChop
Created March 24, 2020 04:35
Show Gist options
  • Save FelixChop/d3d6ce29da1700e31e3f794e33e6e9a7 to your computer and use it in GitHub Desktop.
Save FelixChop/d3d6ce29da1700e31e3f794e33e6e9a7 to your computer and use it in GitHub Desktop.
from sklearn.ensemble import IsolationForest
outlier_detection = IsolationForest(random_state=1, behaviour="new")
outlier_detection.fit(titanic[['Fare', 'SibSp', 'Parch', 'Age']].dropna())
data = titanic[['Fare', 'SibSp', 'Parch', 'Age']].dropna()
data['anomaly_score'] = outlier_detection.score_samples(data)
data.sort_values('anomaly_score')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment