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

Enable plotting custom data in visualizations #374

Merged
merged 6 commits into from Sep 15, 2023
Merged

Conversation

btjanaka
Copy link
Member

@btjanaka btjanaka commented Sep 15, 2023

Description

This PR seeks to solve two issues:

  1. Plotting data from old archives. For instance, if we previously called as_pandas() on an archive and stored an old dataframe, we may want to plot that dataframe afterwards, e.g., during our data analysis.
  2. Plotting custom data that is not necessarily the objective. For instance, [FEATURE REQUEST] Separable objs and heatmap metrics #195 requests plotting metrics that are not necessarily the objective. Another reasonable case is that we have stored some metric in our metadata and wish to plot it instead of the objective.

I propose that these two issues are really the same issue. In particular, both of these are asking to visualize custom data that are not currently in the archive. Issue 1 wants to plot old data, and Issue 2 wants to plot data with a different objective.

Thus, this PR adds a single parameter, df, that can be used to change the data that is plotted. Essentially, when this parameter is provided, the archive only provides configurations like the upper/lower bounds of the measure space and the cell boundaries, while df provides the content that is plotted. This df may be retrieved from an earlier call to as_pandas on the archive, thus resolving Issue 1. Furthermore, users can replace df["objective"] on their own, thus resolving Issue 2. This feature also allows a user to plot data after performing operations on the dataframe; for instance, one could filter the dataframe and plot the X highest performing solutions.

Caveats

  • It is a bit cumbersome to ask users to ask users to manually set df["objective"]. However, the only alternative I could think of was to pass in a callable that takes in the dataframe or an EliteBatch and then returns new values to plot. However, this is equally cumbersome as users need to understand the callable format in addition to the dataframe structure.
  • It is possible that users pass in a "corrupted" dataframe, e.g., one that has out-of-bounds indices. However, for now, I believe it is reasonable to assume users will only get dataframes from as_pandas() and will not perform operations that introduce such entries. In the future, we can add validation checks if this becomes an issue.

TODO

  • Add df param to all visualization functions
  • Add util for preprocessing data param
  • Add tests for all visualization functions

Questions

Status

  • I have read the guidelines in
    CONTRIBUTING.md
  • I have formatted my code using yapf
  • I have tested my code by running pytest
  • I have linted my code with pylint
  • I have added a one-line description of my change to the changelog in
    HISTORY.md
  • This PR is ready to go

@btjanaka btjanaka changed the title Enable plotting custom data in visualize functions Enable plotting custom data in visualizations Sep 15, 2023
@btjanaka btjanaka merged commit b6de0f9 into master Sep 15, 2023
0 of 18 checks passed
@btjanaka btjanaka deleted the visualize-data branch September 15, 2023 07:16
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.

None yet

1 participant