I'm trying to save a pycaret plot but only get a blank file:
plt.figure(figsize = (18,9))
plot_model(pycaret_xgboost, 'auc')
plt.savefig('ROC_xboost.svg')
I'm trying to save a pycaret plot but only get a blank file:
plt.figure(figsize = (18,9))
plot_model(pycaret_xgboost, 'auc')
plt.savefig('ROC_xboost.svg')
Update pycaret to 2.0 (pip install pycaret==2.0
). A new parameter save
has been added in plot_model()
function. When save is set to True, a png / html file depending on the type of plot is saved in current working directory. Names of each plot is pre-defined.
@maria_g shared an correct reference.As in the answer the person is using only pyplot to both plot and save the graph.
Attached is an example of how vector plots (pdf, svg, eps) can be derived from pycaret models, using yellowbrick. It has been tested with googlecolab and pycaret 2.3.4.
#---- data
from pycaret.datasets import get_data
dataset = get_data('diamond')
#---- model pycaret
from pycaret.regression import *
exp_reg101 = setup(data = dataset, target = 'Price', session_id=123,
remove_multicollinearity = True, multicollinearity_threshold = 0.95)
lightgbm = create_model('lightgbm')
#---- plot
from yellowbrick.regressor import ResidualsPlot
X_train, X_test, y_train, y_test = get_config('X_train'), get_config('X_test'), get_config('y_train'), get_config('y_test')
visualizer = ResidualsPlot(lightgbm) # regression model
visualizer.fit(X_train, y_train) # Fit the training data to the visualizer
visualizer.score(X_test, y_test) # Evaluate the model on the test data
visualizer.poof(outpath="ResidualsPlot.pdf") # VECTOR .pdf .eps .svg, RASTER .png .jpg .tif
#visualizer.poof() # Finalize and render the figure
#---- file extensions supported
import matplotlib.pyplot as plt
plt.figure().canvas.get_supported_filetypes()
You are using pyplot and pycaret interchangeably. I suggest you to read the documentation thoroughly. The reason " ROC_xboost.svg" is blank because you didn't plot anything using pyplot. You clearly used pycaret's "plotmodel" to just plot it. Pycaret provides "save_model()" to save the created model though it wont save the plot. Please refer to https://pycaret.org/plot-model/, https://pycaret.org/save-model/ . Plot your model using pyplot.