RSQUARED

Returns a table with the R-squared value of the predictions in a linear regression model.

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

Syntax

RSQUARED ( target, prediction )
    OVER()

Important: You cannot pass any inputs to the OVER() clause.

Parameters

target

The response variable for the model. Must be a float.

prediction

The output from the PREDICT_LINEAR_REG function. If that output is saved as a table, the column containing the prediction from the function is used. Must be a float.

Examples

This example shows how you can execute the RSQUARED function on an input table named faithful_testing. The response variables appear in the column, obs, while the prediction variables appear in the column, pred.

=> SELECT RSQUARED(obs, prediction) OVER()
     FROM (SELECT eruptions AS obs,
                  PREDICT_LINEAR_REG (waiting
                                       USING PARAMETERS model_name='linear_reg_faithful') AS prediction
           FROM faithful_testing) AS prediction_output;
        rsq        |                    comment
-------------------+-----------------------------------------------
 0.819686091991332 | Of 162 rows, 162 were used and 0 were ignored
(1 row)