Ejemplo n.º 1
0
 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]])
Ejemplo n.º 2
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]])
Ejemplo n.º 3
0
 def test_kmeans1(self):
     centroids = k_means(self.restaurants1, 1)
     self.assertEqual(centroids, [[0.0, -3.0]])
Ejemplo n.º 4
0
 def test_kmeans2(self):
     centroids = k_means(self.restaurants2, 1)
     self.assertEqual(centroids, [[1.0, 3.0]])
Ejemplo n.º 5
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]])