eval_average_precision(label, score)

Calculate Average Precision score for binary classification.

Parameters:
  • label (Tensor) –

    Ground truth binary labels in shape of (N,) 1 represents outliers, 0 represents normal instances

  • score (Tensor) –

    Predicted outlier scores in shape of (N,)

Returns:
  • float

    Average Precision score

Notes

Processing Steps:

  • Convert tensors to numpy arrays
  • Calculate average precision using scikit-learn
  • Handle binary classification scenario

Features:

  • CPU computation
  • Outlier detection focus
  • Balanced metric
eval_macro_f1(label, pred)

Calculate Macro-F1 score for multi-class classification.

Parameters:
  • label (Tensor) –

    Ground truth labels in shape of (N,)

  • pred (Tensor) –

    Predicted class labels in shape of (N,)

Returns:
  • float

    Macro-averaged F1 score

Notes

Processing Steps:

  • Convert tensors to numpy arrays
  • Calculate macro-averaged F1 score
  • Handle multi-class scenario

Features:

  • CPU computation
  • Class-weighted averaging
  • Multi-class support
eval_micro_f1(label, pred)

Calculate Micro-F1 score for multi-class classification.

Parameters:
  • label (Tensor) –

    Ground truth labels in shape of (N,)

  • pred (Tensor) –

    Predicted class labels in shape of (N,)

Returns:
  • float

    Micro-averaged F1 score

Notes

Processing Steps:

  • Convert tensors to numpy arrays
  • Calculate micro-averaged F1 score
  • Handle multi-class scenario

Features:

  • CPU computation
  • Instance-weighted averaging
  • Multi-class support
eval_precision_at_k(label, score, k=None)

Calculate Precision@K metric for top-k predictions.

Parameters:
  • label (Tensor) –

    Ground truth binary labels in shape of (N,)

  • score (Tensor) –

    Predicted scores/probabilities in shape of (N,)

  • k (int, default: None ) –

    Number of top instances to consider If None, uses number of positive labels

Returns:
  • float

    Precision score for top-k predictions

Notes

Processing Steps:

  • Determine k value (if not provided)
  • Get top-k scoring instances
  • Calculate precision as (true positives) / k

Features:

  • Flexible k selection
  • Efficient top-k computation
  • Normalized metric
eval_recall_at_k(label, score, k=None)

Calculate Recall@K metric for top-k predictions.

Parameters:
  • label (Tensor) –

    Ground truth binary labels in shape of (N,)

  • score (Tensor) –

    Predicted scores/probabilities in shape of (N,)

  • k (int, default: None ) –

    Number of top instances to consider If None, uses number of positive labels

Returns:
  • float

    Recall score for top-k predictions

Notes

Processing Steps:

  • Determine k value (if not provided)
  • Get top-k scoring instances
  • Calculate recall as (true positives) / (total positives)

Features:

  • Flexible k selection
  • Efficient top-k computation
  • Normalized metric
eval_roc_auc(label, score)

Calculate ROC-AUC score for binary classification.

Parameters:
  • label (Tensor) –

    Ground truth binary labels in shape of (N,)

  • score (Tensor) –

    Predicted scores/probabilities in shape of (N,)

Returns:
  • float

    ROC-AUC score, adjusted to be in [0.5, 1.0] range

Notes

Processing Steps:

  • Convert tensors to numpy arrays
  • Calculate standard ROC-AUC
  • Adjust scores < 0.5 to their complement

Features:

  • CPU computation
  • Score normalization
  • Binary classification focus