class_docstr: A base class for model based early stopping strategies. Includes
  a helper function for processing MapData into arrays.
docstr: A ModelBasedEarlyStoppingStrategy class.
  
  Args:
      metric_names: The names of the metrics the strategy will interact with.
          If no metric names are provided the objective metric is assumed.
      seconds_between_polls: How often to poll the early stopping metric to
          evaluate whether or not the trial should be early stopped.
      min_progression: Only stop trials if the latest progression value
          (e.g. timestamp, epochs, training data used) is greater than this
          threshold. Prevents stopping prematurely before enough data is gathered
          to make a decision.
      max_progression: Do not stop trials that have passed `max_progression`.
          Useful if we prefer finishing a trial that are already near completion.
      min_curves: Trials will not be stopped until a number of trials
          `min_curves` have completed with curve data attached. That is, if
          `min_curves` trials are completed but their curve data was not
          successfully retrieved, further trials may not be early-stopped.
      trial_indices_to_ignore: Trial indices that should not be early stopped.
      true_objective_metric_name: The actual objective to be optimized; used in
          situations where early stopping uses a proxy objective (such as training
          loss instead of eval loss) for stopping decisions.
      normalize_progressions: Normalizes the progression column of the MapData df
          by dividing by the max. If the values were originally in [0, `prog_max`]
          (as we would expect), the transformed values will be in [0, 1]. Useful
          for inferring the max progression and allows `min_progression` to be
          specified in the transformed space. IMPORTANT: Typically, `min_curves`
          should be > 0 to ensure that at least one trial has completed and that
          we have a reliable approximation for `prog_max`.
      min_progression_modeling: If set, this will exclude progressions that are
          below this threshold from being used or modeling. Useful when early data
          is not reliable or excessively noisy.
docstr_tok: ["A","ModelBasedEarlyStoppingStrategy","class",".","Args",":","metric_names",":","The","names","of","the","metrics","the","strategy","will","interact","with",".","If","no","metric","names","are","provided","the","objective","metric","is","assumed",".","seconds_between_polls",":","How","often","to","poll","the","early","stopping","metric","to","evaluate","whether","or","not","the","trial","should","be","early","stopped",".","min_progression",":","Only","stop","trials","if","the","latest","progression","value","(","e.g",".","timestamp",",","epochs",",","training","data","used",")","is","greater","than","this","threshold",".","Prevents","stopping","prematurely","before","enough","data","is","gathered","to","make","a","decision",".","max_progression",":","Do","not","stop","trials","that","have","passed","`","max_progression","`",".","Useful","if","we","prefer","finishing","a","trial","that","are","already","near","completion",".","min_curves",":","Trials","will","not","be","stopped","until","a","number","of","trials","`","min_curves","`","have","completed","with","curve","data","attached",".","That","is",",","if","`","min_curves","`","trials","are","completed","but","their","curve","data","was","not","successfully","retrieved",",","further","trials","may","not","be","early-stopped",".","trial_indices_to_ignore",":","Trial","indices","that","should","not","be","early","stopped",".","true_objective_metric_name",":","The","actual","objective","to","be","optimized",";","used","in","situations","where","early","stopping","uses","a","proxy","objective","(","such","as","training","loss","instead","of","eval","loss",")","for","stopping","decisions",".","normalize_progressions",":","Normalizes","the","progression","column","of","the","MapData","df","by","dividing","by","the","max",".","If","the","values","were","originally","in","[","0",",","`","prog_max","`","]","(","as","we","would","expect",")",",","the","transformed","values","will","be","in","[","0",",","1","]",".","Useful","for","inferring","the","max","progression","and","allows","`","min_progression","`","to","be","specified","in","the","transformed","space",".","IMPORTANT",":","Typically",",","`","min_curves","`","should","be",">","0","to","ensure","that","at","least","one","trial","has","completed","and","that","we","have","a","reliable","approximation","for","`","prog_max","`",".","min_progression_modeling",":","If","set",",","this","will","exclude","progressions","that","are","below","this","threshold","from","being","used","or","modeling",".","Useful","when","early","data","is","not","reliable","or","excessively","noisy","."]
code: def __init__(
      self,
      metric_names: Optional[Iterable[str]] = None,
      seconds_between_polls: int = 300,
      min_progression: Optional[float] = None,
      max_progression: Optional[float] = None,
      min_curves: Optional[int] = None,
      trial_indices_to_ignore: Optional[List[int]] = None,
      true_objective_metric_name: Optional[str] = None,
      normalize_progressions: bool = False,
      min_progression_modeling: Optional[float] = None,
  ) -> None:
      """A ModelBasedEarlyStoppingStrategy class.
  
      Args:
          metric_names: The names of the metrics the strategy will interact with.
              If no metric names are provided the objective metric is assumed.
          seconds_between_polls: How often to poll the early stopping metric to
              evaluate whether or not the trial should be early stopped.
          min_progression: Only stop trials if the latest progression value
              (e.g. timestamp, epochs, training data used) is greater than this
              threshold. Prevents stopping prematurely before enough data is gathered
              to make a decision.
          max_progression: Do not stop trials that have passed `max_progression`.
              Useful if we prefer finishing a trial that are already near completion.
          min_curves: Trials will not be stopped until a number of trials
              `min_curves` have completed with curve data attached. That is, if
              `min_curves` trials are completed but their curve data was not
              successfully retrieved, further trials may not be early-stopped.
          trial_indices_to_ignore: Trial indices that should not be early stopped.
          true_objective_metric_name: The actual objective to be optimized; used in
              situations where early stopping uses a proxy objective (such as training
              loss instead of eval loss) for stopping decisions.
          normalize_progressions: Normalizes the progression column of the MapData df
              by dividing by the max. If the values were originally in [0, `prog_max`]
              (as we would expect), the transformed values will be in [0, 1]. Useful
              for inferring the max progression and allows `min_progression` to be
              specified in the transformed space. IMPORTANT: Typically, `min_curves`
              should be > 0 to ensure that at least one trial has completed and that
              we have a reliable approximation for `prog_max`.
          min_progression_modeling: If set, this will exclude progressions that are
              below this threshold from being used or modeling. Useful when early data
              is not reliable or excessively noisy.
      """
      super().__init__(
          metric_names=metric_names,
          seconds_between_polls=seconds_between_polls,
          min_progression=min_progression,
          max_progression=max_progression,
          min_curves=min_curves,
          trial_indices_to_ignore=trial_indices_to_ignore,
          true_objective_metric_name=true_objective_metric_name,
          normalize_progressions=normalize_progressions,
      )
      self.min_progression_modeling = min_progression_modeling
  
imports: import logging
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from logging import Logger
  from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type
  import numpy
  import pandas
  from ax.core.base_trial import TrialStatus
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.map_data import MapData
  from ax.core.objective import MultiObjective
  from ax.modelbridge.map_torch import MapTorchModelBridge
  from ax.modelbridge.modelbridge_utils import _unpack_observations, observation_data_to_array, observation_features_to_array
  from ax.modelbridge.registry import Cont_X_trans, Y_trans
  from ax.modelbridge.transforms.base import Transform
  from ax.modelbridge.transforms.map_unit_x import MapUnitX
  from ax.models.torch_base import TorchModel
  from ax.utils.common.base import Base
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast, not_none
label_desc: Use image node_id 1 to create a new ModelBasedEarlyStoppingStrategy object from inherited base classes: BaseEarlyStoppingStrategy with example: obj = ModelBasedEarlyStoppingStrategy(metric_names, seconds_between_polls, min_progression, max_progression, min_curves, trial_indices_to_ignore, true_objective_metric_name, normalize_progressions, min_progression_modeling)