Пример #1
0
    def test_cluster_stats(self):
        X = np.random.random((1000, 3))
        ids = np.random.choice(20, 1000)

        cluster_data = visuals._format_cluster_statistics(ids, X, ["a", "b", "c"])

        assert isinstance(cluster_data, dict)
        assert cluster_data["size"] == len(ids)
    def test_cluster_stats_sparse_coo(self):
        X = scipy.sparse.random(1000, 3, density=1.0, format="coo")
        ids = np.random.choice(20, 1000)

        with pytest.raises(
                ValueError,
                match=r".*sparse matrix format must be csr or csc.*"):
            cluster_data = visuals._format_cluster_statistics(
                ids, X, ["a", "b", "c"])
    def test_cluster_stats_sparse_csc(self):
        X = scipy.sparse.random(1000, 3, density=1.0, format="csc")
        ids = np.random.choice(20, 1000)

        cluster_data = visuals._format_cluster_statistics(
            ids, X, ["a", "b", "c"])

        assert isinstance(cluster_data, dict)
        assert cluster_data["size"] == len(ids)
Пример #4
0
    def test_cluster_stats_below(self):
        X = np.ones((1000, 3))
        ids = np.random.choice(20, 1000)
        X[ids, 0] = 0

        cluster_data = visuals._format_cluster_statistics(ids, X, ["a", "b", "c"])

        assert len(cluster_data["below"]) >= 1
        assert cluster_data["below"][0]["feature"] == "a"
        assert cluster_data["below"][0]["mean"] == 0
Пример #5
0
    def test_cluster_stats_below(self):
        X = np.ones((1000, 3))
        ids = np.random.choice(20, 1000)
        X[ids, 0] = 0

        cluster_data = visuals._format_cluster_statistics(
            ids, X, ["a", "b", "c"])

        assert len(cluster_data['below']) >= 1
        assert cluster_data['below'][0]['feature'] == 'a'
        assert cluster_data['below'][0]['mean'] == 0
    def test_cluster_stats_with_no_names(self):
        # This would be the default.

        X = np.ones((1000, 3))
        ids = np.random.choice(20, 1000)
        X[ids, 0] = 0

        cluster_data = visuals._format_cluster_statistics(ids, X, [])

        assert len(cluster_data["below"]) >= 1
        assert cluster_data["below"][0]["feature"] == "f_0"
        assert cluster_data["below"][0]["mean"] == 0