Esempio n. 1
0
 def test_distortion_score_empty_clusters(self):
     """
     Ensure no ValueError is thrown when there are empty clusters #1185
     """
     X = np.array([[1, 2], [3, 4], [5, 6]])
     valuea = distortion_score(X, np.array([1, 3, 3]))
     valueb = distortion_score(X, np.array([0, 1, 1]))
     assert valuea == valueb
Esempio n. 2
0
    def test_distortion_score_pandas_input(self):
        """
        Test the distortion score metric on pandas DataFrame and Series
        """
        df = pd.DataFrame(self.clusters.X)
        s = pd.Series(self.clusters.y)

        score = distortion_score(df, s)
        assert score == pytest.approx(69.10006514142941)
Esempio n. 3
0
    def test_distortion_score_pandas_input(self):
        """
        Test the distortion score metric on pandas DataFrame and Series
        """
        df = pd.DataFrame(X)
        s = pd.Series(y)

        score = distortion_score(df, s)
        assert score == pytest.approx(7.6777850157143783)
Esempio n. 4
0
 def test_distortion_score_sparse_matrix_input(self, func):
     """
     Test the distortion score metric on a sparse array
     """
     score = distortion_score(func(self.clusters.X), self.clusters.y)
     assert score == pytest.approx(69.10006514142938)
Esempio n. 5
0
 def test_distortion_score(self):
     """
     Test the distortion score metric function
     """
     score = distortion_score(self.clusters.X, self.clusters.y)
     assert score == pytest.approx(69.10006514142941)
Esempio n. 6
0
 def test_distortion_score(self):
     """
     Test the distortion score metric function
     """
     score = distortion_score(X, y)
     self.assertEqual(score, 7.6777850157143783)
Esempio n. 7
0
 def test_distortion_score_sparse_matrix_input(self, Xs):
     """
     Test the distortion score metric on a sparse array
     """
     score = distortion_score(Xs, y)
     assert score == pytest.approx(7.6777850157143783)
Esempio n. 8
0
 def test_distortion_score(self):
     """
     Test the distortion score metric function
     """
     score = distortion_score(X, y)
     assert score == 7.6777850157143783