RegressionCFA¶
Contents¶
Overview¶
A RegressionCFA is a subclass of CompositionFunctionApproximator that parameterizes a set of regression_weights over trials to predict the net_outcome for a
Composition (or part of one) controlled by an OptimizationControlMechanism. The regression_weights are updated by its update_weights
LearningFunction assigned as its adapt method, which is called by the
evaluate method to predict the net_outcome
for a Composition (or part of one) controlled by an OptimizationControlMechanism, based on a set of
state_feature_values, a control_allocation, and the net_outcome they produced,
passed to it from an OptimizationControlMechanism.
The state_feature_values and control_allocation passed to the RegressionCFA’s adapt method, and provided
as the input to its update_weights, are represented in the vector attribute of a PredictionVector assigned to the RegressionCFA`s prediction_vector attribute. The state_feature_values are assigned to the state_features field of the
prediction_vector, and the control_allocation is assigned to the control_allocation field of the prediction_vector. The prediction_vector may also contain fields
for the costs ControlMechanism.costs associated with the control_allocation
and for interactions among those terms.
The regression_weights returned by the update_weights are used by the RegressionCFA’s evaluate method to predict
the net_outcome from the prediction_vector.
Class Reference¶
- class psyneulink.library.compositions.regressioncfa.PV¶
Specifies terms used to compute
vectorattribute ofPredictionVector.- F¶
Main effect of
state_feature_values.
- C¶
Main effect of
valuesofcontrol_signals.
- FF¶
Interaction among
state_feature_values.
- CC¶
Interaction among
valuesofcontrol_signals.
- FC¶
Interaction between
state_feature_valuesandvaluesofcontrol_signals.
- FFC¶
Interaction between interactions of
state_feature_valuesandvaluesofcontrol_signals.
- FCC¶
Interaction between
state_feature_valuesand interactions amongvaluesofcontrol_signals.
- FFCC¶
Interaction between interactions of
state_feature_valuesand interactions amongvaluesofcontrol_signals.
- COST¶
Main effect of
costsofcontrol_signals.
- class psyneulink.library.compositions.regressioncfa.RegressionCFA(name=None, update_weights=None, prediction_terms=None)¶
- RegressionCFA(
update_weights=BayesGLM, prediction_terms=[PV.F, PV.C, PV.COST])
Subclass of CompositionFunctionApproximator that implements a CompositionFunctionApproximator as the
agent_repof an OptimizationControlMechanism.See CompositionFunctionApproximator for additional arguments and attributes.
- Parameters:
update_weights (LearningFunction, function or method : default BayesGLM) – parameterizes the
regression_weightsused by theevaluatemethod to improve its prediction ofnet_outcomefrom a given set ofstate_feature_valuesand acontrol_allocationprovided by an OptimizationControlMechanism. It must take a 2d array as its first argument, the first item of which is an array the same length of thevectorattribute of itsprediction_vector, and the second item a 1d array containing a scalar value that it tries predict.prediction_terms (List[PV] : default [PV.F, PV.C, PV.COST]) – terms to be included in (and thereby determines the length of) the
vectorattribute of theprediction_vector; items are members of thePVenum; the default is [F,CFC,COST]. IfNoneis specified, the default values will automatically be assigned.
- update_weights¶
parameterizes the
regression_weightsused by theevaluatemethod to improve prediction ofnet_outcomefrom a given set ofstate_feature_valuesand acontrol_allocationprovided by an OptimizationControlMechanism; its result is assigned as the value of theregression_weightsattribute.- Type:
LearningFunction, function or method
- prediction_terms¶
terms included in
vectorattribute of theprediction_vector; items are members of thePVenum; the default is [F,CFC,COST].- Type:
List[PV]
- prediction_vector¶
represents and manages values in its
vectorattribute that are used byevaluate, along withregression_weightsto make its prediction. The values contained in thevectorattribute are determined byprediction_terms.- Type:
- regression_weights¶
result returned by
update_weightsmethod together withprediction_vectorto generate predictednet_outcome.- Type:
1d array
- class Parameters(owner, parent=None)¶
- prediction_vector¶
-
- Default value:
None
- Type:
- previous_state¶
see
previous_state- Default value:
None
- Type:
- regression_weights¶
-
- Default value:
None
- Type:
- update_weights¶
see
update_weights
- initialize(features_array, control_signals, context)¶
Assign owner and instantiate
prediction_vectorMust be called before RegressionCFA’s methods can be used.
- adapt(feature_values, control_allocation, net_outcome, context=None)¶
Update
regression_weightsso as to improve prediction of net_outcome from state_feature_values and control_allocation.
- evaluate(feature_values, control_allocation, num_estimates, num_trials_per_estimate, context)¶
Update prediction_vector <RegressionCFA.prediction_vector>`, then multiply by regression_weights.
Uses the current values of
regression_weightstogether with values of state_feature_values and control_allocation arguments to generate predictednet_outcome.Note
If this method is assigned as the
objective_funtion of a `GradientOptimizationFunction, it is differentiated using PyTorch autograd’sgrad.
- class PredictionVector(feature_values, control_signals, specified_terms)¶
Maintain a
vectorof terms for a regression model specified by a list ofspecified_terms.Terms are maintained in lists indexed by the
PVEnum and, in “flattened” form within fields of a 1d array invectorindexed by slices listed in theidxattribute.- Parameters:
feature_values (2d array) – arrays of state_features to assign as the
PV.Fterm ofterms.control_signals (List[ControlSignal]) – list containing the ControlSignals of an OptimizationControlMechanism; the
variableof each is assigned as thePV.Cterm ofterms.specified_terms (List[PV]) – terms to include in
vector; entries must be members of thePVEnum.
- specified_terms¶
terms included as predictors, specified using members of the
PVEnum.- Type:
List[PV]
- terms¶
current value of ndarray terms, some of which are used to compute other terms. Only entries for terms in
specified_termsare assigned values; others are assignedNone.- Type:
List[ndarray]
- num¶
number of arrays in outer dimension (axis 0) of each ndarray in
terms. Only entries for terms inspecified_termsare assigned values; others are assignedNone.- Type:
List[int]
- num_elems¶
number of elements in flattened array for each ndarray in
terms. Only entries for terms inspecified_termsare assigned values; others are assignedNone.- Type:
List[int]
- self.labels¶
label of each item in
terms. Only entries for terms inspecified_termsare assigned values; others are assignedNone.- Type:
List[str]
- vector¶
contains the flattened array for all ndarrays in
terms. Contains only the terms specified inspecified_terms. Indices for the fields corresponding to each term are listed inidx.- Type:
ndarray
- idx¶
indices of
vectorfor the flattened version of each nd term interms. Only entries for terms inspecified_termsare assigned values; others are assignedNone.- Type:
List[slice]
- update_vector(variable, feature_values=None, context=None)¶
Update vector with flattened versions of values returned from the
compute_termsmethod of theprediction_vector.Updates
vectorwith current values of variable and, optionally, and state_feature_values.