1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6226],{28453(e,t,a){a.d(t,{R:()=>o,x:()=>s});var n=a(96540);const i={},r=n.createContext(i);function o(e){const t=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function s(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),n.createElement(r.Provider,{value:t},e.children)}},46744(e,t,a){a.r(t),a.d(t,{assets:()=>l,contentTitle:()=>s,default:()=>h,frontMatter:()=>o,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"recipes/existing-data","title":"Attaching existing data to your experiment","description":"Ax provides a straightforward way to attach custom trials to your experiment --","source":"@site/versioned_docs/version-1.1.2/recipes/existing-data.md","sourceDirName":"recipes","slug":"/recipes/existing-data","permalink":"/docs/1.1.2/recipes/existing-data","draft":false,"unlisted":false,"tags":[],"version":"1.1.2","lastUpdatedBy":"github-actions[bot]","lastUpdatedAt":1757446870000,"frontMatter":{},"sidebar":"tutorials","previous":{"title":"Manually Sampling Specific Parameterizations","permalink":"/docs/1.1.2/recipes/attach-trial"},"next":{"title":"Adding Tracking Metrics to Your Experiment","permalink":"/docs/1.1.2/recipes/tracking-metrics"}}');var i=a(74848),r=a(28453);const o={},s="Attaching existing data to your experiment",l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Prerequisites",id:"prerequisites",level:2},{value:"Setup",id:"setup",level:2},{value:"Steps",id:"steps",level:2},{value:"1. Call <code>attach_trial</code> with your custom parameterization",id:"1-call-attach_trial-with-your-custom-parameterization",level:3},{value:"2. Attach data and complete the trial as you typically would",id:"2-attach-data-and-complete-the-trial-as-you-typically-would",level:3},{value:"Learn more",id:"learn-more",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"attaching-existing-data-to-your-experiment",children:"Attaching existing data to your experiment"})}),"\n",(0,i.jsx)(t.p,{children:"Ax provides a straightforward way to attach custom trials to your experiment --\nwe can use this to attach data from trials we conducted before beginning our\nexperiment with Ax."}),"\n",(0,i.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)(t.p,{children:"It is not uncommon to have conducted some manual trials before formally\nbeginning our experiment with Ax. These could have been from some non-adaptive\nexperiment, a previous Ax experiment (though in this case it is often more\nconvenient to save and load the Ax either to a JSON file or to a database), or\nsome baseline observation for our system's status quo."}),"\n",(0,i.jsx)(t.p,{children:"When this occurs it is useful to give Ax access to these observations, both to\nprovide extra information to the surrogate model used in Bayesian optimization\nand for later analyses of these trials along with the trials generated by Ax."}),"\n",(0,i.jsxs)(t.p,{children:["In any of these cases, we can use the ",(0,i.jsx)(t.code,{children:"Client"}),"'s ",(0,i.jsx)(t.code,{children:"attach_trial"})," method to\nmanually attach a trial with a custom parameterization to our experiment."]}),"\n",(0,i.jsx)(t.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,i.jsxs)(t.p,{children:["We will assume you are familiar with ",(0,i.jsx)(t.a,{href:"/docs/1.1.2/tutorials/getting_started/",children:"basic Ax usage"}),"\nalready."]}),"\n",(0,i.jsx)(t.h2,{id:"setup",children:"Setup"}),"\n",(0,i.jsxs)(t.p,{children:["Before we begin you must instantiate the ",(0,i.jsx)(t.code,{children:"Client"})," and configure it your your\nexperiment."]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:"client = Client()\n\nclient.configure_experiment(...)\nclient.configure_optimization(...)\n"})}),"\n",(0,i.jsx)(t.h2,{id:"steps",children:"Steps"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["Call ",(0,i.jsx)(t.code,{children:"attach_trial"})," with your custom parameterization"]}),"\n",(0,i.jsx)(t.li,{children:"Attach data and complete the trial as you typically would"}),"\n"]}),"\n",(0,i.jsxs)(t.h3,{id:"1-call-attach_trial-with-your-custom-parameterization",children:["1. Call ",(0,i.jsx)(t.code,{children:"attach_trial"})," with your custom parameterization"]}),"\n",(0,i.jsxs)(t.p,{children:[(0,i.jsx)(t.code,{children:"attach_trial"})," takes two parameters: the parameters of the trial and optionally\nan arm name (here, arm is synonymous with trial). The parameters dictionary must\ncontain a value for each parameter in the experiment's search space. The arm\nname is not necessary, but it can be useful for keeping track of which arms were\nnot generated by Ax when looking at analyses. Once called ",(0,i.jsx)(t.code,{children:"attach_trial"})," will\nreturn the newly created trial's index -- we'll need this when we want to attach\ndata and complete the trial."]}),"\n",(0,i.jsx)(t.h3,{id:"2-attach-data-and-complete-the-trial-as-you-typically-would",children:"2. Attach data and complete the trial as you typically would"}),"\n",(0,i.jsxs)(t.p,{children:["Once the trial index has been generated you may evaluate the trial and tell the\nresults to Ax using ",(0,i.jsx)(t.code,{children:"complete_trial"}),"."]}),"\n",(0,i.jsx)(t.p,{children:"Steps 1 and 2 are often done together using a loop which iterates over each\nexisting trial."}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:'# For simplicity we\'ll assume the existing data is in the form of a list of tuples\n# of dictionaries, with the parameterization first and the raw data second.\nmy_data = [\n ({"x1": 0, "x2": 0, ...}, {"my_objective": 0}),\n ...\n]\n\nfor parameters, raw_data in my_data.items():\n # First attach the trial and n
1ote the trial index\n trial_index = client.attach_trial(\n parameters=parameters,\n )\n\n # Then complete the trial with the existing data\n client.complete_trial(\n trial_index=trial_index, raw_data=raw_data,\n )\n'})}),"\n",(0,i.jsx)(t.h2,{id:"learn-more",children:"Learn more"}),"\n",(0,i.jsx)(t.p,{children:"Take a look at these other recipes to continue your learning:"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"/docs/1.1.2/recipes/attach-trial",children:"Attaching a custom parameterization to your experiment"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}}}]);
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.