turicreate.svm_classifier.SVMClassifier.predict

SVMClassifier.predict(dataset, output_type='class', missing_value_action='auto')

Return predictions for dataset, using the trained logistic regression model. Predictions can be generated as class labels (0 or 1), or margins (i.e. the distance of the observations from the hyperplane separating the classes). By default, the predict method returns class labels.

For each new example in dataset, the margin—also known as the linear predictor—is the inner product of the example and the model coefficients plus the intercept term. Predicted classes are obtained by thresholding the margins at 0.

Parameters:
dataset : SFrame | dict

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.

output_type : {‘margin’, ‘class’}, optional

Form of the predictions which are one of:

  • ‘margin’: Distance of the observations from the hyperplane separating the classes.
  • ‘class’: Class prediction.
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

An SArray with model predictions.

See also

create, evaluate, classify

Examples

>>> data =  turicreate.SFrame('https://static.turi.com/datasets/regression/houses.csv')
>>> data['is_expensive'] = data['price'] > 30000
>>> model = turicreate.svm_classifier.create(data,
                          target='is_expensive',
                          features=['bath', 'bedroom', 'size'])
>>> class_predictions = model.progressredict(data)
>>> margin_predictions = model.progressredict(data, output_type='margin')