Ax icon indicating copy to clipboard operation
Ax copied to clipboard

how to get plots(slice, contour) from 'ax_client_snapshot.json'?

Open rachelhson opened this issue 2 years ago • 3 comments

Hello,

I am trying to plot plot_slice, contour using saved ax_client_snapshot.json. Could you help me to have plots from ax_client_snapshot.json? I used following code for the plots, however I am getting AttributeError. Is there a way to get these plots from restored_ax_client?

restored_ax_client = ( AxClient.load_from_json_file() ) model = restored_ax_client.generation_strategy.model render(plot_slice(model, param1_name, objective)) render(interact_contour(model=model, metric_name=objective)) image

Thank you :)

rachelhson avatar Dec 08 '23 19:12 rachelhson

@rachelhson the basic problem is that we don't serialize fitted models. So instead of

model = restored_ax_client.generation_strategy.model

you would need to do

model = restored_ax_client.generation_strategy._curr.model(
    experiment=restored_ax_client.experiment,
    data=restored_ax_client.experiment.lookup_data(),
    **restored_ax_client.generation_strategy._curr.model_kwargs
)

After you call restored_ax_client.get_next_trial() though, you can go back to the original way of doing it.

danielcohenlive avatar Dec 08 '23 20:12 danielcohenlive

Thanks for your reply @danielcohenlive . This works for plotting slice model and contour.

If I use generation strategy for my model. Does it have to separately store and call to retrieve?

rachelhson avatar Dec 13 '23 20:12 rachelhson

@rachelhson can you rephrase the question. I'm not sure what you mean by "call to retrieve". And store and call to retrieve during which operation. Thanks :)

danielcohenlive avatar Dec 20 '23 17:12 danielcohenlive

@rachelhson I'm going to close this as it's been inactive for a long time, but you can reopen if you'd like to follow up.

danielcohenlive avatar Jul 08 '24 21:07 danielcohenlive