Ax icon indicating copy to clipboard operation
Ax copied to clipboard

Fix get_countour_plot() not plotting all trials

Open ligerlac opened this issue 1 year ago • 3 comments

This fixes a bug where get_countour_plot() plots all but the last trial. The corresponding issue is here: https://github.com/facebook/Ax/issues/2221.

ligerlac avatar Apr 01 '24 15:04 ligerlac

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 [email protected]. Thanks!

facebook-github-bot avatar Apr 01 '24 15:04 facebook-github-bot

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

facebook-github-bot avatar Apr 01 '24 18:04 facebook-github-bot

AxClient.get_contour_plot() plots the training data of the model of the generation strategy as 'in-sample': https://github.com/facebook/Ax/blob/29671645247d34004f7aef67d64870c9d13b0a59/ax/plot/helper.py#L189 However, this does not necessarily contain all trials of the experiment. For example, in the code snippet provided in the original issue (https://github.com/facebook/Ax/issues/2221#issue-2151849012), 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 https://github.com/facebook/Ax/pull/2305/commits/3d2eec27050ec84deb062280db1176e2f02a2da6# 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: https://github.com/facebook/Ax/blob/29671645247d34004f7aef67d64870c9d13b0a59/ax/service/ax_client.py#L1186-L1189 But that might be unexpected behavior. Maybe @mgarrard can comment?

ligerlac avatar Apr 02 '24 13:04 ligerlac