fitAlgs.fitSims module¶
Author: | Dominic Hunt |
---|
-
class
fitAlgs.fitSims.
FitSim
(participant_choice_property='Actions', participant_reward_property='Rewards', model_fitting_variable='ActionProb', task_stimuli_property=None, fit_subset=None, action_options_property=None, float_error_response_value=1e-100)[source]¶ Bases:
object
A class for fitting data by passing the participant data through the model.
This has been setup for fitting action-response models
Parameters: - participant_choice_property (string, optional) – The participant data key of their action choices. Default
'Actions'
- participant_reward_property (string, optional) – The participant data key of the participant reward data. Default
'Rewards'
- model_fitting_variable (string, optional) – The key to be compared in the model data. Default
'ActionProb'
- task_stimuli_property (list of strings or None, optional) – The keys containing the stimuli seen by the
participant before taking a decision on an action. Default
None
- action_options_property (string or None or list of ints, optional) – The name of the key in partData where the list of valid actions
can be found. If
None
then the action list is considered to stay constant. If a list then the list will be taken as the list of actions that can be taken at each instance. DefaultNone
- float_error_response_value (float, optional) – If a floating point error occurs when running a fit the fitter function
will return a value for each element of fpRespVal. Default is
1/1e100
- fit_subset (
float('Nan')
,None
,"rewarded"
,"unrewarded"
,"all"
or list of int, optional) – Describes which, if any, subset of trials will be used to evaluate the performance of the model. This can either be described as a list of trial numbers or, by passing -"all"
for fitting all trials -float('Nan')
or"unrewarded"
for all those trials whose feedback wasfloat('Nan')
-"rewarded"
for those who had feedback that was notfloat('Nan')
DefaultNone
, which means all trials will be used.
-
Name
¶ The name of the fitting type
Type: string
See also
fitAlgs.fitAlg.FitAlg
- The general fitting class
-
fitness
(*model_parameters)[source]¶ Used by a fitter to generate the list of values characterising how well the model parameters describe the participants actions.
Parameters: model_parameters (list of floats) – A list of the parameters used by the model in the order previously defined Returns: model_performance – The choices made by the model that will be used to characterise the quality of the fit. Return type: list of floats See also
fitAlgs.fitSims.FitSim.participant()
- Fits participant data
fitAlgs.fitAlg.fitAlg()
- The general fitting class
fitAlgs.fitAlg.fitAlg.fitness()
- The function that this one is called by
-
fitted_model
(*model_parameters)[source]¶ Simulating a model run with specific parameter values
Parameters: *model_parameters (floats) – The model parameters provided in the order defined in the model setup Returns: model_instance Return type: model.modelTemplate.Model class instance
-
get_model_parameters
(*model_parameters)[source]¶ Compiles the model parameter arguments based on the model parameters
Parameters: model_parameters (list of floats) – The parameter values in the order extracted from the modelSetup parameter dictionary Returns: parameters – The kwarg model parameter arguments Return type: dict
-
get_model_properties
(*model_parameters)[source]¶ Compiles the kwarg model arguments based on the model_parameters and previously specified other parameters
Parameters: model_parameters (list of floats) – The parameter values in the order extracted from the modelSetup parameter dictionary Returns: model_properties – The kwarg model arguments Return type: dict
-
info
()[source]¶ The dictionary describing the fitters algorithm chosen
Returns: fitInfo – The dictionary of fitters class information Return type: dict
-
static
participant_sequence_generation
(participant_data, choice_property, reward_property, stimuli_property, action_options_property)[source]¶ Finds the stimuli in the participant data and returns formatted observations
Parameters: - participant_data (dict) – The participant data
- choice_property (string) – The participant data key of their action choices.
- reward_property (string) – The participant data key of the participant reward data
- stimuli_property (string or None or list of strings) – A list of the keys in partData representing participant stimuli
- action_options_property (string or None or list of strings, ints or None) – The name of the key in partData where the list of valid actions
can be found. If
None
then the action list is considered to stay constant. If a list then the list will be taken as the list of actions that can be taken at every trialstep. If the list is shorter than the number of trialsteps, then it will be considered to be a list of valid actions for each trialstep.
Returns: participant_sequence – Each list element contains the observation, action and feedback for each trial taken by the participant
Return type: list of three element tuples
- participant_choice_property (string, optional) – The participant data key of their action choices. Default