class_docstr: Unit test class for the correctness or plausibility of Kmeans clustering
  results.
docstr: Check that Kmeans distances match nearest neighbors distances. This was
  a problem in early versions of the tool due to integer casting in the
  cluster centers.
code: def test_distance_accuracy(self):
      """
      Check that Kmeans distances match nearest neighbors distances. This was
      a problem in early versions of the tool due to integer casting in the
      cluster centers.
      """
      ftrs = ["int0", "int1", "float0"]
  
      ## Create models.
      kmeans = tc.kmeans.create(
          self.sf, features=ftrs, num_clusters=3, verbose=False
      )
      knn = tc.nearest_neighbors.create(
          kmeans.cluster_info,
          features=ftrs,
          method="ball_tree",
          distance="euclidean",
          verbose=False,
      )
  
      ## Transform int features into floats.
      coltype_map = {
          k: v
          for k, v in zip(
              self.sf.column_names(), self.sf.column_types()
          )
      }
      sf_float = tc.SFrame()
      for ftr in ftrs:
          if coltype_map[ftr] is int:
              sf_float[ftr] = self.sf[ftr].astype(float)
          else:
              sf_float[ftr] = self.sf[ftr]
  
      knn_dists = knn.query(sf_float, k=1, radius=None, verbose=False)
  
      ## Check that the results are equal.
      self.assertTrue(
          (
              kmeans.cluster_id["row_id"] == knn_dists["query_label"]
          ).all()
      )
      self.assertTrue(
          (
              kmeans.cluster_id["cluster_id"]
              == knn_dists["reference_label"]
          ).all()
      )
      assert_allclose(
          kmeans.cluster_id["distance"], knn_dists["distance"]
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import copy
  import numpy
  from numpy.testing import assert_allclose
  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 KmeansClusterTest obj's underlying member method code with example usage: obj.test_distance_accuracy() without return types