Exemple #1
0
def test_neurolab_single_classification():
    check_classifier(
        NeurolabClassifier(layers=[], epochs=N_EPOCHS2, trainf=None),
        **classifier_params)
    check_classifier(NeurolabClassifier(layers=[2], epochs=N_EPOCHS2),
                     **classifier_params)
    check_classifier(NeurolabClassifier(layers=[1, 1], epochs=N_EPOCHS2),
                     **classifier_params)
Exemple #2
0
def test_neurolab_classification_types():
    import pandas as pd
    for net_type in rep.estimators.neurolab.NET_TYPES.keys():
        try:
            clf = NeurolabClassifier(net_type=net_type, epochs=2)
            ds = pd.DataFrame()
            ds['feature1'] = [0, 1, 2, 3, 4, 5]
            ds['feature2'] = [5, 7, 2, 4, 7, 9]
            ds['y'] = [0, 0, 0, 1, 1, 1]
            clf.fit(ds[['feature1', 'feature2']] / 10., ds['y'])
            _ = clf.predict_proba(ds[['feature1', 'feature2']] / 10.)
            print(net_type, 'is ok')
        except Exception as e:
            print(net_type, 'FAILED', e)
Exemple #3
0
def test_neurolab_classification_types():
    import pandas as pd
    for net_type in rep.estimators.neurolab.NET_TYPES.keys():
        try:
            clf = NeurolabClassifier(net_type=net_type, epochs=2)
            ds = pd.DataFrame()
            ds['feature1'] = [0, 1, 2, 3, 4, 5]
            ds['feature2'] = [5, 7, 2, 4, 7, 9]
            ds['y'] = [0, 0, 0, 1, 1, 1]
            clf.fit(ds[['feature1', 'feature2']] / 10., ds['y'])
            _ = clf.predict_proba(ds[['feature1', 'feature2']] / 10.)
            print(net_type, 'is ok')
        except Exception as e:
            print(net_type, 'FAILED', e)
Exemple #4
0
def test_neurolab_single_classification():
    check_classifier(NeurolabClassifier(show=0,
                                        layers=[],
                                        epochs=N_EPOCHS2,
                                        trainf=nl.train.train_rprop),
                     supports_weight=False,
                     has_staged_pp=False,
                     has_importances=False)
    check_classifier(NeurolabClassifier(net_type='single-layer',
                                        cn='auto',
                                        show=0,
                                        epochs=N_EPOCHS2,
                                        trainf=nl.train.train_delta),
                     supports_weight=False,
                     has_staged_pp=False,
                     has_importances=False)
Exemple #5
0
def test_neurolab_stacking():
    base_nlab = NeurolabClassifier(show=0,
                                   layers=[],
                                   epochs=N_EPOCHS2,
                                   trainf=nl.train.train_rprop)
    check_classifier(SklearnClassifier(
        clf=BaggingClassifier(base_estimator=base_nlab, n_estimators=3)),
                     supports_weight=False,
                     has_staged_pp=False,
                     has_importances=False)
Exemple #6
0
def test_neurolab_stacking():
    base_nlab = NeurolabClassifier(layers=[],
                                   epochs=N_EPOCHS2 * 2,
                                   trainf=nl.train.train_rprop)
    base_bagging = BaggingClassifier(base_estimator=base_nlab, n_estimators=3)
    check_classifier(SklearnClassifier(clf=base_bagging), **classifier_params)
Exemple #7
0
def test_neurolab_multiclassification():
    check_classifier(NeurolabClassifier(layers=[10],
                                        epochs=N_EPOCHS4,
                                        trainf=nl.train.train_rprop),
                     n_classes=4,
                     **classifier_params)
Exemple #8
0
def test_neurolab_reproducibility():
    clf = NeurolabClassifier(layers=[4, 5], epochs=2, trainf=nl.train.train_gd)
    X, y, _ = generate_classification_data()
    check_classification_reproducibility(clf, X, y)
Exemple #9
0
def test_partial_fit():
    clf = NeurolabClassifier(layers=[4, 5], epochs=2, trainf=nl.train.train_gd)
    X, y, _ = generate_classification_data()
    clf.fit(X, y)
    clf.partial_fit(X[:2], y[:2])
Exemple #10
0
def test_partial_fit():
    clf = NeurolabClassifier(layers=[4, 5], epochs=2, trainf=nl.train.train_gd)
    X, y, _ = generate_classification_data()
    clf.fit(X, y)
    clf.partial_fit(X[:2], y[:2])