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

Fix get_countour_plot() not plotting all trials #2305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ligerlac
Copy link

@ligerlac ligerlac commented Apr 1, 2024

This fixes a bug where get_countour_plot() plots all but the last trial. The corresponding issue is here: #2221.

@facebook-github-bot
Copy link
Contributor

Hi @ligerlac!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 1, 2024
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@ligerlac
Copy link
Author

ligerlac commented Apr 2, 2024

AxClient.get_contour_plot() plots the training data of the model of the generation strategy as 'in-sample':

observations = model.get_training_data()

However, this does not necessarily contain all trials of the experiment. For example, in the code snippet provided in the original issue (#2221 (comment)), the model of the generation strategy is updated when ax_client.get_next_trial() is called. Therefore, the last trial will not be displayed in the contour plot.
Passing all trials as generator_runs_dict like so 3d2eec2 leads to duplicated data points except for the last trial. Alternatively, only trials that are not already present in the training data could be passed. Both solutions, however, result in a plot where the colored contours of the model do not take all displayed data points into account, which might be counter-intuitive.
Another possible solution would be to fit the model one more time before making the plot, ensuring the model is up-to-date with all completed trials. Something similar is done when retrieving the model's predictions here:

Ax/ax/service/ax_client.py

Lines 1186 to 1189 in 2967164

# Fit model to ensure:
# - model is instantiated if needed
# - any new completed trials are fit to the model
self.fit_model()

But that might be unexpected behavior.
Maybe @mgarrard can comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants