Ejemplo n.º 1
0
 def test_compute_centroids(self):
     initial_centroids = np.array([[3, 3], [6, 2], [8, 5]])
     idx = find_closest_centroids(self.X, initial_centroids)
     centroids = compute_centroids(self.X, idx, initial_centroids.shape[0])
     expected_centroids = np.array([[2.428301, 3.157924],
                                    [5.813503, 2.633656],
                                    [7.119387, 3.616684]])
     np.testing.assert_almost_equal(centroids,
                                    expected_centroids,
                                    decimal=6)
Ejemplo n.º 2
0
 def test_compute_centroids(self):
     initial_centroids = np.array([[3,3],
                                   [6,2],
                                   [8,5]])
     idx = find_closest_centroids(self.X, initial_centroids)
     centroids = compute_centroids(self.X, idx, initial_centroids.shape[0])
     expected_centroids = np.array([[2.428301, 3.157924],
                                    [5.813503, 2.633656],
                                    [7.119387, 3.616684]])
     np.testing.assert_almost_equal(centroids, expected_centroids, decimal=6)
Ejemplo n.º 3
0
 def test_find_closest_centroids(self):
     initial_centroids = np.array([[3, 3], [6, 2], [8, 5]])
     idx = find_closest_centroids(self.X[0:3, :], initial_centroids)
     np.testing.assert_equal(idx, np.array([1, 3, 2]))
Ejemplo n.º 4
0
 def test_find_closest_centroids(self):
     initial_centroids = np.array([[3,3],
                                   [6,2],
                                   [8,5]])
     idx = find_closest_centroids(self.X[0:3,:], initial_centroids)
     np.testing.assert_equal(idx, np.array([1,3,2]))