The Linear Regression function models the relationship between input variables by fitting a linear equation to the input data.
The method consists of two steps. First, a model is trained. Second, values are predicted by the model. Linear Regression is integrated into the existing table framework. Currently, model training and prediction can not be separated.
- TRAIN_LM: Trains a Linear Regression model.
- TRAIN_FILTERED_LM: The data on which the linear model is trained is filtered.
- INPUT: One or more columns, which is used to train the model so that it describes the Output.
- OUTPUT: One column, through which the model lays a predictor function.
- PREDICT: One or more columns, on which for each row a predicted value is returned by applying the trained model.
All columns in TRAIN_LM have to be joinable. The columns in PREDICT do not have to be joinable with the columns in TRAIN_LM.
The input of the model training is regarded as an independent sub query. This means if an aggregation is used, it is independent of the dimensions defined in the rest of the query. This also means that the columns within TRAIN_LM have to be joinable, but not with the columns used in the rest of the query.
- If a row contains a NULL value, the value is ignored and does not affect the model.
- If a
PREDICTrow contains a NULL value, the result for that row will be NULL.
Standard Linear Regression
If rows of a column are filtered, it does not affect the linear model, as long as the linear model is not trained on aggregation results. This means independent of filters and selections, the underlying model stays the same. If you want to restrict the input data of a model you can use a CASE WHEN statement and map the values you want to be ignored to null. If a model is trained on results of an aggregation it still changes with the filtering because the result of the aggregation is affected by the filtering.
Filtered Linear Regression
If a filter or selection changes, the model is retrained and the resulting function adopts to the new of view of data. This has a serious performance impact.