prfmodel.regressors.RegressorsList¶
- class prfmodel.regressors.RegressorsList(regressors: list[prfmodel.regressors.base.BaseRegressors])¶
Composite regressor model that sums the predictions of multiple regressor models.
Used internally by canonical models to support passing a list of regressor models as the
regressors_modelargument. The parameter names of all child regressor models are aggregated (preserving insertion order, removing duplicates).At call time, the supplied design is a single
pandas.DataFramethat is passed to every child, each of which slices the columns it needs by name.- Parameters:
regressors (list of BaseRegressors) – Non-empty list of regressor model instances.
- Raises:
ValueError – If regressors is empty.
TypeError – If any element is not a
BaseRegressorsinstance.
Examples
>>> import numpy as np >>> import pandas as pd >>> from prfmodel.regressors import AdditiveRegressors, RegressorsList >>> a = AdditiveRegressors(names=["x"]) >>> b = AdditiveRegressors(names=["y"]) >>> regressors_model = RegressorsList([a, b]) >>> regressors_model.parameter_names ['beta_x', 'beta_y'] >>> params = pd.DataFrame({"beta_x": [1.0], "beta_y": [1.0]}) >>> design = pd.DataFrame({"x": np.ones(5), "y": np.ones(5) * 2.0}) >>> resp = regressors_model(design, params) >>> print(resp.shape) (1, 5)
- __call__(regressors: pandas.DataFrame, parameters: pandas.DataFrame, dtype: str | None = None) prfmodel.typing.Tensor¶
Compute the sum of predictions from all child regressor models.
- Parameters:
regressors (pandas.DataFrame) – A single design data frame whose columns cover every child’s required regressor names. It is passed to each child, which slices the columns it needs by name; extra columns are ignored.
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different units.
dtype (str, optional) – The dtype of the prediction result. If None (the default), uses the dtype from
prfmodel.utils.get_dtype().
- Returns:
The predicted model response with shape (num_units, num_frames) and dtype dtype.
- Return type: