Exemplo n.º 1
0
 def test_save_summary(self):
     with self.assertRaises(ValueError):
         grid = {
             "sigma": np.arange(2, 3, 2),
             "prototypes_per_class": np.arange(2, 3, 2)
         }
         gs = GridSearch(clf=RRSLVQ(), grid=grid, max_samples=300)
         gs.save_summary()
Exemplo n.º 2
0
def test_parameter_grid_search_arslvq():
    grid = {
        "sigma": np.append(1, np.arange(2, 11, 2)),
        "prototypes_per_class": np.append(1, np.arange(2, 11, 2)),
        "gamma": np.array([0.7, 0.9, 0.999]),
        "confidence": np.array([0.01, 0.001]),
        "window_size": np.array([100, 200, 300, 800])
    }
    clf = ARSLVQ()
    gs = GridSearch(clf=clf, grid=grid, max_samples=50000)
    gs.streams = gs.init_real_world() + gs.init_standard_streams(
    ) + gs.init_reoccuring_standard_streams()
    gs.search()
    gs.save_summary()
Exemplo n.º 3
0
def test_parameter_grid_search_arslvq():
    grid = {
        "sigma": np.arange(2, 11, 2),
        "prototypes_per_class": np.arange(2, 11, 2)
    }
    clf = ARSLVQ(gradient_descent="Adadelta")
    gs = GridSearch(clf=clf, grid=grid, max_samples=50000)
    gs.search()
    gs.save_summary()
Exemplo n.º 4
0
def test_parameter_grid_search_rslvq():
    grid = {
        "sigma": np.arange(2, 11, 2),
        "prototypes_per_class": np.arange(2, 11, 2)
    }
    clf = RSLVQ()
    gs = GridSearch(clf=clf, grid=grid, max_samples=50000)
    gs.search()
    gs.save_summary()
Exemplo n.º 5
0
 def test_grid_search(self):
     grid = {
         "sigma": np.arange(2, 3, 2),
         "prototypes_per_class": np.arange(2, 3, 2)
     }
     gs = GridSearch(clf=RRSLVQ(), grid=grid, max_samples=300)
     gs.search()
     gs.save_summary()
     self.assertIsNotNone(gs.best_runs)
Exemplo n.º 6
0
def test_gridsearch_via_cv():
    grid = {
        "sigma": np.append(1, np.arange(2, 11, 2)),
        "prototypes_per_class": np.append(1, np.arange(2, 11, 2)),
        "gamma": np.array([0.7, 0.9, 0.999]),
        "confidence": np.array([0.01, 0.001]),
        "window_size": np.array([100, 200, 300, 800])
    }
    grid = {
        "sigma": np.append(1, np.arange(2, 3, 2)),
        "prototypes_per_class": np.append(1, np.arange(2, 3, 2))
    }

    clf = ARSLVQ()
    cv = GridSearch([clf], max_samples=500)
    cv.streams = cv.init_standard_streams()
    cv.parameter_grid_search(grid)
Exemplo n.º 7
0
def test_missing_streams():
    grid = {
        "sigma": np.append(1, np.arange(2, 11, 2)),
        "prototypes_per_class": np.append(1, np.arange(2, 11, 2)),
        "gamma": np.array([0.7, 0.9, 0.999]),
        "confidence": np.array([0.01, 0.001]),
        "window_size": np.array([800])
    }
    clf = ARSLVQ()
    led_a = ConceptDriftStream(
        stream=LEDGeneratorDrift(has_noise=False,
                                 noise_percentage=0.0,
                                 n_drift_features=3),
        drift_stream=LEDGeneratorDrift(has_noise=False,
                                       noise_percentage=0.0,
                                       n_drift_features=7),
        random_state=None,
        alpha=90.0,  # angle of change grade 0 - 90
        position=250000,
        width=1)

    led_a.name = "led_a"
    led_g = ConceptDriftStream(stream=LEDGeneratorDrift(has_noise=False,
                                                        noise_percentage=0.0,
                                                        n_drift_features=3),
                               drift_stream=LEDGeneratorDrift(
                                   has_noise=False,
                                   noise_percentage=0.0,
                                   n_drift_features=7),
                               random_state=None,
                               position=250000,
                               width=50000)
    led_g.name = "led_g"
    led_fa = ReoccuringDriftStream(
        stream=LEDGeneratorDrift(has_noise=False,
                                 noise_percentage=0.0,
                                 n_drift_features=3),
        drift_stream=LEDGeneratorDrift(has_noise=False,
                                       noise_percentage=0.0,
                                       n_drift_features=7),
        random_state=None,
        alpha=90.0,  # angle of change grade 0 - 90
        position=2000,
        width=1)

    led_fg = ReoccuringDriftStream(
        stream=LEDGeneratorDrift(has_noise=False,
                                 noise_percentage=0.0,
                                 n_drift_features=3),
        drift_stream=LEDGeneratorDrift(has_noise=False,
                                       noise_percentage=0.0,
                                       n_drift_features=7),
        random_state=None,
        position=2000,
        width=1000)
    covertype = FileStream(os.path.realpath('covtype.csv'))  # Label failure
    covertype.name = "covertype"
    poker = FileStream(os.path.realpath('poker.csv'))  # label failure
    poker.name = "poker"
    airlines = FileStream(os.path.realpath('airlines.csv'))
    airlines.name = "airport"
    gs = GridSearch(clf=clf, grid=grid, max_samples=50000)

    gs.streams = [led_a, led_g, led_fa, led_fg, covertype, poker, airlines]
    gs.search()
    gs.save_summary()