LOGISTIC_REG

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

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

Syntax

LOGISTIC_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_LOGISTIC_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 INTEGER types with a value of either 0 or 1. The function automatically skips all other values.

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 to be 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: 0.000001

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 LOGISTIC_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 LOGISTIC_REG function.

=> SELECT LOGISTIC_REG('myLogisticRegModel', 'mtcars', 'am',
                       'mpg, cyl, disp, hp, drat, wt, qsec, vs, gear, carb'
                        USING PARAMETERS exclude_columns='hp', optimizer='BFGS');
        LOGISTIC_REG
----------------------------
 Finished in 20 iterations

(1 row)