class_docstr: Unit test class for correctness of model predictions.
class_docstr_tok: ["Unit","test","class","for","correctness","of","model","predictions","."]
docstr: Unit test for class label predictions.
docstr_tok: ["Unit","test","for","class","label","predictions","."]
code: def test_classify(self):
      """
      Unit test for class label predictions.
      """
  
      ## Test type of output.
      ystar = self.model.classify(self.sf[:1], verbose=False)
  
      self.assertIsInstance(ystar, tc.SFrame)
      self.assertItemsEqual(
          ystar.column_names(), ["class", "probability"]
      )
      self.assertItemsEqual(ystar.column_types(), [str, float])
  
      ## Test plausibility of probability output.
      self.assertTrue(all(ystar["probability"] >= 0))
      self.assertTrue(all(ystar["probability"] <= 1))
  
      ## Check that classify on the training data with a single neighbor
      #  returns the training point.
      ystar = self.model.classify(
          self.sf, max_neighbors=1, verbose=False
      )
  
      self.assertTrue((ystar["class"] == self.sf["class"]).all())
      self.assertTrue(all(ystar["probability"] == 1))
  
      ## Check that classifying test data with a small radius returns None
      #  values if there are no qualified neighbors.
      ystar = self.model.classify(
          self.sf_test, max_neighbors=None, radius=1e-6, verbose=False
      )
  
      self.assertTrue(all(ystar["class"] == None))
      self.assertTrue(all(ystar["probability"] == None))
  
      ## Check that the results are correct if *some*, but not *all* of the
      #  test points have no qualified neighbors in the training set.
      ystar = self.model.classify(
          self.sf_test, max_neighbors=None, radius=15.0, verbose=False
      )
  
      self.assertItemsEqual(ystar.column_types(), [str, float])
      self.assertTrue(
          ystar["class"].countna() > 0
          and ystar["class"].countna() < self.sf_test.num_rows()
      )
      self.assertTrue(
          ystar["probability"].countna() > 0
          and ystar["probability"].countna() < self.sf_test.num_rows()
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import copy
  import array
  import numpy
  import turicreate
  from .None import util
  from turicreate.util import _assert_sframe_equal
  from turicreate.toolkits._main import ToolkitError
  import sys
label_desc: Use image node_id 3 for calling the KnnClassifierPredictTest obj's underlying member method code with example usage: obj.test_classify() without return types