turicreate.text_classifier.TextClassifier.predict

TextClassifier.predict(dataset, output_type='class')

Return predictions for dataset, using the trained model.

Parameters:
dataset : SFrame

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 : {‘class’, ‘probability_vector’}, optional

Form of the predictions which are one of:

  • ‘probability_vector’: Prediction probability associated with each class as a vector. The probability of the first class (sorted alphanumerically by name of the class in the training set) is in position 0 of the vector, the second in position 1 and so on.
  • ‘class’: Class prediction. For multi-class classification, this returns the class with maximum probability.
Returns:
out : SArray

An SArray with model predictions.

See also

create, evaluate, classify

Examples

>>> import turicreate as tc
>>> dataset = tc.SFrame({'rating': [1, 5], 'text': ['hate it', 'love it']})
>>> m = tc.text_classifier.create(dataset, 'rating', features=['text'])
>>> m.predict(dataset)