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
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)
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)
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)
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)
def test_distortion_score(self): """ Test the distortion score metric function """ score = distortion_score(X, y) self.assertEqual(score, 7.6777850157143783)
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)
def test_distortion_score(self): """ Test the distortion score metric function """ score = distortion_score(X, y) assert score == 7.6777850157143783