model.BPE module

Author:Dominic Hunt
class model.BPE.BPE(alpha=0.3, epsilon=0.1, dirichletInit=1, validRewards=array([0, 1]), **kwargs)[source]

Bases: model.modelTemplate.Model

The Bayesian predictor model

Name

The name of the class used when recording what has been used.

Type:string
Parameters:
  • alpha (float, optional) – Learning rate parameter
  • epsilon (float, optional) – Noise parameter. The larger it is the less likely the model is to choose the highest expected reward
  • number_actions (integer, optional) – The maximum number of valid actions the model can expect to receive. Default 2.
  • number_cues (integer, optional) –
    The initial maximum number of stimuli the model can expect to receive.
    Default 1.
  • number_critics (integer, optional) – The number of different reaction learning sets. Default number_actions*number_cues
  • validRewards (list,np.ndarray, optional) – The different reward values that can occur in the task. Default array([0, 1])
  • action_codes (dict with string or int as keys and int values, optional) – A dictionary used to convert between the action references used by the task or dataset and references used in the models to describe the order in which the action information is stored.
  • dirichletInit (float, optional) – The initial values for values of the dirichlet distribution. Normally 0, 1/2 or 1. Default 1
  • prior (array of floats in [0, 1], optional) – Ignored in this case
  • stimFunc (function, optional) – The function that transforms the stimulus into a form the model can understand and a string to identify it later. Default is blankStim
  • rewFunc (function, optional) – The function that transforms the reward into a form the model can understand. Default is blankRew
  • decFunc (function, optional) – The function that takes the internal values of the model and turns them in to a decision. Default is model.decision.discrete.weightProb

See also

model.BP
This model is heavily based on that one
actStimMerge(dirichletVals, stimuli)[source]

Takes the parameter to be merged by stimuli and filters it by the stimuli values

Parameters:
  • actStimuliParam (list of floats) –
    The list of values representing each action stimuli pair, where the stimuli will have their filtered
    values merged together.
  • stimFilter (array of floats or a float, optional) – The list of active stimuli with their weightings or one weight for all. Default 1
Returns:

actionParams – The parameter values associated with each action

Return type:

list of floats

actorStimulusProbs()[source]

Calculates in the model-appropriate way the probability of each action.

Returns:probabilities – The probabilities associated with the action choices
Return type:1D ndArray of floats
calcActExpectations(dirichletVals)[source]
calcProbabilities(actionValues)[source]

Calculate the probabilities associated with the actions

Parameters:actionValues (1D ndArray of floats) –
Returns:probArray – The probabilities associated with the actionValues
Return type:1D ndArray of floats
delta(reward, expectation, action, stimuli)[source]

Calculates the comparison between the reward and the expectation

Parameters:
  • reward (float) – The reward value
  • expectation (float) – The expected reward value
  • action (int) – The chosen action
  • stimuli ({int | float | tuple | None}) – The stimuli received
Returns:

Return type:

delta

returnTaskState()[source]

Returns all the relevant data for this model

Returns:results – The dictionary contains a series of keys including Name, Probabilities, Actions and Events.
Return type:dict
rewardExpectation(observation)[source]

Calculate the estimated reward based on the action and stimuli

This contains parts that are task dependent

Parameters:observation ({int | float | tuple}) – The set of stimuli
Returns:
  • actionExpectations (array of floats) – The expected rewards for each action
  • stimuli (list of floats) – The processed observations
  • activeStimuli (list of [0, 1] mapping to [False, True]) – A list of the stimuli that were or were not present
storeState()[source]

Stores the state of all the important variables so that they can be accessed later

updateExpectations(dirichletVals)[source]
updateModel(delta, action, stimuli, stimuliFilter)[source]
Parameters:
  • delta (float) – The difference between the reward and the expected reward
  • action (int) – The action chosen by the model in this trialstep
  • stimuli (list of float) – The weights of the different stimuli in this trialstep
  • stimuliFilter (list of bool) – A list describing if a stimulus cue is present in this trialstep