pycaret / pycaret

An open-source, low-code machine learning library in Python
https://www.pycaret.org
MIT License
8.93k stars 1.77k forks source link

[BUG]: plot_model(iforest) shows no graph in pycaret #2608

Closed mw1296 closed 2 years ago

mw1296 commented 2 years ago

pycaret version checks

Issue Description

Following the tutorial https://github.com/pycaret/pycaret/blob/master/tutorials/Anomaly%20Detection%20Tutorial%20Level%20Beginner%20-%20ANO101.ipynb when I approach plot_model(iforest), the plot displays nothing. I've enabled inline graph and unmuted the plot, and make sure this is not a display issue. The only change I made is that I'm using "Anomaly" dataset instead of "Mice". Any thought what is the issue?

Reproducible Example

import seaborn as sns
from pycaret.datasets import get_data
import graphviz
import pydot
import pydot_ng as pydot
pydot.find_graphviz()
dataset = get_data('anomaly')

# check shape of data
dataset.shape
# withhold 5% of data for testing purpose
data=dataset.sample(frac=0.95, random_state=678)
data_unseen=dataset.drop(data.index)
data.reset_index(drop=True,inplace=True)
data_unseen.reset_index(drop=True, inplace=True)

# pairplot

# seting up environment for Pycaret
from pycaret.anomaly import *
exp_ano101=setup(data,normalize=True,
                 session_id=123
                 )

# create a model
iforest=create_model('iforest') 
print(iforest)
# note that the contamination=0.05 determines the proportion of outliers in the dataset

# assign anomaly labels to dataset to analyze result with iforest
iforest_results=assign_model(iforest)
iforest_results.head()

# plot model
plot_model(iforest,'tsne')

Expected Behavior

https://cdn-images-1.medium.com/max/1000/1*XprV1KkrqkEBMKxLh7aCCw.png

Actual Results

no graph is shown and the created plot has no value

Installed Versions

2.2
kilickursat commented 2 years ago

Could you try to install "!pip install matplotlib==3.1.3" and try to plot? It might be helpful.

ngupta23 commented 2 years ago

@mw1296 This is a very old version of pycaret. Can you upgrade to the latest version? It should not have any issues.

pip install -U --pre pycaret