Exemple #1
0
 def test_compute_centroids(self):
     closest = ml.find_closest(self.ex7data2['X'],
                               np.array([[3, 3], [6, 2], [8, 5]]))
     ex1 = ml.compute_centroids(self.ex7data2['X'],
                                np.asarray(closest[0]), 3)
     self.assertEqual(ex1.all(), np.array([[2.428301, 3.157924],
                                           [5.813503, 2.633656],
                                           [7.119387, 3.616684]]).all())
Exemple #2
0
 def test_find_closest(self):
     closest = ml.find_closest(self.ex7data2['X'],
                               np.array([[3, 3], [6, 2], [8, 5]]))
     self.assertEqual(closest[0][0:3], [0,2,1])