Skip to content

Skip Plotting in Table Report Based on Max Columns Given - #1255

Merged
jeromedockes merged 23 commits into
skrub-data:mainfrom
priscilla-b:skip-plot
Apr 3, 2025
Merged

Skip Plotting in Table Report Based on Max Columns Given#1255
jeromedockes merged 23 commits into
skrub-data:mainfrom
priscilla-b:skip-plot

Conversation

@priscilla-b

Copy link
Copy Markdown
Contributor

fixes #1245

@jeromedockes jeromedockes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is great, thank you very much @priscilla-b ! especially when we are inspecting intermediate steps in a pipeline, we often end up with dataframes that have a lot of columns and this will allow checking them without waiting a long time to generate lots of plots we won't look at 🚀

In fact it is so useful that I think the default should not be None but maybe 30 or something like that. but that would require adding clear messages in the report itself telling users what to do if they really want the plots, so it could be left for another pull request.

Comment thread skrub/_reporting/_table_report.py Outdated
if "_summary_with_plots" in self.__dict__:
return self._summary_with_plots
return self._summary_without_plots
if self.max_plot_columns is None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a great way of handling it! I think we should rename _any_summary and make it a regular method rather than a property. maybe self._any_summary -> self._get_summary()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought of this but wasn't sure the benefits of having it as a method than a property, so decided to maintain the existing implementation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry for the nitpick: could we rename get_summary to _get_summary? this is not something for users and we want the freedom to change the contents of the summary whenever we want so the leading underscore indicates it's not part of the public API

@GaelVaroquaux

GaelVaroquaux commented Mar 19, 2025 via email

Copy link
Copy Markdown
Member

priscilla-b and others added 2 commits March 19, 2025 22:51
Co-authored-by: Jérôme Dockès <jerome@dockes.org>
@priscilla-b

Copy link
Copy Markdown
Contributor Author

Will look into the issue of changing the default param to some arbitrary number

@jeromedockes jeromedockes added the TableReport anything related to the TableReport label Mar 20, 2025
@priscilla-b
priscilla-b marked this pull request as draft March 25, 2025 07:40
@jeromedockes

Copy link
Copy Markdown
Member

very nice @priscilla-b ! thanks for adding the message and doing the extra work to make it dismissable!

screenshot_2025-03-28T12:06:00+01:00

screenshot_2025-03-28T12:06:18+01:00

@jeromedockes jeromedockes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks! I know it's still in draft mode but took a quick look anyway :)

this really speeds up the report, now when there are many columns the bottleneck is definitely the computation of column associations

Comment on lines +780 to +786
this.elem.querySelector("[data-role='dismiss-button']")
.addEventListener("click", (e) => this.hide(e));
}

hide(event) {
this.elem.style.display = "none";
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
this.elem.querySelector("[data-role='dismiss-button']")
.addEventListener("click", (e) => this.hide(e));
}
hide(event) {
this.elem.style.display = "none";
}
this.elem.querySelector("[data-role='dismiss-button']")
.addEventListener("click", (e) => this.hide());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think here we can rely on the parent classe's hide() to hide the whole element and it simplifies things slightly?

Comment thread skrub/_reporting/_patching.py Outdated


def patch_display(pandas=True, polars=True, verbose=1):
def patch_display(pandas=True, polars=True, verbose=1, max_plot_columns=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

here also we could put 30 instead of None as the default

Comment thread skrub/_reporting/_summarize.py Outdated
summary["n_constant_columns"] = sum(
c["value_is_constant"] for c in summary["columns"]
)
summary["plots_skipped"] = all(not c["plot_names"] for c in summary["columns"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can define this based on the argument rather than inspecting the results, something like summary["plots_skipped"] = not with_plots. I think it is a bit simpler and slightly more robust (for example in the weird edge case where all columns are constant there will be no plots but not because they are skipped just because there is nothing to plot). WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I think I did this at first, but I thought we were just reverting the argument and not really checking the presence of the actual plots. But yeah, what I did makes it more complicated, and should just keep it simple.

if "_summary_with_plots" in self.__dict__:
return self._summary_with_plots
return self._summary_without_plots
if self.max_plot_columns is None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry for the nitpick: could we rename get_summary to _get_summary? this is not something for users and we want the freedom to change the contents of the summary whenever we want so the leading underscore indicates it's not part of the public API

Comment thread skrub/_reporting/_table_report.py Outdated
# there are too many columns
# Will be accessed in the HTML template to display a message to the user
summary["plots_auto_skipped"] = (
summary["plots_skipped"] and self.max_plot_columns == 30

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure why we compare max_plot_columns to 30 here? for example if the user sets it to 20 it would still be skipped?

maybe the template can look directly at plots_skipped which you add in summarize, or we could create a flag in the conditional blocks above that we then use eg

...
    summary = self._summary_with_plots
    plots_skipped = False
else:
    summary = self._summary_without_plots
    plots_skipped = True

summary['plots_auto_skipped'] = plots_skipped

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking that if the user set the param to skip the plots directly, they wouldn't need to be shown a message explaining why the plots were skipped.
I wanted to show the message only when the plots were automatically skipped, but couldn't really figure out a simple implementation for checking if the default value is being used or not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

aah ok I understand now, thanks. I didn't realize the goal was to avoid showing the message when the user intentionally skipped plotting by setting max_plot_columns.

I think it might be good to show the message whenever plotting was skipped, even if it is intentional, especially since you made it easy to dismiss the message but both options make sense

@Vincent-Maladiere

Copy link
Copy Markdown
Member

Hey @priscilla-b, thanks for working on this! It seems like the tiles without distributions are somewhat redundant with the 'stats' panel (the only difference being the IQR). Would it make sense to remove them entirely and display only your message in the distribution panel?

@jeromedockes

Copy link
Copy Markdown
Member

It seems like the tiles without distributions are somewhat redundant with the 'stats' panel

that's a good point. Still I would like to have this PR for the next release so maybe we should finish the few remaining details for the current version and open a separate issue for follow-ups?

@priscilla-b

priscilla-b commented Mar 31, 2025 via email

Copy link
Copy Markdown
Contributor Author

@Vincent-Maladiere

Copy link
Copy Markdown
Member

Right, let's do this in two steps then 👍

@jeromedockes jeromedockes added this to the 0.5.2 milestone Apr 1, 2025
@priscilla-b
priscilla-b marked this pull request as ready for review April 2, 2025 13:17

@Vincent-Maladiere Vincent-Maladiere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good on VSCode!

@jeromedockes jeromedockes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks again @priscilla-b 🎉

@jeromedockes
jeromedockes merged commit 1373ba3 into skrub-data:main Apr 3, 2025
rcap107 pushed a commit to rcap107/skrub that referenced this pull request Apr 3, 2025
rcap107 pushed a commit to rcap107/skrub that referenced this pull request Apr 3, 2025
rcap107 pushed a commit that referenced this pull request Apr 3, 2025
Co-authored-by: Jérôme Dockès <jerome@dockes.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TableReport anything related to the TableReport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip plotting in TableReport when there are many columns

4 participants