mlquantify.utils package#
Submodules#
mlquantify.utils.prevalence module#
- mlquantify.utils.prevalence.get_prev_from_labels(y, format='dict', classes: list | None = None)[source]#
Get the real prevalence of each class in the target array.
- Parameters:
- ynp.ndarray or pd.Series
Array of class labels.
- formatstr, default=”dict”
Format of the output. Can be “array” or “dict”.
- classeslist, optional
List of unique classes. If provided, the output will be sorted by these classes.
- Returns:
- dict or np.ndarray
Dictionary of class labels and their corresponding prevalence or array of prevalences.
- mlquantify.utils.prevalence.normalize_prevalence(prevalences: ndarray, classes: list)[source]#
Normalize the prevalence of each class to sum to 1.
- Parameters:
- prevalencesnp.ndarray
Array of prevalences.
- classeslist
List of unique classes.
- Returns:
- dict
Dictionary of class labels and their corresponding prevalence.