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

Modified save argument of plot_model() #1537

Merged
merged 9 commits into from
Sep 4, 2021
Merged

Conversation

bhanuteja2001
Copy link
Contributor

@bhanuteja2001 bhanuteja2001 commented Aug 26, 2021

Enchancement #1288

  • Enhanced the plot_model function to save the figure at any destination in the system.

Describe the changes you've made

Modified the save argument of plot_model to save the figure at the destination mentioned by the user. Instead of just saving the figure in the current directory.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tested with the confusion matrix plot.

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

NA

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Screenshots

Original picture of Log file Picture saved at the destination mentioned
Screenshot (422)_LI
Screenshot (418)

Screenshot (420)

@bhanuteja2001 bhanuteja2001 changed the title added save_path feature for plot_model() Modified save argument for adding the path to directory to save a plot plot_model() Aug 28, 2021
@bhanuteja2001 bhanuteja2001 changed the title Modified save argument for adding the path to directory to save a plot plot_model() Modified save argument of plot_model() Aug 28, 2021
@moezali1 moezali1 requested a review from Yard1 August 28, 2021 13:56
@Yard1
Copy link
Member

Yard1 commented Sep 1, 2021

Hey @bhanuteja2001 thank you for doing this. Could we do something like this instead for all plots?

                if save:
                    if not isinstance(save, bool):
                        plot_filename = os.path.join(save, plot_filename)
                    logger.info(f"Saving '{plot_filename}'")
                    fig.write_html(plot_filename)

This will be much easier to maintain. Thanks! Let me know if you have any questions.

@bhanuteja2001
Copy link
Contributor Author

@Yard1 sure let's do it this way

@bhanuteja2001
Copy link
Contributor Author

@Yard1 I have made the changes.
Please check now.

Copy link
Member

@Yard1 Yard1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a few more comments. Happy to merge once those are addressed and CI passes 🚀

@@ -6918,8 +6934,10 @@ def tree():
display.move_progress()
display.clear_output()
if save:
logger.info(f"Saving '{plot_name}.png' in current active directory")
plt.savefig(f"{plot_name}.png", bbox_inches="tight")
if not isinstance(save, bool):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

@@ -6963,8 +6981,10 @@ def calibration():
display.move_progress()
display.clear_output()
if save:
logger.info(f"Saving '{plot_name}.png' in current active directory")
plt.savefig(f"{plot_name}.png", bbox_inches="tight")
if not isinstance(save, bool):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

@@ -7607,7 +7631,10 @@ def summary(show: bool = True):
shap_plot = shap.summary_plot(shap_values, test_X, show=show, **kwargs)

if save:
plt.savefig(f"SHAP {plot}.png", bbox_inches="tight")
if save == True:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed here

@@ -7640,7 +7667,10 @@ def correlation(show: bool = True):
logger.info("model type detected: type 2")
shap.dependence_plot(dependence, shap_values, test_X, show=show, **kwargs)
if save:
plt.savefig(f"SHAP {plot}.png", bbox_inches="tight")
if save == True:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed here

@bhanuteja2001
Copy link
Contributor Author

@Yard1 please check now.
I have made the changes as requested.

@Yard1 Yard1 self-assigned this Sep 3, 2021
@Yard1 Yard1 merged commit e3d5c0f into pycaret:master Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants