Beispiel #1
0
def test_final_centroids_no_consensus():
    with pytest.raises(ConvergenceWarning):
        kmeans = MultiviewKMeans(random_state=RANDOM_SEED)
        view1 = np.array([[0, 1], [1, 0]])
        view2 = np.array([[1, 0], [0, 1]])
        v1_centroids = np.array([[0, 1],[1, 0]])
        v2_centroids = np.array([[0, 1],[1, 0]])
        centroids = [v1_centroids, v2_centroids]
        kmeans._final_centroids([view1, view2], centroids)
Beispiel #2
0
def test_final_centroids_less_than_n_clusters():
    with pytest.raises(ConvergenceWarning):
        kmeans = MultiviewKMeans(n_clusters=3, random_state=RANDOM_SEED)
        view1 = np.random.random((2,5))
        view2 = np.random.random((2,6))
        v1_centroids = np.random.random((3, 5))
        v2_centroids = np.random.random((3, 6))
        centroids = [v1_centroids, v2_centroids]
        kmeans._final_centroids([view1, view2], centroids)
Beispiel #3
0
def test_predict_no_centroids2():
    kmeans = MultiviewKMeans()
    
    with pytest.raises(ConvergenceWarning):
        view1 = np.array([[0, 1], [1, 0]])
        view2 = np.array([[1, 0], [0, 1]])
        v1_centroids = np.array([[0, 1],[1, 0]])
        v2_centroids = np.array([[0, 1],[1, 0]])
        centroids = [v1_centroids, v2_centroids]
        kmeans._final_centroids([view1, view2], centroids)

    with pytest.raises(AttributeError):
        kmeans.predict([view1, view2])