results¶
- class BaseResult¶
Bases:
objectBase class for classification results.
- f1_score(on)¶
Calculate the F1 score for the given data.
- Parameters:
on (
Literal['timestamp','annotation','prediction']) –The level on which to calculate the F1 scores.
"timestamp": Calculate the F1 scores across all samples (timestamps)."annotation": Calculate the F1 scores based on the annotated intervals."prediction": Calculate the F1 scores based on the predicted intervals.
- Return type:
- remove_overlapping_predictions(*, priority_function, prefilter_recipient_bouts, max_bout_gap, max_allowed_bout_overlap)¶
Remove overlapping predictions from the classification result.
This method is implemented by subclasses if applicable.
- Parameters:
priority_function (
Callable[[DataFrame],Iterable[float]]) – A function that assigns a priority to each prediction.prefilter_recipient_bouts (
bool) – Whether to prefilter recipient bouts.max_bout_gap (
float) – The maximum allowed gap between predictions.max_allowed_bout_overlap (
float) – The maximum allowed overlap between predictions.
- Return type:
Self
- score()¶
Return a summary of the F1 scores for each category at different levels.
- Return type:
- Returns:
A DataFrame containing the F1 scores for each category at different levels.
See also
- class ClassificationResult(categories, timestamps, y_proba, y_pred_numeric, _y_proba_smoothed=None, _predictions=None, _annotations=None, _y_true_numeric=None)¶
Bases:
BaseResult- Parameters:
- property annotations: DataFrame¶
Annotated intervals.
- Raises:
ValueError – If the result is not annotated.
- classmethod from_h5(data_file, data_path)¶
Load classification results from an HDF5 file.
- Parameters:
- Return type:
- property predictions: DataFrame¶
Predicted intervals.
- Raises:
ValueError – If the result is not thresholded.
- smooth(smoothing_func, *, threshold=True, decision_thresholds=None, default_decision='none')¶
Apply smoothing functions to the classification result.
- Parameters:
smoothing_func (
SmoothingFunction) – The smoothing function to apply.threshold (
bool, default:True) – Whether to threshold the result.decision_thresholds (
Iterable[float] |None, default:None) – The decision thresholds to use.default_decision (
int|str, default:'none') – The default decision to use.
- Return type:
- Returns:
The smoothed classification result.
- threshold(decision_thresholds=None, *, default_decision='none')¶
Apply decision thresholds to the classification result.
- to_h5(data_file, data_path)¶
Save the classification results to an HDF5 file.
- property y_proba_smoothed¶
Smoothed classification probabilities.
- property y_true_numeric¶
True labels, represented as integers.
- Raises:
ValueError – If the result is not annotated.
- class DatasetClassificationResult(classification_results, target)¶
Bases:
_NestedResult- Parameters:
classification_results (dict[str | int, GroupClassificationResult])
target (Literal['individual', 'dyad'])
-
classification_results:
dict[str|int,GroupClassificationResult]¶
- classmethod combine(results)¶
Combine multiple dataset classification results into a single result.
- Parameters:
results (
Iterable[DatasetClassificationResult]) – The dataset classification results to combine.- Return type:
- Returns:
A new
DatasetClassificationResultwith the combined results.
- classmethod from_h5(data_file, *, dataset_name)¶
Load the dataset classification result from an HDF5 file.
- Parameters:
- Return type:
- Returns:
The loaded dataset classification result.
- to_dataset(*, trajectories, background_category)¶
Convert the classification results to an annotated dataset.
- Parameters:
- Return type:
- Returns:
Annotated dataset.
- class GroupClassificationResult(classification_results, target, individuals)¶
Bases:
_NestedResult- Parameters:
- classmethod combine(results)¶
Combine multiple
GroupClassificationResultinto a single one.- Parameters:
results (
Iterable[GroupClassificationResult]) – Iterable ofGroupClassificationResultto combine.- Return type:
- Returns:
A new
GroupClassificationResultobject containing the combined results.
- classmethod from_h5(data_file, data_path)¶
Load a
GroupClassificationResultfrom a HDF5 file.- Parameters:
- Return type:
- Returns:
The loaded group classification result.