coco_pipe.decoding.run_statistical_assessment#
- coco_pipe.decoding.run_statistical_assessment(observed_result, experiment_config, X, y, groups, sample_ids, sample_metadata, feature_names, time_axis, observation_level, inferential_unit, sample_weight=None)#
Orchestrate the statistical assessment of experiment results.
Resolves the chosen statistical method (binomial, permutation or sign flip) and dispatches analysis for each model and metric.
Scientific Rationale#
Statistical significance in decoding is often non-trivial due to temporal autocorrelations and multiple comparisons. This orchestrator handles analytical binomial tests (fast, theoretical chance), full-pipeline permutation tests (rigorous, empirical null; labels permuted between units, within strata, or between blocks within strata, as
chance.permutation_schemesets) and group-level sign-flip tests of leave-one-group-out fold scores (no refits).- param observed_result:
The result of the actual experiment run.
- type observed_result:
ExperimentResult
- param experiment_config:
The full configuration of the experiment.
- type experiment_config:
ExperimentConfig
- param X:
The raw features and targets.
- type X:
np.ndarray
- param y:
The raw features and targets.
- type y:
np.ndarray
- param groups:
CV grouping vector.
- type groups:
np.ndarray, optional
- param sample_ids:
Unique identifiers for samples.
- type sample_ids:
np.ndarray
- param sample_metadata:
Metadata for unit resolution.
- type sample_metadata:
pd.DataFrame, optional
- param feature_names:
Names of input features.
- type feature_names:
list of str, optional
- param time_axis:
Time coordinates for temporal data.
- type time_axis:
np.ndarray, optional
- param observation_level:
Level of input rows (‘sample’ or ‘epoch’).
- type observation_level:
str
- param inferential_unit:
Definition of statistical independence (‘sample’ or ‘subject’).
- type inferential_unit:
str
- param sample_weight:
The weights given to
Experiment.run: each permutation refits with them, so the null is fitted as the observed result was.- type sample_weight:
np.ndarray of shape (n_samples,), optional
- returns:
assessment_payload – Summary containing ‘rows’ (standardized results), ‘nulls’ and ‘meta’, which records the permutation scheme and its strata and block columns.
- rtype:
dict
- raises ValueError:
If the experiment produced no predictions; if a unit, strata or block column is missing; if a permuted unit or block holds more than one label, or the scoring unit spans several permuted units; or, for the sign-flip test, if a test fold holds more than one group or the metric has no known chance level and
chance.p0is unset.
Examples
>>> # Internal use within Experiment.run() >>> # res = run_statistical_assessment(observed, config, X, y, ...)
See also
binomial_accuracy_testCore analytical test.
assess_post_hoc_permutationFast post-hoc alternative.
- Parameters:
- Return type: