Skip to content

Commit

Permalink
Rename fn arg from parameters to parameterization in Service API …
Browse files Browse the repository at this point in the history
…tutorial (#2130)

Summary:
Rename the argument in the Service API tutorial `evaluate` function from `parameters` to `parameterization` to avoid confusion with the `parameters` configuration dictionary kwarg. This is also in line with the way the evaluate function is defined in the [corresponding section in the loop API tutorial](https://ax.dev/tutorials/gpei_hartmann_loop.html#1.-Define-evaluation-function).

i.e.,

```python
def evaluate(parameters):
    x = np.array([parameters.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)}

...

for i in range(25):
    parameters, trial_index = ax_client.get_next_trial()
    # Local evaluation here can be replaced with deployment to external system.
    ax_client.complete_trial(trial_index=trial_index, raw_data=evaluate(parameters))
```

becomes
```python
def evaluate(parameterization):
    x = np.array([parameters.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)}

...

for i in range(25):
    parameterization, trial_index = ax_client.get_next_trial()
    # Local evaluation here can be replaced with deployment to external system.
    ax_client.complete_trial(trial_index=trial_index, raw_data=evaluate(parameterization))
```

Pull Request resolved: #2130

Reviewed By: Balandat

Differential Revision: D52783577

Pulled By: danielcohenlive

fbshipit-source-id: 5df6bf9c2b9d245a1dbfbcb3bd916f93664a5dda
  • Loading branch information
sgbaird authored and facebook-github-bot committed Jan 15, 2024
1 parent 4de2a81 commit bad2837
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tutorials/gpei_hartmann_service.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
"import numpy as np\n",
"\n",
"\n",
"def evaluate(parameters):\n",
" x = np.array([parameters.get(f\"x{i+1}\") for i in range(6)])\n",
"def evaluate(parameterization):\n",
" x = np.array([parameterization.get(f\"x{i+1}\") for i in range(6)])\n",
" # In our case, standard error is 0, since we are computing a synthetic function.\n",
" return {\"hartmann6\": (hartmann6(x), 0.0), \"l2norm\": (np.sqrt((x**2).sum()), 0.0)}"
]
Expand Down Expand Up @@ -158,9 +158,9 @@
"outputs": [],
"source": [
"for i in range(25):\n",
" parameters, trial_index = ax_client.get_next_trial()\n",
" parameterization, trial_index = ax_client.get_next_trial()\n",
" # Local evaluation here can be replaced with deployment to external system.\n",
" ax_client.complete_trial(trial_index=trial_index, raw_data=evaluate(parameters))"
" ax_client.complete_trial(trial_index=trial_index, raw_data=evaluate(parameterization))"
]
},
{
Expand Down

0 comments on commit bad2837

Please sign in to comment.