run¶
-
dataFitting.
run
(data_folder=u'./', data_format=u'csv', data_file_filter=None, data_file_terminal_ID=True, data_read_options=None, data_split_by=None, data_group_by=None, data_extra_processing=None, model_name=u'QLearn', model_changing_properties=None, model_constant_properties=None, participantID=u'Name', participant_choices=u'Actions', participant_rewards=u'Rewards', model_fit_value=u'ActionProb', fit_subset=None, task_stimuli=None, participant_action_options=None, fit_method=u'Evolutionary', fit_method_args=None, fit_measure=u'-loge', fit_measure_args=None, fit_extra_measures=None, participant_varying_model_parameters=None, label=None, save_fitting_progress=False, config_file=None, output_path=None, pickle=False, boundary_excess_cost_function=None, min_log_level=u'INFO', numpy_error_level=u'log', fit_float_error_response_value=1e-100, calculate_covariance=False)[source]¶ A framework for fitting models to data for tasks, along with recording the data associated with the fits.
Parameters: - data_folder (string or list of strings, optional) – The folder where the data can be found. Default is the current folder.
- data_format (string, optional) – The file type of the data, from
mat
,csv
,xlsx
andpkl
. Default iscsv
- data_file_filter (callable, string, list of strings or None, optional) – A function to process the file names or a list of possible prefixes as strings or a single string.
Default
None
, no file names removed - data_file_terminal_ID (bool, optional) – Is there an ID number at the end of the filename? If not then a more general search will be performed.
Default
True
- data_read_options (dict, optional) – The keyword arguments for the data importing method chosen
- data_split_by (string or list of strings, optional) – If multiple participant datasets are in one file sheet, this specifies the column or columns that can
distinguish and identify the rows for each participant. Default
None
- data_group_by (list of strings, optional) – A list of parts of filenames that are repeated across participants, identifying all the files that should
be grouped together to form one participants data. The rest of the filename is assumed to identify the
participant. Default is
None
- data_extra_processing (callable, optional) – A function that modifies the dictionary of data read for each participant in such that it is appropriate
for fitting. Default is
None
- model_name (string, optional) – The name of the file where a model.modelTemplate.Model class can be found. Default
QLearn
- model_changing_properties (dictionary with values of tuple of two floats, optional) – Parameters are the options that you allow to vary across model fits. Each model parameter is specified as a
dict key. The value is a tuple containing the upper and lower search bounds, e.g.
alpha
has the bounds (0, 1). DefaultNone
- model_constant_properties (dictionary of float, string or binary valued elements, optional) – These contain all the the model options that define the version
of the model being studied. Default
None
- participantID (basestring, optional) – The key (label) used to identify each participant. Default
Name
- participant_choices (string, optional) – The participant data key of their action choices. Default
'Actions'
- participant_rewards (string, optional) – The participant data key of the participant reward data. Default
'Rewards'
- model_fit_value (string, optional) – The key to be compared in the model data. Default
'ActionProb'
- 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. - task_stimuli (list of strings or None, optional) – The keys containing the observational parameters seen by the
participant before taking a decision on an action. Default
None
- participant_action_options (string or list of strings or None or one element list with a list, optional) – If a string or list of strings these are treated as dict keys where the valid actions for each trial can
be found. If None then all trials will use all available actions. If the list contains one list then it will
be treated as a list of valid actions for each trialstep. Default
'None'
- fit_method (string, optional) – The fitting method to be used. The names accepted are those of the modules in the folder fitAlgs containing a
FitAlg class. Default
'evolutionary'
- fit_method_args (dict, optional) – A dictionary of arguments specific to the fitting method. Default
None
- fit_measure (string, optional) – The name of the function used to calculate the quality of the fit.
The value it returns provides the fitter with its fitting guide. Default
-loge
- fit_measure_args (dict, optional) – The parameters used to initialise fitMeasure and extraFitMeasures. Default
None
- fit_extra_measures (list of strings, optional) – List of fit measures not used to fit the model, but to provide more information. Any arguments needed for these
measures should be placed in fitMeasureArgs. Default
None
- participant_varying_model_parameters (dict of string, optional) – A dictionary of model settings whose values should vary from participant to participant based on the
values found in the imported participant data files. The key is the label given in the participant data file,
as a string, and the value is the associated label in the model, also as a string. Default
{}
- label (string, optional) – The label for the data fitting. Default
None
will mean no data is saved to files. - save_fitting_progress (bool, optional) – Specifies if the results from each iteration of the fitting process should be returned. Default
False
- config_file (string, optional) – The file name and path of a
.yaml
configuration file. Overrides all other parameters if found. DefaultNone
- output_path (string, optional) – The path that will be used for the run output. Default
None
- pickle (bool, optional) – If true the data for each model, and participant is recorded.
Default is
False
- boundary_excess_cost_function (basestring or callable returning a function, optional) – The function is used to calculate the penalty for exceeding the boundaries.
Default is
boundFunc.scalarBound()
- min_log_level (basestring, optional) – Defines the level of the log from (
DEBUG
,INFO
,WARNING
,ERROR
,CRITICAL
). DefaultINFO
- numpy_error_level ({'log', 'raise'}) – Defines the response to numpy errors. Default
log
. See numpy.seterr - fit_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`
- calculate_covariance (bool, optional) – Is the covariance calculated. Default
False
See also
modelGenerator()
- The model factory
outputting()
- The outputting functions
fitAlgs.fitAlg.FitAlg()
- General class for a method of fitting data
fitAlgs.fitSims.fitSim()
- General class for a method of simulating the fitting of data
data.Data()
- Data import class