Skip to content

Instantly share code, notes, and snippets.

@Younes-Charfaoui
Created July 1, 2020 19:58
Show Gist options
  • Select an option

  • Save Younes-Charfaoui/8f1391c412f92a1f38f1549170b521fa to your computer and use it in GitHub Desktop.

Select an option

Save Younes-Charfaoui/8f1391c412f92a1f38f1549170b521fa to your computer and use it in GitHub Desktop.
# import the libraries
from sklearn.cluster import DBSCAN
import pandas as pd
# read your data
data = pd.read_csv("yourData.csv")
# create the isolation forest
outlier_detection = DBSCAN(eps = 0.2, metric=”euclidean”, min_samples = 5, n_jobs = -1)
# fit and predict the outliers
outliers_cluster = outlier_detection.fit_predict(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment