autogluon icon indicating copy to clipboard operation
autogluon copied to clipboard

How to make plot_ensemble_model() work in sagemaker (or any jupyter based env)

Open agt64 opened this issue 3 years ago • 3 comments

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!

agt64 avatar Feb 20 '22 23:02 agt64

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?

agt64 avatar Mar 07 '22 05:03 agt64

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()

agt64 avatar Mar 07 '22 16:03 agt64

Thanks for the info! We will try to make this process easier in a future release.

Innixma avatar Mar 07 '22 18:03 Innixma

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))

Innixma avatar Jun 13 '23 17:06 Innixma