How to use the hyperactive.Hyperactive function in hyperactive

To help you get started, we’ve selected a few hyperactive 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 SimonBlanke / Hyperactive / tests / local / _test_performance.py View on Github external
def test_EvolutionStrategy():
    opt0 = Hyperactive(X, y, random_state=random_state)
    opt0.search(
        search_config,
        optimizer="EvolutionStrategy",
        n_iter=n_iter_min,
        init_config=init_config,
    )

    opt1 = Hyperactive(X, y, random_state=random_state)
    opt1.search(
        search_config,
        optimizer="EvolutionStrategy",
        n_iter=n_iter_max,
        init_config=init_config,
    )

    assert opt0.best_scores[model] < opt1.best_scores[model]
github SimonBlanke / Hyperactive / tests / test_memory.py View on Github external
criterion=para["criterion"], max_depth=para["max_depth"]
        )
        scores = cross_val_score(model, X_train, y_train, cv=2)

        return scores.mean()

    search_config = {
        model4: {"criterion": ["gini", "entropy"], "max_depth": range(1, 11)}
    }

    opt1 = Hyperactive(X, y, memory="long")
    opt1.search(search_config)

    best_para = opt1.results[model4]

    opt2 = Hyperactive(X, y, memory="long")
    opt2.search(search_config, n_iter=0, init_config=opt1.results)

    assert best_para == opt2.results[model4]
github SimonBlanke / Hyperactive / tests / local / _test_performance.py View on Github external
def test_HillClimbing():
    opt0 = Hyperactive(X, y, random_state=random_state)
    opt0.search(
        search_config,
        optimizer="HillClimbing",
        n_iter=n_iter_min,
        init_config=init_config,
    )

    opt1 = Hyperactive(X, y, random_state=random_state)
    opt1.search(
        search_config,
        optimizer="HillClimbing",
        n_iter=n_iter_max,
        init_config=init_config,
    )

    assert opt0.best_scores[model] < opt1.best_scores[model]
github SimonBlanke / Hyperactive / tests / _test_hyperactive_api.py View on Github external
def test_memory():
    opt0 = Hyperactive(X, y, memory=True)
    opt0.search(search_config)

    opt1 = Hyperactive(X, y, memory=False)
    opt1.search(search_config)

    opt2 = Hyperactive(X, y, memory="short")
    opt2.search(search_config)

    opt3 = Hyperactive(X, y, memory="long")
    opt3.search(search_config)

    opt4 = Hyperactive(X, y, memory="long")
    opt4.search(search_config)

    opt = Hyperactive(X, y, memory=memory, verbosity=0)
    opt.search(search_config)
github SimonBlanke / Hyperactive / tests / optimizer_parameter / EvolutionStrategy.py View on Github external
def test_crossover_rate():
    for crossover_rate in [0.1, 0.9]:
        opt = Hyperactive(X, y, memory=memory)
        opt.search(
            search_config,
            n_iter=n_iter,
            optimizer={"EvolutionStrategy": {"crossover_rate": crossover_rate}},
        )
github SimonBlanke / Hyperactive / tests / optimizer_parameter / TPE.py View on Github external
def test_warm_start_smbo():
    opt = Hyperactive(X, y, memory="long")
    opt.search(
        search_config, n_iter=n_iter, optimizer={"TPE": {"warm_start_smbo": True}}
    )
github SimonBlanke / Hyperactive / examples / test_functions / himmelblau_function_example.py View on Github external
def himmelblau(para, X, y):
    """Himmelblau's function"""

    return -(
        (para["x"] ** 2 + para["y"] - 11) ** 2 + (para["x"] + para["y"] ** 2 - 7) ** 2
    )


x_range = np.arange(0, 10, 0.1)

search_config = {himmelblau: {"x": x_range, "y": x_range}}


opt = Hyperactive(np.array([0]), np.array([0]))
opt.search(search_config, n_iter=100000)
github SimonBlanke / Hyperactive / examples / examples_v1.x.x / extensions / memory_example.py View on Github external
model = GradientBoostingClassifier(
        n_estimators=para["n_estimators"], max_depth=para["max_depth"]
    )
    scores = cross_val_score(model, X, y, cv=3)

    return scores.mean()


search_config = {model: {"n_estimators": range(10, 200, 10), "max_depth": range(2, 15)}}

"""
The memory will remember previous evaluations done during the optimization process.
Instead of retraining the model, it accesses the memory and uses the saved score/loss.
This shows as a speed up during the optimization process, since the whole search space has been explored.
"""
opt = Hyperactive(search_config, n_iter=1000, memory=True)

# search best hyperparameter for given data
opt.search(X, y)
github SimonBlanke / Hyperactive / docs / examples / meta_opt_example.py View on Github external
}
    }

    opt = Hyperactive(search_config, optimizer={"StochasticHillClimbing": {"r": para["r"]}})
    opt.search(X, y)

    return score


search_config = {
    meta_opt: {
        "r": np.arange(0, 10, 0.1),
    }
}

opt = Hyperactive(search_config, optimizer="Bayesian", n_iter=3)
opt.search(X, y)
github SimonBlanke / Hyperactive / examples / use_cases / SklearnPreprocessing.py View on Github external
return scores.mean()


search_config = {
    model: {
        "decomposition": [pca, none],
        "k": range(2, 30),
        "n_components": range(1, 11),
        "n_estimators": range(10, 100, 3),
        "max_depth": range(2, 12),
    }
}


opt = Hyperactive(X, y, memory="short")
opt.search(search_config, n_iter=100)