prfmodel.scaling.Baseline¶
- class prfmodel.scaling.Baseline¶
Additive baseline scaling model.
Transforms a temporal response by adding a baseline.
Examples
>>> import numpy as np >>> import pandas as pd >>> params = pd.DataFrame({ ... "baseline": [5.0, 10.0, -3.0], ... }) >>> num_frames = 10 >>> inputs = np.ones((params.shape[0], num_frames)) >>> model = Baseline() >>> resp = model(inputs, params) >>> print(resp.shape) # (num_units, num_frames) (3, 10)
- __call__(inputs: prfmodel.typing.Tensor | numpy.ndarray, parameters: pandas.DataFrame, dtype: str | None = None) numpy.ndarray¶
Make predictions with the scaling model.
This is the public entry point; subclasses implement
call()instead. Usecall()when a backend tensor is required.- Parameters:
inputs (
prfmodel.typing.Tensoror numpy.ndarray) – Input tensor with temporal response and shape (num_units, num_frames).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:
- Raises:
ValueError – If parameters is missing one or more of
parameter_names.
- call(inputs: prfmodel.typing.Tensor, parameters: prfmodel.utils.TensorFrame) prfmodel.typing.Tensor¶
Predict the model response.
- Parameters:
inputs (
prfmodel.typing.Tensor) – Input tensor with temporal response and shape (num_units, num_frames).parameters (TensorFrame) – Model parameters as tensors, supporting the same column selection as a
pandas.DataFrame.
- Returns:
The predicted model response with shape (num_units, num_frames) and dtype dtype.
- Return type:
- check_parameter_names(parameters: pandas.DataFrame) None¶
Check that required parameter names are supplied.
- Parameters:
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different units.
- Raises:
ValueError – When a parameter name in the
parameter_namesattribute is not a column inparameters.
- check_parameter_values(parameters: pandas.DataFrame) None¶
Check that the parameter values lie inside the domain the model is defined on.
- Parameters:
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different units.
- Raises:
ValueError – When a parameter that must be
> 0is zero or negative.
- get_consumed_parameter_names(parameters: pandas.DataFrame) list[str]¶
Return the parameter names the model reads from
parameters.A name covered by
default_parametersis only read when the caller supplies a column for it; otherwise the default is merged in further down and the column would be absent here.- Parameters:
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different units.
- Returns:
Names of the parameters the model reads from
parameters.- Return type: