bsfit.nodes.models.bayes.StandardBayes

class bsfit.nodes.models.bayes.StandardBayes(initial_params: Dict[str, list], prior_shape: str, prior_mode: float, readout: str)[source]

Bases: bsfit.nodes.models.abstract_model.Model

Standard Bayesian model class

__init__(initial_params: Dict[str, list], prior_shape: str, prior_mode: float, readout: str)[source]

instantiate Standard Bayesian model

Parameters
  • initial_params (Dict) –

    initial_params = {
        "k_llh": list,
        "k_prior": list,
        "p_rand": list,
        "k_m": list,
    }
    

  • prior_shape (str) – prior’s function (“vonMisesPrior”)

  • prior_mode (float) – prior’s mode (e.g., 225)

  • readout (str) – decision process (“map”: max a posteriori readout)

Methods

__init__(initial_params, prior_shape, ...)

instantiate Standard Bayesian model

fit(dataset)

fit the model

get_attributes()

get model attributes

predict(data, granularity)

generate the model's predictions

simulate(dataset, granularity, centering, ...)

simulate predictions

fit(dataset: pandas.core.frame.DataFrame)[source]

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[source]

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)[source]

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)