LINEAR_REG

Executes linear regression on an input table or view. The result is a linear regression model.

Important: Before using a machine learning function, be aware that all the ongoing transactions might be committed.

Syntax

LINEAR_REG ( 'model_name', 'input_relation', 'response_column', 'predictor_columns'
	      [ USING PARAMETERS[exclude_columns='col1, col2, ... coln',]
	                        [optimizer='value',]
	                        [epsilon=value,]
	                        [max_iterations=value,]
                               [regularization= 'value',]
                               [lambda= value] ])

Arguments

model_name

The name of the linear regression model. You can use the resulting model for prediction with the PREDICT_LINEAR_REG function.

Model names are case insensitive.

input_relation

The table or view that contains the training data for building the model.

response_column

The name of the column in the input_relation that represents the dependent variable, or outcome.

For the model to be valid, all values in this column must be of type numeric.

predictor_columns

A comma-separated list of the columns in the input_relation that represent the independent variables for the model.

For the model to be valid, all values in this column must be of type numeric.

Supports the use of wildcard (*) characters in place of column names. If you use a wildcard character (*) in place of a column name, all the columns in input_relation are selected. In this case, the response_column must be explicitly excluded using the list assigned to exclude_columns.

Parameters

exclude_columns=col1, col2, ... coln

(Optional) The columns from input_relation that you want to exclude from the predictor_columns argument.

optimizer=value

(Optional) The optimizer method used to train the model.

Valid Values:

  • BFGS
  • Newton (default value)
epsilon=value

(Optional) Determines whether the algorithm has reached the specified accuracy result.

Default Value: 1e-6

max_iterations=value

(Optional) Determines the maximum number of iterations the algorithm performs before achieving the specified accuracy result.

Default Value: 100

regularization=value

(Optional) Determines the method of regularization.

Default Value: None

Valid Values:

  • L2
  • None
lambda=value

(Optional) The regularization parameter value. The value must be zero or positive.

Default Value: 0.0

Privileges

To use LINEAR_REG, you must either be a superuser or have CREATE privileges for the schema of the output view and SELECT privileges for the input table or view. There are no privileges needed on the function itself.

See GRANT (Schema) and GRANT (Table).

Examples

This example shows how you can use the LINEAR_REG function.

=> SELECT LINEAR_REG('myLinearRegModel', 'faithful', 'eruptions', 'waiting' 
                      USING PARAMETERS optimizer='BFGS');
         LINEAR_REG
----------------------------
 Finished in 10 iterations

(1 row)