dataFrame.columns.stat — predict()
Description
The predict() method of the stat object computes predicted values for each row using a fitted regression model.
Signature
dataFrame.columns(...columnNames).stat.predict({ model: 'linear' })Arguments
...columnNames( string[] )- The name of the columns from which to compute the prediction.
options(object)- Prediction model options.
Option
model(string)- The regression model used to generate predictions.
linear(default)theilSensiegelRepeatedMedian
Returns
mask( number[] )- The predicted values computed for each row.
Notes
- The method requires exactly two selected numeric columns.
- The first selected column is interpreted as the predictor variable.
- The second selected column is used to fit the regression model.
- One predicted value is returned for each observation of the predictor column.
- The
linearmodel uses ordinary least squares regression. - The
theilSenmodel provides robust predictions based on pairwise slopes. - The
siegelRepeatedMedianmodel provides highly robust predictions resistant to outliers. - Predicted values are computed from the fitted regression line:
Example
// computes predicted values for 2 columns of the dataFrame
var mask = dataFrame.columns('x', 'y').stat.predict();
// add the predicted values to the dataFrame
dataFrame.column('y_pred').set(mask);