src.plots#

Module Contents#

Classes#

Plotter

Helper class that provides a standard way to create an ABC using

Attributes#

K

V

src.plots.K#
src.plots.V#
class src.plots.Plotter(**data: Any)#

Bases: pydantic.BaseModel, abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

max_alpha: float#
default_alpha: float#
min_boots_in_one_tail: int#
metric: Callable[[numpy.typing.NDArray[numpy.float32], numpy.typing.NDArray[numpy.float32]], float]#
_initial_alpha: float#
_min_n_boots: int#
_n_boots: int#
_alpha: float#
validate_alphas(v: dict[str, float]) dict[str, float]#

Validate the alphas when initiate the Plotter object.

Parameters:

v (dict[str, float]) – a dictionary includes default_alpha and max_alpha, and their values

Raises:
  • ValueError – if default_alpha is grater than 0.5

  • ValueError – if default_alpha is not in between 0 and max_alpha

Returns:

a dictionary includes validated default_alpha and max_alpha, and their values

Return type:

dict[str, float]

preprocess_inputs(results: pandas.DataFrame) pandas.DataFrame#

Drop the row as long as it contain NA value.

Parameters:

results (DataFrame) – input dataframe

Returns:

output dataframe

Return type:

DataFrame

__call__(predictions: dict[K, V], labels: dict[K, V])#
static combine_inputs(labels: dict[K, V], predictions: dict[K, V]) pandas.DataFrame#

Combine input labels and input predictions, and return it as dataframe.

Parameters:
  • labels (dict[K, V]) – input dictionary of labels

  • predictions (dict[K, V]) – input dictionary of predictions

Returns:

the combined dataframe of input labels and input predictions

Return type:

DataFrame

_one_boot(y_true: numpy.typing.NDArray[numpy.float32], y_pred: numpy.typing.NDArray[numpy.float32]) tuple[numpy.typing.NDArray[numpy.float32], numpy.typing.NDArray[numpy.float32]]#

Usage: (t, p) = one_boot(true, pred) with true, pred, t, p arrays of same length

_boot_generator(y_true: numpy.typing.NDArray[Any], y_pred: numpy.typing.NDArray[Any])#
_min_n_boots_from(alpha: float) int#
_min_alpha_from(n_boots: int) float#
metric_boot_histogram(y_true, y_pred)#

Plot histogram with lines for 1 observed metric and its confidence interval.

Parameters:
  • y_true (ndarray) – True labels.

  • y_pred (ndarray) – The predictions.