Home > Net >  How to save the model comparison dataframe from compare_models() in pycaret?
How to save the model comparison dataframe from compare_models() in pycaret?

Time:06-13

I want to save the model comparison data frame from compare_models() in pycaret.

# load dataset
from pycaret.datasets import get_data
diabetes = get_data('diabetes')

# init setup
from pycaret.classification import *
clf1 = setup(data = diabetes, target = 'Class variable')

# compare models
best = compare_models()

enter image description here

i.e. this data frame as shown above.

Does anyone know how to do that?

CodePudding user response:

compare_models() returns a pandas dataframe, containing the information of the list of models. Hence, you only need to save a dataframe, which can be for example achieved with best.to_csv(path). If you want to save the object in a different format (pickle, xml, ...), you can refer to pandas i/o documentation.

CodePudding user response:

The solution is :

df = pull()

by Goosang Yu from the pycaret slack community.

  • Related