Skip to content

Commit ddc4e60

Browse files
paschaifacebook-github-bot
authored andcommitted
Add tracking metrics recipe (#3500)
Summary: as titled - corrections and edits are greatly appreciated! Differential Revision: D71039272
1 parent f1ee58f commit ddc4e60

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

docs/recipes/tracking-metrics.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Adding Tracking Metrics to Your Experiment
2+
## Introduction
3+
To gain a deeper understanding of your experiment's performance, you can track additional metrics beyond its primary objective. Ax allows you to add these tracking metrics to your experiment, providing valuable insights into the behavior of your system.
4+
5+
## Prerequisites
6+
Before adding tracking metrics, make sure you have an understanding of Ax [experiments](#) and their components.
7+
8+
We will also assume you are already familiar with
9+
[using Ax for ask-tell optimization](#), though this can be used for closed-loop
10+
experiments as well.
11+
12+
## Setup
13+
Before we begin you must instantiate the `Client` and configure it with your
14+
experiment.
15+
16+
```python
17+
from ax import AxClient
18+
19+
client = AxClient()
20+
21+
client.create_experiment(...)
22+
client.set_optimization_config(...)
23+
```
24+
25+
## Steps
26+
27+
1. Define the Metrics You Want to Track
28+
2. Add the Metrics to the Experiment
29+
3. Save the modifications to your experiment
30+
31+
### 1. Define the Metrics You Want to Track
32+
Construct a list of `metric_names` and, optionally, `metric_definitions` to specify the metrics you intend to track.
33+
34+
Metric Definitions are like a set of instructions or extra details you provide for each metric you want to add to an experiment. Think of it as a way to customize how each metric behaves or is calculated.
35+
36+
When you define a metric, you might want to specify things like:
37+
- What type of metric it is.
38+
- Any specific conditions or filters that should be applied to it.
39+
- Any special settings that are unique to that metric.
40+
41+
42+
```python
43+
# Define the metrics to track
44+
45+
metric_names=["tm1", tm2"],
46+
metric_definitions = {"tm1": {"properties": {"m1_opt": "m1_val"}}}
47+
```
48+
49+
### 2. Add the Metrics to the Experiment
50+
Call the `add_tracking_metrics` method, passing in the list of metrics and metric definitions.
51+
52+
```python
53+
# Add the metrics to the experiment
54+
55+
client.add_tracking_metrics(
56+
# one with a definition, one without
57+
metric_names=metric_names,
58+
metric_definitions=metric_definitions
59+
)
60+
```
61+
62+
### 3. Save the modifications to your experiment
63+
Don't forget to call `save_experiment()` to push the modifications to your experiment. It will print "True" upon success.
64+
65+
```python
66+
client.save_experiment()
67+
```
68+
69+
### Learn More
70+
For further learning, explore these additional resources:
71+
72+
* [Creating metrics in Ax](#)
73+
* [Creating optimization configurations in Ax](#)

website/sidebars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ export default {
4949
},
5050
tutorials: tutorials(),
5151
recipes: {
52-
Recipes: ['recipes/index', 'custom-trials'],
52+
Recipes: ['recipes/index', 'custom-trials', 'recipes/tracking-metrics'],
5353
},
5454
};

0 commit comments

Comments
 (0)