turicreate.linear_regression.LinearRegression.evaluate

LinearRegression.evaluate(dataset, metric='auto', missing_value_action='auto')

Evaluate the model by making target value predictions and comparing to actual values.

Two metrics are used to evaluate linear regression models. The first is root-mean-squared error (RMSE) while the second is the absolute value of the maximum error between the actual and predicted values. Let \(y\) and \(\hat{y}\) denote vectors of length \(N\) (number of examples) with actual and predicted values. The RMSE is defined as:

\[RMSE = \sqrt{\frac{1}{N} \sum_{i=1}^N (\widehat{y}_i - y_i)^2}\]

while the max-error is defined as

\[max-error = \max_{i=1}^N \|\widehat{y}_i - y_i\|\]
Parameters:
dataset : SFrame

Dataset of new observations. Must include columns with the same names as the target and features used for model training. Additional columns are ignored.

metric : str, optional

Name of the evaluation metric. Possible values are: - ‘auto’: Compute all metrics. - ‘rmse’: Rooted mean squared error. - ‘max_error’: Maximum error.

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 evaluation and terminate with an error message.
Returns:
out : dict

Results from model evaluation procedure.

See also

create, predict

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.evaluate(data)