def test_kmeans4(self): centroids = k_means(self.restaurants1 + self.restaurants2, 2) centroids.sort(key=lambda tup: tup[0] + tup[1]) self.assertEqual(centroids, [[0.0, -3.0], [1.0, 3.0]])
def test_kmeans3(self): centroids = k_means(self.restaurants1 + self.restaurants2, 1) centroids.sort(key=lambda tup: tup[0] + tup[1]) self.assertEqual(centroids, [[0.4, -0.6]])
def test_kmeans1(self): centroids = k_means(self.restaurants1, 1) self.assertEqual(centroids, [[0.0, -3.0]])
def test_kmeans2(self): centroids = k_means(self.restaurants2, 1) self.assertEqual(centroids, [[1.0, 3.0]])
def test_kmeans6(self): centroids = k_means(self.restaurants1 + self.restaurants2, 4) centroids.sort(key=lambda tup: tup[0] + tup[1]) self.assertEqual(centroids, [[-3.0, -4.0], [1.5, -2.5], [0.0, 3.0], [2.0, 3.0]])