Source code for sorbetto.flavor.worst_flavor

from typing import Any

import numpy as np

from sorbetto.core.entity import Entity
from sorbetto.core.importance import Importance
from sorbetto.flavor.abstract_numeric_flavor import AbstractNumericFlavor
from sorbetto.performance.finite_set_of_two_class_classification_performances import (
    FiniteSetOfTwoClassClassificationPerformances,
)
from sorbetto.ranking.ranking_score import RankingScore


[docs] class WorstFlavor(AbstractNumericFlavor): """ TODO actual description Example of Worst Flavor: the Baseline Flavor. """ def __init__( self, performances: FiniteSetOfTwoClassClassificationPerformances, entity_list: list[Entity], name: str = "Unnamed Baseline Flavor", colormap: Any = None, ): super().__init__(name=name, colormap=colormap) self._entity_list = entity_list self._nb_entities = len(entity_list) self._performances = performances @property def entity_list(self) -> list[Entity]: return self._entity_list @property def nb_entities(self) -> int: return self._nb_entities @property def performances(self) -> FiniteSetOfTwoClassClassificationPerformances: return self._performances def __call__( self, importance: Importance | np.ndarray, ) -> float | np.ndarray: values = RankingScore._compute( importance=importance, performance=self._performances ) return np.min(values, axis=0)
[docs] def getDefaultColormap(self): return "gray"
[docs] def getLowerBound(self): return 0.0
[docs] def getUpperBound(self): return 1.0