turicreate.drawing_classifier.DrawingClassifier.predict_topk¶
-
DrawingClassifier.
predict_topk
(dataset, output_type='probability', k=3)¶ Return top-k predictions for the
dataset
, using the trained model. Predictions are returned as an SFrame with three columns: id, class, and probability or rank, depending on theoutput_type
parameter.Parameters: - dataset : SFrame | SArray | turicreate.Image
Drawings to be classified. If dataset is an SFrame, it 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 : {‘probability’, ‘rank’}, optional
Choose the return type of the prediction:
- probability: Probability associated with each label in the
- prediction.
- rank : Rank associated with each label in the prediction.
- k : int, optional
Number of classes to return for each input example.
- 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 : SFrame
An SFrame with model predictions.
Examples
>>> pred = m.predict_topk(validation_data, k=3) >>> print(pred) +----+-------+-------------------+ | id | class | probability | +----+-------+-------------------+ | 0 | 4 | 0.995623886585 | | 0 | 9 | 0.0038311756216 | | 0 | 7 | 0.000301006948575 | | 1 | 1 | 0.928708016872 | | 1 | 3 | 0.0440889261663 | | 1 | 2 | 0.0176190119237 | | 2 | 3 | 0.996967732906 | | 2 | 2 | 0.00151345680933 | | 2 | 7 | 0.000637513934635 | | 3 | 1 | 0.998070061207 | | .. | ... | ... | +----+-------+-------------------+ [35688 rows x 3 columns]