bsfit.nodes.models.bayes.CardinalBayes¶
- class bsfit.nodes.models.bayes.CardinalBayes(initial_params: Dict[str, list], prior_shape: str, prior_mode: float, readout: str)[source]¶
Bases:
bsfit.nodes.models.bayes.StandardBayes
Cardinal Bayesian model
- __init__(initial_params: Dict[str, list], prior_shape: str, prior_mode: float, readout: str)[source]¶
Instantiate Cardinal Bayesian model
- Parameters
prior_shape (str) – prior shape
"vonMisesPrior" (-) –
prior_mode (float) – prior mode
readout (str) – the posterior readout
"map" (-) – maximum a posteriori
- Exceptions:
MissingParameter: - “k_card” parameter is missing
Methods
__init__
(initial_params, prior_shape, ...)Instantiate Cardinal Bayesian model
fit
(dataset)fit the model
get model attributes
predict
(data, granularity)generate the model's predictions
simulate
(dataset, granularity, centering, ...)simulate predictions
- fit(dataset: pandas.core.frame.DataFrame)¶
fit the model
- Parameters
dataset (pd.DataFrame) –
dataset with columns:
'stim_mean': the stimulus feature (e.g., motion direction) 'stim_std': the stimulus feature strength 'prior_mode': mode of prior 'prior_std': std of the prior 'prior_shape': density function of the prior (e.g., "vonMisesPrior") 'estimate': the estimate data
init_p (dict) – initial parameters
- Usage:
from bsfit.nodes.models.bayes import StandardBayes initial_params = { "k_llh": [2.7, 10.7, 33], "k_prior": [2.7, 33], "p_rand": [0], "k_m": [2000], } model = StandardBayes( initial_params=initial_params, prior_shape="vonMisesPrior", prior_mode=225, readout="map") model.fit(dataset)
- Returns
the fitted model
- Return type
(Model)
- get_attributes()¶
get model attributes
- Parameters
self (Model) – the model
- Returns
list the model attributes
- Return type
(list)
- predict(data: tuple, granularity: str) dict ¶
generate the model’s predictions
- Parameters
data (tuple) – the data to predict, tuple of (stim_mean, stim_estimate)
granularity (str) – (“trial” or “mean”) to predict single choices or their stats
- Returns
the model predictions
- Return type
(dict)
- simulate(dataset: pandas.core.frame.DataFrame, granularity: str, centering: bool, **kwargs: dict)¶
simulate predictions
- Parameters
dataset (pd.DataFrame) –
dataset:
'stim_mean': the stimulus feature (e.g., motion direction) 'stim_std': the stimulus feature strength 'prior_mode': the stimulus feature density's mode 'prior_std': the stimulus feature density's std 'prior_shape': prior's density function (e.g., "vonMisesPrior") 'estimate' (optional): the estimate data
granularity (str) – (“trial” or “mean”)
centering (bool) – center or not plot’s x-axis
- Kwargs:
n_repeats (int): the number of repeats of conditions, when granularity=”trial”
- Returns
results of the simulation
- Return type
(dict)