turicreate.image_classifier.ImageClassifier.predict

ImageClassifier.predict(dataset, output_type='class', batch_size=64)

Return predictions for dataset, using the trained logistic regression model. Predictions can be generated as class labels, probabilities that the target value is True, or margins (i.e. the distance of the observations from the hyperplane separating the classes). probability_vector returns a vector of probabilities by each class.

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. The probability is obtained by passing the margin through the logistic function. Predicted classes are obtained by thresholding the predicted probabilities at 0.5. If you would like to threshold predictions at a different probability level, you can use the Turi Create evaluation toolkit.

Parameters:
dataset : SFrame | SArray | turicreate.Image | array

The images to be classified or extracted features. If dataset is an SFrame, it must have 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 : {‘probability’, ‘margin’, ‘class’, ‘probability_vector’}, optional

Form of the predictions which are one of:

  • ‘probability’: Prediction probability associated with the True class (not applicable for multi-class classification)
  • ‘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.
batch_size : int, optional

If you are getting memory errors, try decreasing this value. If you have a powerful computer, increasing this value may improve performance.

Returns:
out : SArray

An SArray with model predictions. If dataset is a single image, the return value will be a single prediction.

See also

create, evaluate, classify

Examples

>>> probability_predictions = model.predict(data, output_type='probability')
>>> margin_predictions = model.predict(data, output_type='margin')
>>> class_predictions = model.predict(data, output_type='class')