PREDICT_LINEAR_REG

Applies a linear regression model on an input table or view.

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

Syntax

PREDICT_LINEAR_REG ( col1, col2, ... coln
                       USING PARAMETERS model_name = 'name_of_model'
                                        [, match_by_pos = 'method'])
                                        

Arguments

col1, col2, ..., coln

The columns to use from the input table or view.

Parameters

model_name = 'name_of_model'

The name of the linear regression model.

match_by_pos= 'method'

(Optional) Valid Values:

  • false (default): Input columns will be matched to features in the model based on their names.

  • true: Input columns will be matched to features in the model based on their position in the list of indicated input columns.

Return

Return data type:FLOAT

Returns the predicted value.

Examples

The following example shows how you can use the PREDICT_LINEAR_REG function on an input table.

=> SELECT PREDICT_LINEAR_REG(waiting USING PARAMETERS model_name='linear_reg_faithful')FROM faithful ORDER BY id;


 PREDICT_LINEAR_REG
--------------------
   4.15403481386324
   2.18505296804024
   3.76023844469864
    2.8151271587036
   4.62659045686076
   2.26381224187316
   4.86286827835952
   4.62659045686076
   1.94877514654148
   4.62659045686076
   2.18505296804024
.
.
.
 (272 rows)

The following example shows how you can use the PREDICT_LINEAR_REG function on an input table, using the match_by_pos parameter. Note that you can replace the column argument with a constant that does not match an input column:

=> SELECT PREDICT_LINEAR_REG(55 USING PARAMETERS model_name='linear_reg_faithful',
                     match_by_pos='true')FROM faithful ORDER BY id;
 PREDICT_LINEAR_REG
--------------------
2.28552115094171
2.28552115094171
2.28552115094171
2.28552115094171
2.28552115094171
2.28552115094171
2.28552115094171
.
.
.
 (272 rows)