SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Defines the interface for regression parameter calculation objects. More...
#include <rw/analytics/regcalc.h>
Public Member Functions | |
RWRegressionCalc () | |
virtual void | addObsToBaseCalc (const RWAddObservations< T, S > &dataChange) |
virtual void | addPredToBaseCalc (const RWAddPredictors< T, S > &dataChange) |
virtual void | calc (const RWGenMat< T > &r, const RWMathVec< S > &o)=0 |
virtual RWRegressionCalc< T, S > * | clone () const =0 |
virtual bool | fail () const =0 |
virtual RWCString | name () const =0 |
virtual RWMathVec< T > | parameters () const =0 |
virtual void | removeObsFromBaseCalc (const RWRemoveObservations< T, S > &dataChange) |
virtual void | removePredFromBaseCalc (const RWRemovePredictors< T, S > &dataChange) |
virtual void | setBaseCalc (const RWGenMat< T > &r, const RWMathVec< S > &o) |
The abstract base class RWRegressionCalc defines the interface for the regression parameter calculation objects used in Linear Algebra Module. Classes derived from RWRegressionCalc include RWLeastSqQRCalc, RWLeastSqQRPvtCalc, and RWLeastSqSVDCalc for linear regression, and RWLogisticIterLSQ and RWLogisticLevenbergMarquardt for logistic regression. The template parameter T
specifies the datatype for elements in the predictor matrix (usually double
), and the template parameter S
specifies the datatype for elements in the observation vector (usually double
for linear regression and bool
for logistic regression).
If you want to provide your own parameter calculation algorithm as an alternative to those already available in Linear Algebra Module, it is useful to understand the interface to RWRegressionCalc. Otherwise, once you have provided an implementation class derived from RWRegressionCalc, you can use that implementation simply by calling the method RWLinearRegression::setCalcMethod() or the method RWLogisticRegression::setCalcMethod() with an instance of the implementation class.
|
inline |
Constructs an empty RWRegressionCalc object.
|
virtual |
Recalculates the regression model using an additional set of predictor-observation data pairs. This method offers the option of using results from the base calculation to calculate the coefficients for the larger data set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable provides the additional data. The default implementation simply recalculates the parameters from scratch using the calc() method.
Reimplemented in RWLogisticLevenbergMarquardt, and RWLogisticIterLSQ.
|
virtual |
Expands the regression model to include new predictor variables. This method has the option of using results from the base calculation to calculate the coefficients for the larger predictor set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable contains the data for the added predictor variables. The default implementation simply recalculates the parameters from scratch using the calc() method.
Reimplemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, and RWLeastSqQRCalc.
|
pure virtual |
Calculates the parameters for the regression model. This is a pure virtual function that must be overridden by deriving classes. Invoking this method does not affect the state of any existing base calculation.
Implemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, RWLeastSqQRPvtCalc, RWLeastSqSVDCalc, and RWLeastSqQRCalc.
|
pure virtual |
Allocates and creates a clone, or exact copy, of the current instance, and returns a pointer to the copy. Caller is responsible for deleting the returned object.
Implemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, RWLeastSqQRPvtCalc, RWLeastSqSVDCalc, and RWLeastSqQRCalc.
|
pure virtual |
Returns true
if the calculation failed.
Implemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, RWLeastSqQRPvtCalc, RWLeastSqSVDCalc, and RWLeastSqQRCalc.
|
pure virtual |
Returns the name of the calculation method.
Implemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, RWLeastSqQRPvtCalc, RWLeastSqSVDCalc, and RWLeastSqQRCalc.
|
pure virtual |
Returns the parameters from the last calculation performed. If the calculation failed, and this method is called, an exception of type RWInternalErr is thrown.
Implemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, RWLeastSqQRCalc, RWLeastSqSVDCalc, and RWLeastSqQRPvtCalc.
|
virtual |
Modifies the regression model by removing a set of contiguous predictor-observation data pairs, and recalculating the parameters. This method offers the option of using results from the base calculation to calculate the coefficients for the smaller data set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable indicates the indices of the rows to be removed from the regression matrix and from the observation vector used in the base calculation. The default implementation simply recalculates the parameters from scratch using the calc() method.
Reimplemented in RWLogisticLevenbergMarquardt, and RWLogisticIterLSQ.
|
virtual |
Shrinks the regression model to exclude previously used predictor variables. This method offers the option of using results from the base calculation to calculate the coefficients for the smaller predictor set. Consequently, this method can be called only when a base calculation has been set using setBaseCalc(). The input variable indicates the indices of the columns to be removed from the regression matrix used in the base calculation. The default implementation simply recalculates the parameters from scratch using the calc() method.
Reimplemented in RWLogisticLevenbergMarquardt, RWLogisticIterLSQ, and RWLeastSqQRCalc.
|
inlinevirtual |
Calculates the coefficients for the input regression data and sets the base calculation to this calculation. Deriving classes need not override this method if they do not store base calculation results. The default implementation calls the calc() method.
Reimplemented in RWLogisticIterLSQ, RWLogisticLevenbergMarquardt, and RWLeastSqQRCalc.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |