Source code for ax.modelbridge.transforms.inverse_gaussian_cdf_y
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import List, Optional, TYPE_CHECKING
from ax.core.observation import ObservationData, ObservationFeatures
from ax.core.search_space import SearchSpace
from ax.modelbridge.transforms.base import Transform
from ax.modelbridge.transforms.utils import match_ci_width_truncated
from ax.models.types import TConfig
from ax.utils.common.logger import get_logger
from scipy.stats import norm
if TYPE_CHECKING:
# import as module to make sphinx-autodoc-typehints happy
from ax.modelbridge import base as base_modelbridge # noqa F401 # pragma: no cover
logger = get_logger(__name__)
# TODO(jej): Add OptimizationConfig validation - can't transform outcome constraints.
[docs]class InverseGaussianCdfY(Transform):
"""Apply inverse CDF transform to Y.
This means that we model uniform distributions as gaussian-distributed.
"""
def __init__(
self,
search_space: SearchSpace,
observation_features: List[ObservationFeatures],
observation_data: List[ObservationData],
modelbridge: Optional["base_modelbridge.ModelBridge"] = None,
config: Optional[TConfig] = None,
) -> None:
self.dist = norm(loc=0, scale=1)
def _map(self, val: float) -> float:
mapped_val = self.dist.ppf(val)
return mapped_val