Objective Class
Optimization objective.
Optimization objective.
- Inheritance
-
azure.ai.ml.entities._mixins.RestTranslatableMixinObjective
Constructor
Objective(goal: str | None, primary_metric: str | None = None)
Parameters
Name | Description |
---|---|
goal
Required
|
Defines supported metric goals for hyperparameter tuning. Accepted values are: "minimize", "maximize". |
primary_metric
|
The name of the metric to optimize. Default value: None
|
goal
Required
|
Defines supported metric goals for hyperparameter tuning. Acceptable values are: "minimize" or "maximize". |
primary_metric
Required
|
The name of the metric to optimize. |
Examples
Assigning an objective to a SweepJob.
from azure.ai.ml.entities import CommandJob
from azure.ai.ml.sweep import BayesianSamplingAlgorithm, Objective, SweepJob, SweepJobLimits
command_job = CommandJob(
inputs=dict(kernel="linear", penalty=1.0),
compute=cpu_cluster,
environment=f"{job_env.name}:{job_env.version}",
code="./scripts",
command="python scripts/train.py --kernel $kernel --penalty $penalty",
experiment_name="sklearn-iris-flowers",
)
sweep = SweepJob(
sampling_algorithm=BayesianSamplingAlgorithm(),
trial=command_job,
search_space={"ss": Choice(type="choice", values=[{"space1": True}, {"space2": True}])},
inputs={"input1": {"file": "top_level.csv", "mode": "ro_mount"}},
compute="top_level",
limits=SweepJobLimits(trial_timeout=600),
objective=Objective(goal="maximize", primary_metric="accuracy"),
)
Współpracuj z nami w serwisie GitHub
Źródło tej zawartości można znaleźć w witrynie GitHub, gdzie można również tworzyć i przeglądać problemy i żądania ściągnięcia. Więcej informacji znajdziesz w naszym przewodniku dla współtwórców.
Azure SDK for Python