yasa.EpochByEpochAgreement.get_agreement_bystage#

EpochByEpochAgreement.get_agreement_bystage(beta=1.0, zero_division=nan)[source]#

Return a pandas.DataFrame of unweighted (i.e., one-vs-rest) agreement scores.

Parameters:
betafloat

Weight of recall relative to precision in the F-score. Default is 1.0 (i.e., F1). See sklearn.metrics.precision_recall_fscore_support.

zero_division{np.nan, 0, 1, “warn”}

Value assigned to a metric whose denominator is zero, e.g. recall (and fbeta) for a stage that is absent from the reference hypnogram of a session, or precision for a stage that the observed scorer never assigned in a session. Default is np.nan, meaning that undefined scores are left missing and therefore ignored when averaging across sessions (e.g. in summary). Set to 0 to count such sessions as a score of 0% instead, or to 1 for a score of 100%. "warn" behaves like 0 but also emits a sklearn.exceptions.UndefinedMetricWarning. Applied to all metrics, including specificity and npv.

Added in version 0.8.0.

Returns:
agreementpandas.DataFrame

A DataFrame with agreement metrics as columns (fbeta, npv, precision, recall, specificity, support) and a MultiIndex with sleep stage and session as rows (only sleep stage if a single session is evaluated).

specificity (True Negative Rate) and npv (Negative Predictive Value) are computed using a one-vs-rest confusion matrix per stage.

All metrics are expressed as percentages (0-100), except support, which is the number of epochs of each stage in the reference hypnogram. A support of 0 flags the sessions where recall and fbeta are undefined.