Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

prediction

prediction

BrainData prediction — timeseries (encoding) and MVPA (decoding).

Single entry point: predict. Returns Predict with fields populated based on dispatch. Mirrors BrainData.fit / Fit patterns: frozen result dataclass, inplace=True mutates self with attributes, inplace=False returns the dataclass.

Attributes:

NameTypeDescription
VALID_SPATIAL_SCALES

Methods:

NameDescription
build_pipelineBuild a per-fold scikit-learn preprocessing and model pipeline.
predictDispatch BrainData prediction to timeseries encoding or MVPA decoding.
predict_mvpaCross-validated decoding. Returns Predict (or self if inplace=True).
predict_timeseriesPredict voxel timeseries from a fitted encoding model.
resolve_modelResolve a string shortcut or pass through a sklearn estimator.
resolve_scoringResolve scoring=‘auto’ to ‘accuracy’ (classifier) or ‘r2’ (regressor).

Classes

Methods

build_pipeline

build_pipeline(model, standardize: bool, reduce: str | None, n_components: str | None)

Build a per-fold scikit-learn preprocessing and model pipeline.

The pipeline contains an optional StandardScaler, optional PCA, and the model. If only the model is needed, returns the model itself.

predict

predict(bd, *, y = None, X = None, spatial_scale: str = 'whole_brain', model: Any = 'svm', cv: int = 5, standardize: bool = True, reduce: str | None = None, n_components: int | None = None, scoring: str = 'auto', groups: str = None, roi_mask: str = None, radius_mm: float = 10.0, inplace: bool = False, n_jobs: int = 1, random_state: int | None = None, progress_bar: bool = False)

Dispatch BrainData prediction to timeseries encoding or MVPA decoding.

Implements BrainData.predict. See the class docstring for full parameter documentation.

predict_mvpa

predict_mvpa(bd, *, y, spatial_scale: str, model: Any, cv: Any, standardize: bool, reduce: str | None, n_components: int | None, scoring: str, groups: str, roi_mask: str, radius_mm: float, inplace: bool, n_jobs: int, random_state: int | None = None, progress_bar: bool = False) -> Predict | Any

Cross-validated decoding. Returns Predict (or self if inplace=True).

predict_timeseries

predict_timeseries(bd, *, X = None)

Predict voxel timeseries from a fitted encoding model.

Returns a fresh BrainData whose .data is the predicted timeseries. Encoding model prediction yields a brain image — the natural container is BrainData, so it composes directly with downstream methods (.plot(), .standardize(), etc.). MVPA decoding (y= mode) returns Predict.

resolve_model

resolve_model(model: Any)

Resolve a string shortcut or pass through a sklearn estimator.

resolve_scoring

resolve_scoring(scoring: str, classifier: bool) -> str

Resolve scoring=‘auto’ to ‘accuracy’ (classifier) or ‘r2’ (regressor).