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 OptimiziationControlMechanism
, based on a set of feature_values
, a control_allocation
,
and the net_outcome
they produced, passed to it from an OptimizationControlMechanism.
The feature_values
and control_allocation
passed to the RegressorCFA’s adapt
method, and provided
as the input to its update_weights
, are represented in the vector
attribute of a PredictionVector
assigned to the RegressorCFA`s prediction_vector
attribute. The feature_values
are
assigned to the 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 RegressorCFA’s evaluate
method to predict
the net_outcome
from the prediction_vector
.
Class Reference¶

class
psyneulink.library.compositions.regressioncfa.
PV
(*args, **kwargs)¶ Specifies terms used to compute
vector
attribute ofPredictionVector
.
F
¶ Main effect of
feature_values
.

C
¶ Main effect of
values
ofcontrol_signals
.

FF
¶ Interaction among
feature_values
.

CC
¶ Interaction among
values
ofcontrol_signals
.

FC
¶ Interaction between
feature_values
andvalues
ofcontrol_signals
.

FFC
¶ Interaction between interactions of
feature_values
andvalues
ofcontrol_signals
.

FCC
¶ Interaction between
feature_values
and interactions amongvalues
ofcontrol_signals
.

FFCC
¶ Interaction between interactions of
feature_values
and interactions amongvalues
ofcontrol_signals
.

COST
¶ Main effect of
costs
ofcontrol_signals
.

_member_type_
¶ alias of
object


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 anOptimizationControlmechanism
.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 offeature_values
and acontrol_allocation
provided by anOptimiziationControlMechanism
. 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
¶ LearningFunction, function or method – parameterizes the
regression_weights
used by theevaluate
method to improve prediction ofnet_outcome
from a given set offeature_values
and acontrol_allocation
provided by anOptimiziationControlMechanism
; its result is assigned as the value of theregression_weights
attribute.

prediction_terms
¶ List[PV] – terms included in
vector
attribute of theprediction_vector
; items are members of thePV
enum; the default is [F
,C
FC
,COST
].

prediction_vector
¶ PredictionVector – 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
.

regression_weights
¶ 1d array – result returned by
update_weights
method together withprediction_vector
to generate predictednet_outcome
.

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
Default value: BayesGLM
Type: Function


initialize
(features_array, control_signals, context)¶ Assign owner and instantiate
prediction_vector
Must be called before RegressorCFA’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 feature_values and control_allocation.

evaluate
(feature_values, control_allocation, num_estimates, context)¶ Update prediction_vector <RegressorCFA.prediction_vector>`, then multiply by regression_weights.
Uses the current values of
regression_weights
together with values of control_allocation and feature_values 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 nparray) – arrays of 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.

terms
¶ List[ndarray] – 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
.

num
¶ List[int] – 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
.

num_elems
¶ List[int] – number of elements in flattened array for each ndarray in
terms
. Only entries for terms inspecified_terms
are assigned values; others are assignedNone
.

self.
labels
¶ List[str] – label of each item in
terms
. Only entries for terms inspecified_terms
are assigned values; others are assignedNone
.

vector
¶ ndarray – 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
.

idx
¶ List[slice] – indices of
vector
for the flattened version of each nd term interms
. Only entries for terms inspecified_terms
are assigned values; others are assignedNone
.

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 feature_values.
 feature_values (2d nparray) – arrays of features to assign as the