Ejemplo n.º 1
0
def test_silhouette_score_batched_non_monotonic():
    vecs = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 2.0, 2.0],
                     [10.0, 10.0, 10.0]])
    labels = np.array([0, 0, 1, 3])

    cuml_score = cu_silhouette_score(X=vecs, labels=labels)
    sk_score = sk_silhouette_score(X=vecs, labels=labels)
    assert_almost_equal(cuml_score, sk_score, decimal=2)

    vecs = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [10.0, 10.0, 10.0]])
    labels = np.array([1, 1, 3])

    cuml_score = cu_silhouette_score(X=vecs, labels=labels)
    sk_score = sk_silhouette_score(X=vecs, labels=labels)
    assert_almost_equal(cuml_score, sk_score, decimal=2)
Ejemplo n.º 2
0
def test_silhouette_score_batched(metric, chunk_divider, labeled_clusters):
    X, labels = labeled_clusters
    cuml_score = cu_silhouette_score(X,
                                     labels,
                                     metric=metric,
                                     chunksize=int(X.shape[0] / chunk_divider))
    sk_score = sk_silhouette_score(X, labels, metric=metric)
    assert_almost_equal(cuml_score, sk_score, decimal=2)
Ejemplo n.º 3
0
def test_silhouette_score(metric, labeled_clusters):
    X, labels = labeled_clusters
    cuml_score = cu_silhouette_score(X, labels, metric=metric)
    sk_score = sk_silhouette_score(X, labels, metric=metric)
    assert_almost_equal(cuml_score, sk_score)