Advertisement
teceai

Untitled

May 11th, 2021
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import pandas as pd
  2. from sklearn.ensemble import IsolationForest
  3.  
  4. df = pd.read_csv('/datasets/sales.csv')
  5. data = df[['Sales', 'Profit']]
  6.  
  7. sales = df['Sales'].values.reshape(-1, 1)
  8. profit = df['Profit'].values.reshape(-1, 1)
  9.  
  10. isolation_forest = IsolationForest(n_estimators=100)
  11. isolation_forest.fit(data)
  12. #estimator = isolation_forest.predict(data)
  13. estimator = isolation_forest.fit_predict(data)
  14.  
  15. outliers = (estimator == -1).tolist()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement