Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: error with residuals_interactive plot #2547

Closed
3 tasks done
moezali1 opened this issue May 13, 2022 · 2 comments · Fixed by #2550 or #2557
Closed
3 tasks done

[BUG]: error with residuals_interactive plot #2547

moezali1 opened this issue May 13, 2022 · 2 comments · Fixed by #2550 or #2557
Assignees
Labels
bug Something isn't working priority_high

Comments

@moezali1
Copy link
Collaborator

pycaret version checks

Issue Description

plot_model(model, plot = 'residuals_interactive') generates error. see below to reproduce.

Reproducible Example

from pycaret.datasets import get_data
data = get_data('insurance')

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

dt = create_model('dt')

plot_model(dt, plot = 'residuals_interactive')

Expected Behavior

The plot is displayed but after the plot error is printed. see below log.

Actual Results

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Input In [23], in <cell line: 1>()
----> 1 plot_model(dt, plot = 'residuals_interactive')

File ~\anaconda3\envs\pycaret-develop\lib\site-packages\pycaret\internal\utils.py:911, in check_if_global_is_not_none.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    909     if globals_d[name] is None:
    910         raise ValueError(message)
--> 911 return func(*args, **kwargs)

File ~\anaconda3\envs\pycaret-develop\lib\site-packages\pycaret\regression\functional.py:1555, in plot_model(estimator, plot, scale, save, fold, fit_kwargs, plot_kwargs, groups, use_train_data, verbose, display_format)
   1455 @check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
   1456 def plot_model(
   1457     estimator,
   (...)
   1467     display_format: Optional[str] = None,
   1468 ) -> str:
   1470     """
   1471     This function analyzes the performance of a trained model on holdout set.
   1472     It may require re-training the model in certain cases.
   (...)
   1552 
   1553     """
-> 1555     return _CURRENT_EXPERIMENT.plot_model(
   1556         estimator=estimator,
   1557         plot=plot,
   1558         scale=scale,
   1559         save=save,
   1560         fold=fold,
   1561         fit_kwargs=fit_kwargs,
   1562         plot_kwargs=plot_kwargs,
   1563         groups=groups,
   1564         verbose=verbose,
   1565         use_train_data=use_train_data,
   1566         display_format=display_format,
   1567     )

File ~\anaconda3\envs\pycaret-develop\lib\site-packages\pycaret\regression\oop.py:1339, in RegressionExperiment.plot_model(self, estimator, plot, scale, save, fold, fit_kwargs, plot_kwargs, groups, use_train_data, verbose, display_format)
   1244 def plot_model(
   1245     self,
   1246     estimator,
   (...)
   1256     display_format: Optional[str] = None,
   1257 ) -> str:
   1259     """
   1260     This function analyzes the performance of a trained model on holdout set.
   1261     It may require re-training the model in certain cases.
   (...)
   1336 
   1337     """
-> 1339     return super().plot_model(
   1340         estimator=estimator,
   1341         plot=plot,
   1342         scale=scale,
   1343         save=save,
   1344         fold=fold,
   1345         fit_kwargs=fit_kwargs,
   1346         plot_kwargs=plot_kwargs,
   1347         groups=groups,
   1348         verbose=verbose,
   1349         use_train_data=use_train_data,
   1350         system=True,
   1351         display_format=display_format,
   1352     )

File ~\anaconda3\envs\pycaret-develop\lib\site-packages\pycaret\internal\pycaret_experiment\tabular_experiment.py:2023, in _TabularExperiment.plot_model(self, estimator, plot, scale, save, fold, fit_kwargs, plot_kwargs, groups, feature_name, label, use_train_data, verbose, system, display, display_format)
   2020     self.logger.info("Visual Rendered Successfully")
   2022 # execute the plot method
-> 2023 ret = locals()[plot]()
   2024 if ret:
   2025     plot_filename = ret

File ~\anaconda3\envs\pycaret-develop\lib\site-packages\pycaret\internal\pycaret_experiment\tabular_experiment.py:677, in _TabularExperiment.plot_model.<locals>.residuals_interactive()
    674     resplots.write_html(plot_filename)
    676 self.logger.info("Visual Rendered Successfully")
--> 677 return plot_filename

UnboundLocalError: local variable 'plot_filename' referenced before assignment

Installed Versions

3.0

@moezali1 moezali1 added bug Something isn't working priority_high labels May 13, 2022
@moezali1 moezali1 added this to the pycaret 3.0.0rc1 milestone May 13, 2022
Yard1 added a commit that referenced this issue May 13, 2022
@Yard1 Yard1 mentioned this issue May 13, 2022
13 tasks
Yard1 added a commit that referenced this issue May 13, 2022
@moezali1 moezali1 reopened this May 14, 2022
@moezali1
Copy link
Collaborator Author

@Yard1 The issue still exist. I have reproduced it here

@Yard1 Yard1 mentioned this issue May 15, 2022
13 tasks
Yard1 added a commit that referenced this issue May 19, 2022
@moezali1
Copy link
Collaborator Author

The issue is fixed now. Thanks

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working priority_high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants