1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3512],{26919(e,t,i){i.r(t),i.d(t,{assets:()=>s,contentTitle:()=>o,default:()=>m,frontMatter:()=>a,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"recipes/tracking-metrics","title":"Adding Tracking Metrics to Your Experiment","description":"Introduction","source":"@site/versioned_docs/version-1.3.1/recipes/tracking-metrics.md","sourceDirName":"recipes","slug":"/recipes/tracking-metrics","permalink":"/docs/recipes/tracking-metrics","draft":false,"unlisted":false,"tags":[],"version":"1.3.1","lastUpdatedBy":"github-actions[bot]","lastUpdatedAt":1781025267000,"frontMatter":{},"sidebar":"tutorials","previous":{"title":"Attaching existing data to your experiment","permalink":"/docs/recipes/existing-data"},"next":{"title":"Saving and Loading an Ax Experiment to JSON","permalink":"/docs/recipes/experiment-to-json"}}');var r=i(74848),c=i(28453);const a={},o="Adding Tracking Metrics to Your Experiment",s={},d=[{value:"Introduction",id:"introduction",level:2},{value:"Setup",id:"setup",level:2},{value:"Steps",id:"steps",level:2},{value:"1. Call <code>configure_tracking_metrics</code> to add the metrics to your experiment",id:"1-call-configure_tracking_metrics-to-add-the-metrics-to-your-experiment",level:3},{value:"2. Attaching data with tracking metrics",id:"2-attaching-data-with-tracking-metrics",level:3}];function l(e){const t={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",...(0,c.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"adding-tracking-metrics-to-your-experiment",children:"Adding Tracking Metrics to Your Experiment"})}),"\n",(0,r.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)(t.p,{children:"To gain a deeper understanding of your experiment's performance, you can track\nadditional metrics beyond its primary objective(s). Ax allows you to add these\ntracking metrics to your experiment, providing valuable insights into the\nbehavior of your system."}),"\n",(0,r.jsx)(t.h2,{id:"setup",children:"Setup"}),"\n",(0,r.jsxs)(t.p,{children:["Before we begin you must instantiate the ",(0,r.jsx)(t.code,{children:"Client"})," and configure it with your\nexperiment. In this example, we will be setting our objective to a custom\nmetric."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"client = Client()\n\nclient.configure_experiment(...)\nclient.configure_optimization(objective='custom_metric')\n"})}),"\n",(0,r.jsx)(t.h2,{id:"steps",children:"Steps"}),"\n",(0,r.jsxs)(t.ol,{children:["\n",(0,r.jsxs)(t.li,{children:["Call ",(0,r.jsx)(t.code,{children:"configure_tracking_metrics"})," to add the metrics to your experiment"]}),"\n",(0,r.jsx)(t.li,{children:"Attaching data with tracking metrics"}),"\n"]}),"\n",(0,r.jsxs)(t.h3,{id:"1-call-configure_tracking_metrics-to-add-the-metrics-to-your-experiment",children:["1. Call ",(0,r.jsx)(t.code,{children:"configure_tracking_metrics"})," to add the metrics to your experiment"]}),"\n",(0,r.jsxs)(t.p,{children:["Call the ",(0,r.jsx)(t.code,{children:"configure_tracking_metrics"})," method, passing in the list of metric\nnames you would like to track."]}),"\n",(0,r.jsx)(t.p,{children:"If any of the metrics are already defined on the experiment, they will be\nskipped with a warning."}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:'# Add the tracking metrics to the experiment by name\nclient.configure_tracking_metrics(["my_tracking_metric_1", "my_tracking_metric_2"])\n'})}),"\n",(0,r.jsx)(t.h3,{id:"2-attaching-data-with-tracking-metrics",children:"2. Attaching data with tracking metrics"}),"\n",(0,r.jsxs)(t.p,{children:["To associate data with your experiment, such as when completing a specific trial\nand providing additional information, you can utilize the ",(0,r.jsx)(t.code,{children:"complete_trial"}),"\nmethod along with its ",(0,r.jsx)(t.code,{children:"raw_data"})," parameter to attach tracking metrics for that\nparticular trial."]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:'# Getting just one tri
1al in this example\ntrial_index, parameters = client.get_next_trials(max_trials=1)().popitem()\n\nclient.complete_trial(trial_index=trial_index, raw_data={"my_tracking_metric_1": ..., "my_tracking_metric_2": ...})\n'})})]})}function m(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},28453(e,t,i){i.d(t,{R:()=>a,x:()=>o});var n=i(96540);const r={},c=n.createContext(r);function a(e){const t=n.useContext(c);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),n.createElement(c.Provider,{value:t},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.