How to use susi - 10 common examples

To help you get started, we’ve selected a few susi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felixriese / susi / tests / test_SOMClustering.py View on Github external
def test_transform(n_rows, n_columns, X):
    som_clustering = susi.SOMClustering(
        n_rows=n_rows, n_columns=n_columns)
    som_clustering.fit(X)
    bmus = som_clustering.transform(X)
    assert(len(bmus) == X.shape[0])
    assert(len(bmus[0]) == 2)
github felixriese / susi / tests / test_SOMClustering.py View on Github external
def test_fit(X, n_rows, n_columns, train_mode_unsupervised, random_state,
             expected):
    som = susi.SOMClustering(
        n_rows=n_rows,
        n_columns=n_columns,
        train_mode_unsupervised=train_mode_unsupervised,
        random_state=random_state)

    som.fit(X)
    assert isinstance(som.unsuper_som_, np.ndarray)
    assert som.unsuper_som_.shape == (n_rows, n_columns, X.shape[1])
    assert np.allclose(som.unsuper_som_, expected, atol=1e-20)

    with pytest.raises(Exception):
        som = susi.SOMClustering(train_mode_unsupervised="alsdkf")
        som.fit(X)
github felixriese / susi / tests / test_SOMClustering.py View on Github external
def test_som_clustering_init(n_rows, n_columns):
    som_clustering = susi.SOMClustering(
        n_rows=n_rows, n_columns=n_columns)
    assert som_clustering.n_rows == n_rows
    assert som_clustering.n_columns == n_columns
github felixriese / susi / tests / test_SOMRegressor.py View on Github external
def test_mexicanhat_nbh_dist_weight_mode():
    som = susi.SOMRegressor(nbh_dist_weight_mode="mexican-hat")
    som.fit(X_train, y_train)
    som.predict(X_test)
    with pytest.raises(Exception):
        som = susi.SOMRegressor(nbh_dist_weight_mode="pseudogaussian")
        som.fit(X_train, y_train)
github felixriese / susi / tests / test_SOMRegressor.py View on Github external
def test_mexicanhat_nbh_dist_weight_mode():
    som = susi.SOMRegressor(nbh_dist_weight_mode="mexican-hat")
    som.fit(X_train, y_train)
    som.predict(X_test)
    with pytest.raises(Exception):
        som = susi.SOMRegressor(nbh_dist_weight_mode="pseudogaussian")
        som.fit(X_train, y_train)
github felixriese / susi / tests / test_SOMRegressor.py View on Github external
def test_som_regressor_init(n_rows, n_columns):
    som_reg = susi.SOMRegressor(
        n_rows=n_rows, n_columns=n_columns)
    assert(som_reg.n_rows == n_rows)
    assert(som_reg.n_columns == n_columns)
github felixriese / susi / tests / test_MultiOutput.py View on Github external
def test_MultiOutputRegressor():
    mor = MultiOutputRegressor(
        estimator=susi.SOMRegressor(n_jobs=2),
        n_jobs=2
    )
    mor.fit(X, y)
github felixriese / susi / tests / test_SOMClassifier.py View on Github external
def test_fit(train_mode_unsupervised, train_mode_supervised):
    som = susi.SOMClassifier(
        n_rows=8,
        n_columns=8,
        train_mode_unsupervised=train_mode_unsupervised,
        train_mode_supervised=train_mode_supervised,
        random_state=3)
    som.fit(X_train, y_train)
    assert(som.score(X_test, y_test) >= 0.8)
github felixriese / susi / tests / test_SOMClassifier.py View on Github external
def test_fit_semi(train_mode_unsupervised, train_mode_supervised):
    som = susi.SOMClassifier(
        n_rows=5,
        n_columns=5,
        train_mode_unsupervised=train_mode_unsupervised,
        train_mode_supervised=train_mode_supervised,
        missing_label_placeholder=-1,
        random_state=3)
    som.fit(X_train, y_train_semi)
    assert(som.score(X_test, y_test) > 0.5)
github felixriese / susi / tests / test_SOMClustering.py View on Github external
def test_modify_weight_matrix_online(n_rows, n_columns, random_state,
                                     n_iter_unsupervised, X, learningrate,
                                     neighborhood_func, bmu_pos, dp, expected):
    som_clustering = susi.SOMClustering(
        n_rows=n_rows, n_columns=n_columns,
        n_iter_unsupervised=n_iter_unsupervised, random_state=random_state)
    som_clustering.fit(X)
    assert np.allclose(susi.modify_weight_matrix_online(
        som_array=som_clustering.unsuper_som_,
        learningrate=learningrate,
        dist_weight_matrix=som_clustering.get_nbh_distance_weight_matrix(
            neighborhood_func, bmu_pos),
        true_vector=som_clustering.X_[dp]), expected, atol=1e-8)