This module provides functions for encoding target labels and metrcics-toolbox- specific utilities.
The toolbox expects 2D arrays for all classification tasks, including binary classification. However, sklearn's label_binarize returns a 1D array for binary classification. This module includes a fix to ensure consistent 2D output shape.
toolbox_binarize_labels(y, classes)
Binarize target labels.
Uses sklearn's label_binarize under the hood, with a fix for binary case. Sklearn's label_binarize returns (N, 1) shape for binary classification, while the toolbox expects always 2D arrays, to align metrics compute methods to work consistently for binary, multi-class and regression tasks.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in metrics_toolbox/encoding.py
toolbox_binarize_probs(y_pred)
Binarize predicted probabilities for binary classification.
Ensures that predicted probabilities are in 2D array format. If input is 1D, converts it to 2D with two columns: [false, true], aligning with sklearn's convention. Already 2D inputs are returned unchanged.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in metrics_toolbox/encoding.py
toolbox_widen_series(y)
Widen regression targets to 2D array format.
Converts 1D regression target arrays to 2D format with a single column, ensuring consistency across all metric computations in the toolbox.
| Parameters: |
|
|---|
| Returns: |
|
|---|