Developer Guide and Reference

  • 2021.6
  • 04/11/2022
  • Public Content

Linear Regression

Linear regression is a method for modeling the relationship between a dependent variable (which may be a vector) and one or more explanatory variables by fitting linear equations to observed data.


Let LaTex Math image. be a vector of input variables and LaTex Math image. be the response. For each LaTex Math image., the linear regression model has the format [Hastie2009]:
LaTex Math image.
Here LaTex Math image., LaTex Math image., are referred to as independent variables, and LaTex Math image. are referred to as dependent variables or responses.
Linear regression is called:
  • Simple Linear Regression
    (if there is only one explanatory variable)
  • Multiple Linear Regression
    (if the number of explanatory variables LaTex Math image.)
Training Stage
Let LaTex Math image. be a set of training data, LaTex Math image.. The matrix LaTex Math image. of size LaTex Math image. contains observations LaTex Math image., LaTex Math image., LaTex Math image. of independent variables.
To estimate the coefficients LaTex Math image. one these methods can be used:
  • Normal Equation system
  • QR matrix decomposition
Prediction Stage
Linear regression based prediction is done for input vector LaTex Math image. using the equation LaTex Math image. for each LaTex Math image..

Usage of Training Alternative

To build a Linear Regression model using methods of the Model Builder class of Linear Regression, complete the following steps:
  • Create a Linear Regression model builder using a constructor with the required number of responses and features.
  • Use the
    method to add the set of pre-calculated coefficients to the model. Specify random access iterators to the first and the last element of the set of coefficients [ISO/IEC 14882:2011 §24.2.7]_.
    If your set of coefficients does not contain an intercept,
    is automatically set to
    , and to
    , otherwise.
  • Use the
    method to get the trained Linear Regression model.
  • Use the
    method to check the status of the model building process. If
    macros is defined, the status report contains the list of errors that describe the problems API encountered (in case of API runtime failure).
If after calling the
method you use the
method to update coefficients, the initial model will be automatically updated with the new LaTex Math image. coefficients.
C++ (CPU)
There is no support for Java on GPU.

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at