Comments (3)
I found a quick fix solution :
1 - at the begining of your srcipt you import the Ok class :
from ax.utils.common.result import Ok2 - In your custom metric class, for the fetch_trial_data function, you return the Ok object initialized with your Data. In my case the fetch_trial_data function looks like this now :
def fetch_trial_data(self, trial, **kwargs): records = [] for arm_name, arm in trial.arms_by_name.items(): # Extracting the result from trial metadata result = retrieve_result(trial.index, arm_name, self.result_directory) records.append({ "arm_name": arm_name, "metric_name": self.name, "mean": result, "sem": 0.0, # Standard error of the mean "trial_index": trial.index, }) data = Data(df=pd.DataFrame.from_records(records)) return Ok(data)
Good afternoon a-rouxel!
I don't know how it works but, It perfectly worked!
Thank you for your help!
Have a good day today! : )
I added
from ax.utils.common.result import Ok
and
for arm_name, arm in trial.arms_by_name.items():
in the metric function
for calling the AX functions
##Call AX functions
from ax import (
ComparisonOp,
ParameterType,
RangeParameter,
ChoiceParameter,
FixedParameter,
SearchSpace,
Experiment,
OutcomeConstraint,
OrderConstraint,
SumConstraint,
OptimizationConfig,
Objective,
Metric,
Data
)
from ax.utils.notebook.plotting import render, init_notebook_plotting
init_notebook_plotting()
from ax.utils.common.result import Ok #I added this part
for metric function,
#Create Metric
from ax import Metric
import pandas as pd
class Discrep_Metric(Metric):
def fetch_trial_data(self, trial):
records = []
for arm_name, arm in trial.arms_by_name.items():
#Call MSE calculation that is defined from global env
mse = MSE_CALCULATION()
# Record
records.append({
"arm_name": arm_name,
"metric_name": self.name,
"mean": mse, # MSE 값
"sem": 0.0,
"trial_index": trial.index,
})
data = Data(df=pd.DataFrame.from_records(records))
return Ok(data)
from ax.
I have the same issue here. In the docs, the fetch_trial_data function from the Custom metric should return a Data object, however, in the base function from the metric.py file, it is indicated that it should return a MetricFetchResult object that is defined like this : Result[Data, MetricFetchE] .... There is something wrong here but i am not sure how to fix it. I'll keep you updated if i find a good solution !
from ax.
I found a quick fix solution :
1 - at the begining of your srcipt you import the Ok class :
from ax.utils.common.result import Ok
2 - In your custom metric class, for the fetch_trial_data function, you return the Ok object initialized with your Data.
In my case the fetch_trial_data function looks like this now :
def fetch_trial_data(self, trial, **kwargs):
records = []
for arm_name, arm in trial.arms_by_name.items():
# Extracting the result from trial metadata
result = retrieve_result(trial.index, arm_name, self.result_directory)
records.append({
"arm_name": arm_name,
"metric_name": self.name,
"mean": result,
"sem": 0.0, # Standard error of the mean
"trial_index": trial.index,
})
data = Data(df=pd.DataFrame.from_records(records))
return Ok(data)
from ax.
Related Issues (20)
- Trouble with searching documentation (Algolia, API docs, etc.), for example `get_next_trials` HOT 1
- Issue when starting an AxClient with out-of-design points HOT 2
- cannot import name 'TrainingData' HOT 2
- applying complex constrains HOT 2
- Ax is not not starting as many workers as I'd like to; sometimes, get_next_trials returns 0 new trials HOT 4
- Evaluating custom candidates HOT 2
- Input Feature Selection - Does the relevant code exist? HOT 6
- [Feature Request] support constraints on `ChoiceParameters` HOT 4
- Extending Models.THOMPSON with an extra parameter HOT 1
- There are some questions when i use the Ax HOT 7
- Space characters in the objective name AND specifying a threshold leads to an error message: "AssertionError: Outcome constraint should be of form `metric_name >= x" HOT 1
- Pandas deprecation warning when deserializing AxClient JSON HOT 2
- AX seems to get stuck with Ray
- `StandardizeY` transform requires non-empty data." when using SAASBO
- Plotting outside of a notebook HOT 1
- Setting search space step size in Ax Service API HOT 10
- Problem when Sobol falls back to HitAndRunPolytopeSampler HOT 3
- Arms from previous batch keep appearing in new batches HOT 5
- EHVI & NEHVI break with more than 7 objectives HOT 4
- Multi-objective experiments generate duplicated data HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ax.