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
vector
attribute ofPredictionVector
. F¶
Main effect of
state_feature_values
.
 C¶
Main effect of
values
ofcontrol_signals
.
 FF¶
Interaction among
state_feature_values
.
 CC¶
Interaction among
values
ofcontrol_signals
.
 FC¶
Interaction between
state_feature_values
andvalues
ofcontrol_signals
.
 FFC¶
Interaction between interactions of
state_feature_values
andvalues
ofcontrol_signals
.
 FCC¶
Interaction between
state_feature_values
and interactions amongvalues
ofcontrol_signals
.
 FFCC¶
Interaction between interactions of
state_feature_values
and interactions amongvalues
ofcontrol_signals
.
 COST¶
Main effect of
costs
ofcontrol_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_rep
of an OptimizationControlMechanism.See CompositionFunctionApproximator for additional arguments and attributes.
 Parameters
update_weights (LearningFunction, function or method : default BayesGLM) – parameterizes the
regression_weights
used by theevaluate
method to improve its prediction ofnet_outcome
from a given set ofstate_feature_values
and acontrol_allocation
provided 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 thevector
attribute 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
vector
attribute of theprediction_vector
; items are members of thePV
enum; the default is [F
,C
FC
,COST
]. IfNone
is specified, the default values will automatically be assigned.
 update_weights¶
parameterizes the
regression_weights
used by theevaluate
method to improve prediction ofnet_outcome
from a given set ofstate_feature_values
and acontrol_allocation
provided by an OptimizationControlMechanism; its result is assigned as the value of theregression_weights
attribute. Type
LearningFunction, function or method
 prediction_terms¶
terms included in
vector
attribute of theprediction_vector
; items are members of thePV
enum; the default is [F
,C
FC
,COST
]. Type
List[PV]
 prediction_vector¶
represents and manages values in its
vector
attribute that are used byevaluate
, along withregression_weights
to make its prediction. The values contained in thevector
attribute are determined byprediction_terms
. Type
 regression_weights¶
result returned by
update_weights
method together withprediction_vector
to 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_vector
Must be called before RegressionCFA’s methods can be used.
 adapt(feature_values, control_allocation, net_outcome, context=None)¶
Update
regression_weights
so 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_weights
together with values of state_feature_values and control_allocation arguments to generate predictednet_outcome
.
 class PredictionVector(feature_values, control_signals, specified_terms)¶
Maintain a
vector
of terms for a regression model specified by a list ofspecified_terms
.Terms are maintained in lists indexed by the
PV
Enum and, in “flattened” form within fields of a 1d array invector
indexed by slices listed in theidx
attribute. Parameters
feature_values (2d array) – arrays of state_features to assign as the
PV.F
term ofterms
.control_signals (List[ControlSignal]) – list containing the ControlSignals of an OptimizationControlMechanism; the
variable
of each is assigned as thePV.C
term ofterms
.specified_terms (List[PV]) – terms to include in
vector
; entries must be members of thePV
Enum.
 specified_terms¶
terms included as predictors, specified using members of the
PV
Enum. Type
List[PV]
 terms¶
current value of ndarray terms, some of which are used to compute other terms. Only entries for terms in
specified_terms
are 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_terms
are 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_terms
are assigned values; others are assignedNone
. Type
List[int]
 self.labels¶
label of each item in
terms
. Only entries for terms inspecified_terms
are 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
vector
for the flattened version of each nd term interms
. Only entries for terms inspecified_terms
are 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_terms
method of theprediction_vector
.Updates
vector
with current values of variable and, optionally, and state_feature_values.