turicreate.linear_regression.LinearRegression.predict

LinearRegression.predict(dataset, missing_value_action='auto')

Return target value predictions for dataset, using the trained linear regression model. This method can be used to get fitted values for the model by inputting the training dataset.

Parameters:
dataset : SFrame | pandas.Dataframe

Dataset of new observations. Must include columns with the same names as the features used for model training, but does not require a target column. Additional columns are ignored.

missing_value_action : str, optional

Action to perform when missing values are encountered. This can be one of:

  • ‘auto’: Default to ‘impute’
  • ‘impute’: Proceed with evaluation by filling in the missing values with the mean of the training data. Missing values are also imputed if an entire column of data is missing during evaluation.
  • ‘error’: Do not proceed with prediction and terminate with an error message.
Returns:
out : SArray

Predicted target value for each example (i.e. row) in the dataset.

See also

create, evaluate

Examples

>>> data =  turicreate.SFrame('https://static.turi.com/datasets/regression/houses.csv')
>>> model = turicreate.linear_regression.create(data,
                                     target='price',
                                     features=['bath', 'bedroom', 'size'])
>>> results = model.predict(data)