autogluon
autogluon copied to clipboard
How to make plot_ensemble_model() work in sagemaker (or any jupyter based env)
Has anyone figured out an easy way to make plot_ensemble_model() work in jupyter based environments? I'm having a lot of difficulty installing pygraphviz (think it might be related to pygraphviz not able to see where graphviz is being installed? but not sure)
I've tried the following code without success: %pip install python3-dev %pip install graphviz %pip install libgraphviz-dev %pip install pkg-config
%pip install pygraphviz
Thanks for the help!
As a workaround, I was able to install pygraphviz on my local machine. When I opened the predictor object on my local machine and run plot_ensemble_model(), it's still trying to save to the original path that I had set that was cloud storage. Is there an easy way to change the path attribute of a predictor object after its trained?
Here's my workaround from local machine (make sure to use / if windows instead of \ or \)
import autogluon import pickle import pygraphviz from autogluon.tabular import TabularPredictor
new_path = 'D:/target'
predictor = TabularPredictor.load(new_path) predictor.plot_ensemble_model()
Thanks for the info! We will try to make this process easier in a future release.
This should be resolved by #3259.
You can refer to the updated documentation on installation instructions here: https://auto.gluon.ai/dev/api/autogluon.tabular.TabularPredictor.plot_ensemble_model.html
Once installed, you can get it to display on a Jupyter Notebook via the following:
from autogluon.tabular import TabularDataset, TabularPredictor
train_data = TabularDataset('train.csv')
predictor = TabularPredictor(label='class').fit(train_data)
path_to_png = predictor.plot_ensemble_model()
# To view the plot inside a Jupyter Notebook, use the below code:
from IPython.display import Image, display
display(Image(filename=path_to_png))