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' })
Scope
columns
Family
stat
Returns
mask

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)
  • theilSen
  • siegelRepeatedMedian

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 linear model uses ordinary least squares regression.
  • The theilSen model provides robust predictions based on pairwise slopes.
  • The siegelRepeatedMedian model 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);