ERROR_RATE
Using an input table, returns a table which calculates the rate of incorrect classifications.
You cannot pass any inputs to the OVER()
clause.
Important: Before using a machine learning function, be aware that all the ongoing transactions might be committed.
Syntax
ERROR_RATE ( target, predictions [ USING PARAMETERS [num_classes=C] ]) OVER()
Arguments
target |
The column in the input table containing the response variable. Must be an integer. |
predictions |
The column in the input table containing the prediction variables. Must be an integer. |
Parameters
num_classes=C |
(Optional) The number of classes you want to pass to the function. Must be a positive integer. The result of |
Privileges
To use ERROR_RATE, you must either be the dbadmin, owner of the model or have USAGE privileges. There are no privileges needed on the function itself.
See GRANT (Schema) and GRANT (Table).
Examples
This example shows how you can execute the ERROR_RATE function on an input table named mtcars
. The response variables appear in the column obs
, while the prediction variables appear in the column pred
. Because this example is a classification problem, all of the response variable values and the prediction variable values are either 0 or 1, indicating binary classification.
In the table returned by the function, the first column displays the class id column. The second column displays the corresponding error rate for the class id. The third column indicates how many rows were successfully used by the function and whether any rows were ignored.
=> SELECT ERROR_RATE(obs, pred::int USING PARAMETERS num_classes=2) OVER() FROM (SELECT am AS obs, PREDICT_LOGISTIC_REG (mpg, cyl, disp, hp, drat, wt, qsec, vs, gear, carb USING PARAMETERS model_name='logisticRegModel', type='response') AS pred FROM mtcars) AS prediction_output; class | error_rate | comment -------+--------------------+--------------------------------------------- 0 | 0 | 1 | 0.0769230797886848 | | 0.03125 | Of 32 rows, 32 were used and 0 were ignored (3 rows)