pycaret / pycaret

An open-source, low-code machine learning library in Python
https://www.pycaret.org
MIT License
8.95k stars 1.77k forks source link

[BUG]: TypeError: draw() got an unexpected keyword argument 'ax' from evaluate_model() #3459

Closed lobbie closed 1 year ago

lobbie commented 1 year ago

pycaret version checks

Issue Description

I am following Mr Ali's tutorial at Introduction to Regression in Python with PyCaret

An error when using evaluate_model(mycatboost). Error message below,

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)
    255                     value = widget.get_interact_value()
    256                     self.kwargs[widget._kwarg] = value
--> 257                 self.result = self.f(**self.kwargs)
    258                 show_inline_matplotlib_plots()
    259                 if self.auto_display and self.result is not None:

/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/pycaret/internal/pycaret_experiment/tabular_experiment.py in _plot_model(self, estimator, plot, scale, save, fold, fit_kwargs, plot_kwargs, groups, feature_name, label, use_train_data, verbose, system, display, display_format)
   1942                 # execute the plot method
   1943                 with redirect_output(self.logger):
-> 1944                     ret = locals()[plot]()
   1945                 if ret:
   1946                     plot_filename = ret

/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/pycaret/internal/pycaret_experiment/tabular_experiment.py in pipeline()
    574                         )
    575 
--> 576                         d.draw(ax=ax, showframe=False, show=False)
    577                         ax.set_aspect("equal")
    578                         plt.axis("off")

TypeError: draw() got an unexpected keyword argument 'ax'

It also gave a warning below,

findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif
findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif
findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif

Can anyone advise how do I fix this at my end?

Thanks, Lobbie

Reproducible Example

import numpy as np
import pandas as pd
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 1000)
pd.set_option('display.width', 1000)
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt

from pycaret.datasets import get_data
dataset = get_data('diamond')

#check the shape of data
dataset.shape

data = dataset.sample(frac=0.9, random_state=786)
data_unseen = dataset.drop(data.index)

data.reset_index(drop=True, inplace=True)
data_unseen.reset_index(drop=True, inplace=True)

print('Data for Modeling: ' + str(data.shape))
print('Unseen Data For Predictions: ' + str(data_unseen.shape))

from pycaret.regression import *
s = setup(data = data, target = 'Price', session_id=123)

best = compare_models()

mycatboost = create_model('catboost')

tuned_mycatboost = tune_model(mycatboost)

plot_model(mycatboost)
plot_model(tuned_mycatboost)
plot_model(mycatboost, plot = 'error')
plot_model(mycatboost, plot='feature')

evaluate_model(mycatboost)

Expected Behavior

Evaluate Model should display the plots without errors and users can interactively review model performance.

Actual Results

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)
    255                     value = widget.get_interact_value()
    256                     self.kwargs[widget._kwarg] = value
--> 257                 self.result = self.f(**self.kwargs)
    258                 show_inline_matplotlib_plots()
    259                 if self.auto_display and self.result is not None:

/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/pycaret/internal/pycaret_experiment/tabular_experiment.py in _plot_model(self, estimator, plot, scale, save, fold, fit_kwargs, plot_kwargs, groups, feature_name, label, use_train_data, verbose, system, display, display_format)
   1942                 # execute the plot method
   1943                 with redirect_output(self.logger):
-> 1944                     ret = locals()[plot]()
   1945                 if ret:
   1946                     plot_filename = ret

/anaconda/envs/wt38_pycaret/lib/python3.8/site-packages/pycaret/internal/pycaret_experiment/tabular_experiment.py in pipeline()
    574                         )
    575 
--> 576                         d.draw(ax=ax, showframe=False, show=False)
    577                         ax.set_aspect("equal")
    578                         plt.axis("off")

TypeError: draw() got an unexpected keyword argument 'ax'
findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif
findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif
findfont: Generic family 'sans-serif' not found because none of the following families were found: Arial, Liberation Sans, Bitstream Vera Sans, sans-serif


### Installed Versions

<details>
System:
    python: 3.8.16 (default, Mar  2 2023, 03:21:46)  [GCC 11.2.0]
executable: /anaconda/envs/wt38_pycaret/bin/python
   machine: Linux-5.15.0-1031-azure-x86_64-with-glibc2.17

PyCaret required dependencies:
                 pip: 23.0.1
          setuptools: 60.10.0
             pycaret: 3.0.0
             IPython: 7.34.0
          ipywidgets: 7.7.5
                tqdm: 4.64.1
               numpy: 1.23.5
              pandas: 1.5.3
              jinja2: 3.1.2
               scipy: 1.9.1
              joblib: 1.2.0
             sklearn: 1.2.2
                pyod: 1.0.9
            imblearn: 0.10.1
   category_encoders: 2.6.0
            lightgbm: 3.3.5
               numba: 0.56.4
            requests: 2.28.2
          matplotlib: 3.6.3
          scikitplot: 0.3.7
         yellowbrick: 1.5
              plotly: 5.14.0
             kaleido: 0.2.1
         statsmodels: 0.13.5
              sktime: 0.16.1
               tbats: 1.1.2
            pmdarima: 2.0.3
              psutil: 5.9.0

PyCaret optional dependencies:
                shap: 0.41.0
           interpret: 0.3.2
                umap: 0.5.3
    pandas_profiling: 3.6.6
  explainerdashboard: 0.4.2.1
             autoviz: 0.1.58
           fairlearn: 0.7.0
             xgboost: 1.7.5
            catboost: 1.1.1
              kmodes: 0.12.2
             mlxtend: 0.22.0
       statsforecast: 1.5.0
        tune_sklearn: 0.4.5
                 ray: 2.3.1
            hyperopt: 0.2.7
              optuna: 3.1.0
               skopt: 0.9.0
              mlflow: 1.30.0
              gradio: 3.24.1
             fastapi: 0.95.0
             uvicorn: 0.21.1
              m2cgen: 0.10.0
           evidently: 0.2.8
               fugue: 0.8.3
           streamlit: Not installed
             prophet: Not installed
</details>
lobbie commented 1 year ago

any updates on this error, please

Utsav-2301 commented 1 year ago

I am facing the same error and not getting any idea how to solve it

turkalpmd commented 1 year ago

I have also same error

Yard1 commented 1 year ago

Hi, this was fixed in https://github.com/pycaret/pycaret/commit/b4cf58ab8feb982e7b2639beee5ff2b9f686d3f7 - please do pip install "schemdraw<0.16"

lobbie commented 1 year ago

thank you. issue is fixed now with pip install "schemdraw<0.16"