- Categories:
MEAN_ ERROR (system data metric function)¶
Returns the mean signed error between a column of predicted values and a column of actual values, where each error is the actual value minus the predicted value. Use this function to detect bias, that is, whether predictions are consistently too high or too low.
This topic provides the syntax for calling the function directly. To learn how to associate the function with a table or view so it runs at regular intervals, see Associate a DMF.
Syntax¶
Arguments¶
querySpecifies a SQL query that projects two columns. The first column contains the predicted values, and the second column contains the actual values.
Allowed data types¶
The two columns projected by the query must have the same data type, which must be one of
the following:
FLOATNUMBER
Returns¶
The function returns a FLOAT value:
- A positive value means that, on average, the predictions are lower than the actual values.
- A negative value means that, on average, the predictions are higher than the actual values.
- A value of 0 means that the errors cancel out. It doesn’t mean that every prediction is correct.
The function returns NULL if no row has both a predicted and an actual value.
Usage notes¶
- The function computes
AVG(actual - predicted). - The order of the columns matters. The first column is the predicted value and the second is the actual value. When you
associate the function with a table or view, specify the columns in the same order:
ON (predicted_column, actual_column). - Rows in which either value is
NULLare ignored. - You can’t mix data types. For example, you can’t use the function on a
NUMBERcolumn of predictions and aFLOATcolumn of actual values. - Errors in opposite directions cancel each other out. To measure the size of the errors, use MAE or RMSE.
Examples¶
The examples use the following table of demand forecasts. The prediction in the last row is missing, so the function ignores that row:
Measure the bias of the forecasts:
Associate the function with the table, and define an expectation that is violated when forecasts are, on average, more than 5 units too high or too low: