mixle.utils.metrics module

Functions for classification evaluation. Create ROC curves and search depth rankings.

classify(data, model, labels=None)[source]

Classification of sequence of iid observation from model predictions. Labels may be provided.

Returns :param data: Sequence of iid observations for classification. :type data: Sequence[T] :param model: Distribution for classification. :type model: SequenceEncodableProbabilityDistribution :param labels: List of labels for the data. :type labels: Optional[List[T]]

Returns:

Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

Parameters:
  • data (Sequence[T])

  • model (SequenceEncodableProbabilityDistribution)

  • labels (list[T] | None)

roc_curve(pos_x, neg_x)[source]

Create ROC curve.

Parameters:
  • pos_x (Union[List[float], np.ndarray]) – Probs for positive classifications.

  • neg_x (Union[List[float], np.ndarray]) – Probs for negative classifications.

Returns:

Tuple of true-positive rate and false-positive rate arrays.

Return type:

tuple[ndarray, ndarray]

auc(x, y)[source]

Trapezoidal area under a curve.

Parameters:
  • x (list[float] | ndarray) – X-axis coordinates, such as false-positive rates.

  • y (list[float] | ndarray) – Y-axis coordinates, such as true-positive rates.

Returns:

Non-negative trapezoidal area after sorting by x.

Return type:

float

roc_auc(pos_x, neg_x)[source]

Area under the ROC curve for positive and negative scores.

Parameters:
Return type:

float

roc_percentiles(pos_x, neg_x, perc_points)[source]
Parameters:
Return type:

ndarray

ranking_depth(x, k=None, comp_func=lambda a, b: ...)[source]