-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable plotting custom data in visualizations (#374)
## Description <!-- Provide a brief description of the PR's purpose here. --> 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, #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 <!-- Notable points that this PR has either accomplished or will accomplish. --> - [x] Add `df` param to all visualization functions - [x] Add util for preprocessing data param - [x] Add tests for all visualization functions ## Questions <!-- Any concerns or points of confusion? --> ## Status - [x] I have read the guidelines in [CONTRIBUTING.md](https://github.com/icaros-usc/pyribs/blob/master/CONTRIBUTING.md) - [x] I have formatted my code using `yapf` - [x] I have tested my code by running `pytest` - [x] I have linted my code with `pylint` - [x] I have added a one-line description of my change to the changelog in `HISTORY.md` - [x] This PR is ready to go
- Loading branch information
Showing
18 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+105 KB
tests/visualize/baseline_images/cvt_archive_3d_plot_test/plot_metadata_with_df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+90.6 KB
tests/visualize/baseline_images/cvt_archive_heatmap_test/plot_metadata_with_df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.8 KB
...s/visualize/baseline_images/grid_archive_heatmap_test/plot_metadata_with_df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+214 KB
tests/visualize/baseline_images/parallel_axes_plot_test/plot_metadata_with_df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.8 KB
...seline_images/sliding_boundaries_archive_heatmap_test/plot_metadata_with_df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.