facebook / Ax

Adaptive Experimentation Platform
https://ax.dev
MIT License
2.36k stars 303 forks source link

ax_client.generation_strategy.trials_as_df #2569

Closed Fa20 closed 2 months ago

Fa20 commented 3 months ago

Hallo Ax team,

I attached some trials but I can not display the attached trial as completed trial using :

ax_client.generation_strategy.trials_as_df

mgarrard commented 3 months ago

Hi Fa20, thanks for reaching out. In order for us to help you best it's useful to format questions with context on your goal/application, code that we can directly run on our side, and direct ptr to the issue vs the expected behavior. If you could provide that, that would be awesome. Thank you :)

Fa20 commented 3 months ago

@mgarrard


from ax.service.ax_client import AxClient, ObjectiveProperties
from ax.utils.measurement.synthetic_functions import hartmann6
from ax.utils.notebook.plotting import init_notebook_plotting, render

init_notebook_plotting()
ax_client = AxClient()
ax_client.create_experiment(
    name="hartmann_test_experiment",
    parameters=[
        {
            "name": "x1",
            "type": "range",
            "bounds": [0.0, 1.0],
            "value_type": "float",  # Optional, defaults to inference from type of "bounds".
            "log_scale": False,  # Optional, defaults to False.
        },
        {
            "name": "x2",
            "type": "range",
            "bounds": [0.0, 1.0],
        },
        {
            "name": "x3",
            "type": "range",
            "bounds": [0.0, 1.0],
        },
        {
            "name": "x4",
            "type": "range",
            "bounds": [0.0, 1.0],
        },
        {
            "name": "x5",
            "type": "range",
            "bounds": [0.0, 1.0],
        },
        {
            "name": "x6",
            "type": "range",
            "bounds": [0.0, 1.0],
        },
    ],
    objectives={"hartmann6": ObjectiveProperties(minimize=True)},
    parameter_constraints=["x1 + x2 <= 2.0"],  # Optional.
    outcome_constraints=["l2norm <= 1.25"],  # Optional.
)

import numpy as np

def evaluate(parameterization):
    x = np.array([parameterization.get(f"x{i+1}") for i in range(6)])
    # In our case, standard error is 0, since we are computing a synthetic function.
    return {"hartmann6": (hartmann6(x), 0.0), "l2norm": (np.sqrt((x**2).sum()), 0.0)}

para,index=ax_client.attach_trial(
    parameters={"x1": 0.9, "x2": 0.9, "x3": 0.9, "x4": 0.9, "x5": 0.9, "x6": 0.9}
)
ax_client.complete_trial(trial_index=index, raw_data=evaluate(para))
ax_client.generation_strategy.trials_as_df > >```
mgarrard commented 3 months ago

Hi @Fa20 - could you provide a snippet of what logs etc you get from running `ax_client.generation_strategy.trials_as_df ?

Fa20 commented 3 months ago

@mgarrard

grafik

mgarrard commented 2 months ago

Hi @Fa20 after doing some digging, this is because the trial is manually created. I have put up a fix and will update this thread once the fix lands on master

mgarrard commented 2 months ago

@Fa20 fix has landed on main in https://github.com/facebook/Ax/pull/2577?fbclid=IwZXh0bgNhZW0CMTEAAR3pIbAgHtQo5_malc-4Zo2rV7abaTxaFDOKb433YIJnhJjm36O1pH91ty8_aem_ZpjRscYOJhQC9ZYipO-akQ , we are planning to do an ax release later this week and this will be on the most update to date version of Ax. Will close the task once we cut the release

Abrikosoff commented 2 months ago

@Fa20 fix has landed on main in #2577 , we are planning to do an ax release later this week and this will be on the most update to date version of Ax. Will close the task once we cut the release

Hi Mia @mgarrard , excited to hear about the new Ax release! Would you be able to give a glimpse of a few of the major changes, if any?

mgarrard commented 2 months ago

Hey @Abrikosoff, this will be a general maintence release, and all the updates will be summarized in the release post -- I'm actually going to cut it Monday because we're close to the weekend now. Will link it here for you when it's done. As far as major upgrades, we are planning a bigger release end of year/ early next year to expose some more advanced methods and improve the usability of our framework :)

mgarrard commented 2 months ago

Closing the issue as the release just went out that includes the fix: https://github.com/facebook/Ax/releases/tag/0.4.1 cc @Fa20 and @Abrikosoff (release notes have all updates)