How to plot confusion matrix using load_model?

37 Views Asked by At

Is it possible to use the plot_model function from pycaret without using the setup function first?

The following code demonstrates the issue:

from pycaret.datasets import get_data
import pandas as pd
from pycaret.classification import ClassificationExperiment
juice = get_data('juice')
exp = ClassificationExperiment() 
exp.setup(data = juice, target = 'Purchase')
lr = exp.create_model('lr')
exp.save_model(lr, 'lr-test-pipeline')
exp2 = ClassificationExperiment() 
lr2 = exp2.load_model('lr-test-pipeline')
lr2.predict(juice.drop(['Purchase'], axis=1))
print(exp2.get_config(None))
exp2.set_config('X_test', juice)
exp2.set_config('y_test', juice[['Purchase']])
exp2.plot_model(lr2, plot = 'confusion_matrix')

The result is

ValueError: Variable X_test not found or is not writeable. 

Alternatively is there a way of doing this manually with yellowbrick.classifier.ConfusionMatrix and lr2 using the preprocessing transforms built into lr2?

0

There are 0 best solutions below