Module streamauc.utils
Functions
def auc(vals_x: numpy.ndarray, vals_y: numpy.ndarray) ‑> Union[numpy.ndarray, float]-
Compute the approximate area under the curve.
This is a weak wrapper around np.trapz, ensuring that the integral is always positive, i.e. making it ignore the sorting order of the input numpy array.
Parameters
vals_x:np.ndarray- Must be squeezable to shape (-1,) or (-1, n_classes).
vals_y:np.ndarray- Must be squeezable to shape (-1,) or (-1, n_classes).
Returns
Union[np.ndarray, float]- Approximate AUC value. Either single float or np.ndarray of shape (vals_x.shape[1],).
def check_confusion_matrix_entries(*args)-
Validate that input confusion matrix arrays are 2D, have the same shape, and are non-negative.
Parameters:
*args : np.ndarray Variable number of input arrays representing confusion matrix entries.
Raises:
AssertionError If input arrays are not 2D, do not have the same shape, or contain negative values.
def copy_docstring_from(source)-
Decorator to copy the docstring from one function to another.
Parameters
source:function- The function from which to copy the docstring.
Returns
function- The decorated function with the copied docstring.
def onehot_encode(int_masks: numpy.ndarray, num_classes: int) ‑> numpy.ndarray-
Convert integer masks to one-hot encoded masks. Optimized methods that does not explode in memory for larger input arrays.
Parameters
int_masks:np.ndarray- An array of integer class labels. Each element in the array is an integer representing a class label.
num_classes:int- The number of distinct classes. This will determine the depth of the one-hot encoded dimension.
Returns
np.ndarray- A one-hot encoded array with shape (n, num_classes), where n is
the number of
elements in
int_masks. Each row in the output corresponds to a one-hot encoded version of the respective element inint_masks.
Classes
class AggregationMethod (value, names=None, *, module=None, qualname=None, type=None, start=1)-
Enumeration for specifying the method of aggregating metrics in multi-class classification.
Attributes:
MICRO : str Micro-averaging method, which aggregates contributions from all classes to compute the average metric. MACRO : str Macro-averaging method, which computes the metric independently for each class and then takes the average. ONE_VS_ALL : str One-vs-all method, which treats (subsequently) each class as the positive class and all others as negative, computing metrics for each class in this manner.
Expand source code
class AggregationMethod(Enum): """ Enumeration for specifying the method of aggregating metrics in multi-class classification. Attributes: ---------- MICRO : str Micro-averaging method, which aggregates contributions from all classes to compute the average metric. MACRO : str Macro-averaging method, which computes the metric independently for each class and then takes the average. ONE_VS_ALL : str One-vs-all method, which treats (subsequently) each class as the positive class and all others as negative, computing metrics for each class in this manner. """ MICRO = "MICRO" MACRO = "MACRO" ONE_VS_ALL = "ONE_VS_ALL"Ancestors
- enum.Enum
Class variables
var MACROvar MICROvar ONE_VS_ALL