AtulyaManikandan

Experiment 4-2

Mar 26th, 2025 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # GITHUB LINK: https://github.com/YBI-Foundation/Dataset/blob/main/Salary%20Data.csv
  2.  
  3. import numpy as np
  4. import pandas as pd
  5. import seaborn as sns
  6. import matplotlib.pyplot as plt
  7. from sklearn.ensemble import IsolationForest
  8. df=pd.read_csv('Salary Data.csv')
  9. df.head(10)
  10. sns.violinplot(df.Salary)
  11. model = IsolationForest(n_estimators=50,max_samples='auto',contamination=float(0.1),max_features=1.0)
  12. model.fit(df[['Salary']])
  13. df['scores']=model.decision_function(df[['Salary']])
  14. df['anomaly']=model.predict(df[['Salary']])
  15. df.head(20)
  16. anomaly=df.loc[df['anomaly']==-1]
  17. anomaly_index=list(anomaly.index)
  18. print(anomaly)
Advertisement
Add Comment
Please, Sign In to add comment