#!/usr/bin/env python # coding: utf-8 # In[ ]: # install pycaret # pip install pycaret # pip install pycaret[full] # In[33]: from pycaret.utils import version version() # In[34]: from pycaret.datasets import get_data data = get_data('anomaly') # In[47]: data.describe().transpose() # In[ ]: # In[36]: type(data) # In[ ]: # In[35]: data.shape # In[48]: from pycaret.anomaly import * s = setup(data, session_id = 123, log_experiment = True, experiment_name = 'anomaly-demo') # In[49]: models() # In[50]: iforest = create_model('iforest') # In[60]: iforest # In[61]: iforest = create_model('iforest', n_estimators=200) iforest # In[56]: knn = create_model('knn') print(knn) # In[63]: plot_model(iforest, plot = 'umap') # In[64]: save_model(iforest, model_name = 'abc') # In[65]: l = load_model('abc') # In[68]: from pycaret.anomaly import load_model, predict_model l = load_model('iforest-abc', platform = 'aws', authentication = .......) p = predict_model(l, data=data) p.head() # In[74]: p # In[80]: iforest = create_model('iforest', fraction = 0.05) results = assign_model(iforest) results.head() # In[83]: results['Anomaly_Score'].hist(bins=100, figsize=(10,6)) # In[ ]: # In[ ]: # In[71]: from sklearn import set_config set_config(display=None) # In[72]: l # In[73]: deploy_model(iforest, 'iforest-abc', platform = 'aws', authentication = {'bucket' : 'pycaret-test'}) # In[ ]: # In[ ]: # In[ ]: # In[ ]: # In[ ]: # In[51]: iforest # In[52]: type(iforest) # In[53]: results = assign_model(iforest) results.head() # In[ ]: