train_model.mvpa_model: Train an MVPA Model

View source: R/model_fit.R

train_model.mvpa_modelR Documentation

Train an MVPA Model

Description

This function trains a Multi-Variate Pattern Analysis (MVPA) model on the provided data, taking care of feature selection, parameter tuning, and model fitting.

Usage

## S3 method for class 'mvpa_model'
train_model(obj, train_dat, y, indices, wts = NULL, ...)

Arguments

obj

An object of class mvpa_model, specifying the MVPA problem.

train_dat

Training data, an instance of class ROIVolume or ROISurface.

y

The dependent variable (response variable), either a numeric vector or a factor.

indices

The spatial indices associated with each column.

wts

Optional class weights (if the underlying model supports it).

...

Additional arguments passed to other methods.

Value

A model fit object containing the trained model, its fit, the model type (classification or regression), the best tuning parameters, the voxel indices, and the feature mask.

Examples


  dset_info <- gen_sample_dataset(D = c(8, 8, 8), nobs = 20,
    response_type = "categorical", data_mode = "image", nlevels = 2)
  cval <- blocked_cross_validation(dset_info$design$block_var)
  sda_model <- load_model("sda_notune")
  mspec <- mvpa_model(
    model = sda_model,
    dataset = dset_info$dataset,
    design = dset_info$design,
    model_type = "classification",
    crossval = cval
  )
  train_model(mspec, dset_info$dataset$train_data,
    dset_info$design$y_train,
    indices = seq_len(ncol(dset_info$dataset$train_data)))


bbuchsbaum/rMVPA documentation built on June 10, 2025, 8:23 p.m.