Skip to content

Commit

Permalink
remove unused metrics (facebook#2728)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#2728

These may have once been used for benchmarking, but no longer are (not even in tests). Also, if these were to become needed again, it should be possible to define one metric based on BoTorch test functions that covers most of these, so we don't need so many classes that need their own registry entries.

Also removed Sphinx headings for metrics files that aren't in Ax.

* Removed Sphinx headings for BoTorch Test Problem and Dictionary Lookup, which don't exist anymore
* Removed Hartmann6Metric, JenattonMetric, AugmentedBraninMetric, AugmentedhartmannMetric
* Removed functionality from stubs that wasn't being used

Differential Revision: D61998254
  • Loading branch information
esantorella authored and facebook-github-bot committed Aug 30, 2024
1 parent ca907cb commit 1e20d51
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 138 deletions.
57 changes: 0 additions & 57 deletions ax/metrics/botorch_test_problem.py

This file was deleted.

10 changes: 2 additions & 8 deletions ax/storage/json_store/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
OrEarlyStoppingStrategy,
)
from ax.global_stopping.strategies.improvement import ImprovementGlobalStoppingStrategy
from ax.metrics.branin import AugmentedBraninMetric, BraninMetric, NegativeBraninMetric
from ax.metrics.branin import BraninMetric, NegativeBraninMetric
from ax.metrics.branin_map import BraninTimestampMapMetric
from ax.metrics.chemistry import ChemistryMetric, ChemistryProblemType
from ax.metrics.factorial import FactorialMetric
from ax.metrics.hartmann6 import AugmentedHartmann6Metric, Hartmann6Metric
from ax.metrics.hartmann6 import Hartmann6Metric
from ax.metrics.l2norm import L2NormMetric
from ax.metrics.noisy_function import NoisyFunctionMetric
from ax.metrics.sklearn import SklearnDataset, SklearnMetric, SklearnModelType
Expand Down Expand Up @@ -178,8 +178,6 @@
Arm: arm_to_dict,
AuxiliaryExperiment: auxiliary_experiment_to_dict,
AndEarlyStoppingStrategy: logical_early_stopping_strategy_to_dict,
AugmentedBraninMetric: metric_to_dict,
AugmentedHartmann6Metric: metric_to_dict,
AutoTransitionAfterGen: transition_criterion_to_dict,
BatchTrial: batch_to_dict,
BenchmarkMetric: metric_to_dict,
Expand Down Expand Up @@ -281,8 +279,6 @@
CORE_DECODER_REGISTRY: TDecoderRegistry = {
"AbandonedArm": AbandonedArm,
"AndEarlyStoppingStrategy": AndEarlyStoppingStrategy,
"AugmentedBraninMetric": AugmentedBraninMetric,
"AugmentedHartmann6Metric": AugmentedHartmann6Metric,
"AutoTransitionAfterGen": AutoTransitionAfterGen,
"AuxiliaryExperiment": AuxiliaryExperiment,
"Arm": Arm,
Expand All @@ -293,7 +289,6 @@
"BenchmarkProblem": BenchmarkProblem,
"BenchmarkResult": BenchmarkResult,
"BoTorchModel": BoTorchModel,
"BotorchTestProblemMetric": BenchmarkMetric, # backward-compatibility
"BotorchTestProblemRunner": BotorchTestProblemRunner,
"BraninMetric": BraninMetric,
"BraninTimestampMapMetric": BraninTimestampMapMetric,
Expand All @@ -314,7 +309,6 @@
"GenerationStep": GenerationStep,
"GeneratorRun": GeneratorRun,
"GeneratorRunStruct": GeneratorRunStruct,
"Hartmann6Metric": Hartmann6Metric,
"HierarchicalSearchSpace": HierarchicalSearchSpace,
"ImprovementGlobalStoppingStrategy": ImprovementGlobalStoppingStrategy,
"Interval": Interval,
Expand Down
4 changes: 0 additions & 4 deletions ax/storage/json_store/tests/test_json_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
get_acquisition_type,
get_and_early_stopping_strategy,
get_arm,
get_augmented_branin_metric,
get_augmented_hartmann_metric,
get_auxiliary_experiment,
get_batch_trial,
get_botorch_model,
Expand Down Expand Up @@ -142,8 +140,6 @@
("AggregatedBenchmarkResult", get_aggregated_benchmark_result),
("AndEarlyStoppingStrategy", get_and_early_stopping_strategy),
("Arm", get_arm),
("AugmentedBraninMetric", get_augmented_branin_metric),
("AugmentedHartmannMetric", get_augmented_hartmann_metric),
("AuxiliaryExperiment", get_auxiliary_experiment),
("BatchTrial", get_batch_trial),
("BenchmarkMethod", get_sobol_gpei_benchmark_method),
Expand Down
45 changes: 1 addition & 44 deletions ax/utils/testing/core_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@
from ax.exceptions.core import UserInputError
from ax.global_stopping.strategies.base import BaseGlobalStoppingStrategy
from ax.global_stopping.strategies.improvement import ImprovementGlobalStoppingStrategy
from ax.metrics.branin import AugmentedBraninMetric, BraninMetric
from ax.metrics.branin import BraninMetric
from ax.metrics.branin_map import BraninTimestampMapMetric
from ax.metrics.factorial import FactorialMetric
from ax.metrics.hartmann6 import AugmentedHartmann6Metric, Hartmann6Metric
from ax.modelbridge.factory import Cont_X_trans, get_factorial, get_sobol, Models
from ax.modelbridge.generation_strategy import GenerationNode, GenerationStrategy
from ax.modelbridge.model_spec import ModelSpec
Expand Down Expand Up @@ -1494,24 +1493,6 @@ def get_branin_metric(
)


def get_augmented_branin_metric(name: str = "aug_branin") -> AugmentedBraninMetric:
param_names = ["x1", "x2", "fidelity"]
return AugmentedBraninMetric(name=name, param_names=param_names, noise_sd=0.01)


def get_hartmann_metric(name: str = "hartmann") -> Hartmann6Metric:
param_names = [f"x{idx + 1}" for idx in range(6)]
return Hartmann6Metric(name=name, param_names=param_names, noise_sd=0.01)


def get_augmented_hartmann_metric(
name: str = "aug_hartmann",
) -> AugmentedHartmann6Metric:
param_names = [f"x{idx + 1}" for idx in range(6)]
param_names.append("fidelity")
return AugmentedHartmann6Metric(name=name, param_names=param_names, noise_sd=0.01)


def get_factorial_metric(name: str = "success_metric") -> FactorialMetric:
coefficients: dict[str, dict[TParamValue, float]] = {
"factor1": {"level11": 0.1, "level12": 0.2, "level13": 0.3},
Expand Down Expand Up @@ -1635,18 +1616,6 @@ def get_branin_multi_objective(num_objectives: int = 2) -> MultiObjective:
return MultiObjective(objectives=objectives)


def get_augmented_branin_objective() -> Objective:
return Objective(metric=get_augmented_branin_metric(), minimize=False)


def get_hartmann_objective() -> Objective:
return Objective(metric=get_hartmann_metric(), minimize=False)


def get_augmented_hartmann_objective() -> Objective:
return Objective(metric=get_augmented_hartmann_metric(), minimize=False)


##############################
# Optimization Configs
##############################
Expand Down Expand Up @@ -1745,18 +1714,6 @@ def get_branin_multi_objective_optimization_config(
)


def get_augmented_branin_optimization_config() -> OptimizationConfig:
return OptimizationConfig(objective=get_augmented_branin_objective())


def get_hartmann_optimization_config() -> OptimizationConfig:
return OptimizationConfig(objective=get_hartmann_objective())


def get_augmented_hartmann_optimization_config() -> OptimizationConfig:
return OptimizationConfig(objective=get_augmented_hartmann_objective())


##############################
# Arms
##############################
Expand Down
25 changes: 0 additions & 25 deletions sphinx/source/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ ax.metrics
.. currentmodule:: ax.metrics


BoTorch Test Problem
~~~~~~~~~~~~~~~~~~~~

.. automodule:: ax.metrics.botorch_test_problem
:members:
:undoc-members:
:show-inheritance:

Branin
~~~~~~

Expand Down Expand Up @@ -48,14 +40,6 @@ Curve
:undoc-members:
:show-inheritance:

Dictionary Lookup
~~~~~~~~~~~~~~~~~

.. automodule:: ax.metrics.dict_lookup
:members:
:undoc-members:
:show-inheritance:

Factorial
~~~~~~~~~

Expand All @@ -72,15 +56,6 @@ Hartmann6
:undoc-members:
:show-inheritance:

Jenatton
~~~~~~~~

.. automodule:: ax.metrics.jenatton
:members:
:undoc-members:
:show-inheritance:


L2 Norm
~~~~~~~

Expand Down

0 comments on commit 1e20d51

Please sign in to comment.