"""Base functionality for all BayBE targets."""from__future__importannotationsfromabcimportABC,abstractmethodfromtypingimportTYPE_CHECKINGimportpandasaspdfromattrsimportdefine,fieldfrombaybe.serializationimport(SerialMixin,converter,get_base_structure_hook,unstructure_base,)ifTYPE_CHECKING:frombaybe.objectiveimportSingleTargetObjective
[docs]@define(frozen=True)classTarget(ABC,SerialMixin):"""Abstract base class for all target variables. Stores information about the range, transformations, etc. """name:str=field()"""The name of the target."""
[docs]defto_objective(self)->SingleTargetObjective:"""Create a single-task objective from the target."""frombaybe.objectives.singleimportSingleTargetObjectivereturnSingleTargetObjective(self)
[docs]@abstractmethoddeftransform(self,data:pd.DataFrame)->pd.DataFrame:"""Transform data into computational representation. The transformation depends on the target mode, e.g. minimization, maximization, matching, etc. Args: data: The data to be transformed. Returns: A dataframe containing the transformed data. """
[docs]@abstractmethoddefsummary(self)->dict:"""Return a custom summarization of the target."""