Beispiel #1
0
def test_n_init_not_positive_int():
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(n_init=-1)
        kmeans.fit(data_small)
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(n_init=0)
        kmeans.fit(data_small)
Beispiel #2
0
def test_init_not_2_views(data_small):
    with pytest.raises(ValueError):
        view1 = np.random.random((2,8))
        view2 = np.random.random((2,9))
        view3 = np.random.random((2,9))
        kmeans = MultiviewSphericalKMeans(init=[view1, view2, view3])
        kmeans.fit(data_small)
Beispiel #3
0
def test_not_2_views():
    with pytest.raises(ValueError):
        view1 = np.random.random((10,))
        view2 = np.random.random((10,))
        view3 = np.random.random((10,))
        kmeans = MultiviewSphericalKMeans()
        kmeans.fit([view1, view2, view3]) 
Beispiel #4
0
def test_final_centroids_less_than_n_clusters():
    with pytest.warns(ConvergenceWarning):
        kmeans = MultiviewSphericalKMeans(n_clusters=3,
                                          random_state=RANDOM_SEED)
        view1 = np.random.random((2, 11))
        view2 = np.random.random((2, 10))
        kmeans.fit([view1, view2])
Beispiel #5
0
def test_max_iter_not_positive_int(data_small):
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(max_iter=-1)
        kmeans.fit(data_small)
    
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(max_iter=0)
        kmeans.fit(data_small)
Beispiel #6
0
def test_predict_random_small(data_random):

    kmeans = MultiviewSphericalKMeans()
    input_data = [data_random['fit_data'][0][:2],data_random['fit_data'][1][:2]] 
    kmeans.fit(input_data)
    cluster_pred = kmeans.predict(data_random['test_data'])

    assert(data_random['n_test'] ==  cluster_pred.shape[0])

    for cl in cluster_pred:
        assert(cl >= 0 and cl < data_random['n_clusters'])
Beispiel #7
0
def test_patience_not_nonnegative_int(data_small):
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(patience=-1)
        kmeans.fit(data_small)
Beispiel #8
0
def test_samples_not_2D_2():
    with pytest.raises(ValueError):
        view1 = np.random.random((10,))
        view2 = np.random.random((10,))
        kmeans = MultiviewSphericalKMeans()
        kmeans.fit([view1, view2])
Beispiel #9
0
def test_samples_not_list():
    with pytest.raises(ValueError):
        view1 = 1
        view2 = 3
        kmeans = MultiviewSphericalKMeans()
        kmeans.fit([view1, view2])
Beispiel #10
0
def test_random_state_not_convertible(data_small):
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(random_state='ab')
        kmeans.fit(data_small)
Beispiel #11
0
def test_tol_not_nonnegative_float(data_small):
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(tol=-1)
        kmeans.fit(data_small)
Beispiel #12
0
def test_init_not_feat_dimensions(data_small):
    with pytest.raises(ValueError):
        view1 = np.random.random((2, 9))
        view2 = np.random.random((2, 9)) 
        kmeans = MultiviewSphericalKMeans(init=[view1, view2])
        kmeans.fit(data_small)
Beispiel #13
0
def test_init_not_n_clusters(data_small):
    with pytest.raises(ValueError):
        view1 = np.random.random((3, 8))
        view2 = np.random.random((3, 9)) 
        kmeans = MultiviewSphericalKMeans(init=[view1, view2])
        kmeans.fit(data_small)
Beispiel #14
0
def test_init_samples_not_2D_2(data_small):
    with pytest.raises(ValueError):
        view1 = np.random.random((2,))
        view2 = np.random.random((2,))
        kmeans = MultiviewSphericalKMeans(init=[view1, view2])
        kmeans.fit(data_small)
Beispiel #15
0
def test_init_samples_not_list(data_small):
    with pytest.raises(ValueError):
        view1 = 1
        view2 = 3
        kmeans = MultiviewSphericalKMeans(init=[view1, view2])
        kmeans.fit(data_small)
Beispiel #16
0
def test_not_init1(data_small):
    with pytest.raises(ValueError):
        kmeans = MultiviewSphericalKMeans(init='Not_Init')
        kmeans.fit(data_small)