def test_sample_server():
    pop = DistributedPopulation(XgboostIndividual,
                                size=100,
                                additional_parameters={'kfold': 3},
                                maximize=False,
                                host='localhost',
                                user='******',
                                password='******')
    ga = GeneticAlgorithm(pop)
    ga.run(10)
Beispiel #2
0
def test_california_housing_xgb():
    data = fetch_california_housing()
    y_train = data.target
    x_train = data.data

    model = XgboostModel(x_train, y_train, kfold=3, num_boost_round=10)

    pop = Population(
        XgboostIndividual, x_train, y_train, size=5,
        additional_parameters={'model': model},
        maximize=False
    )
    ga = GeneticAlgorithm(pop)
    ga.run(3)
Beispiel #3
0
def test_california_housing_xgb_grid():
    data = fetch_california_housing()
    y_train = data.target
    x_train = data.data

    grid = {
        'eta': [0.1, 0.2],
        'max_depth': range(3, 5),
        'colsample_bytree': [0.80, 0.85],
    }

    model = XgboostModel(x_train, y_train, kfold=3, num_boost_round=10)

    pop = GridPopulation(
        XgboostIndividual, x_train, y_train, genes_grid=grid,
        additional_parameters={'model': model}, maximize=False
    )
    ga = GeneticAlgorithm(pop)
    ga.run(3)
Beispiel #4
0
#!/usr/bin/env python
"""
Test the genetic algorithm on a single machine over the
California Housing data using a random population.
"""

import os
import sys

sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

if __name__ == '__main__':
    from sklearn.datasets import fetch_california_housing
    from gentun import GeneticAlgorithm, Population, XgboostIndividual

    data = fetch_california_housing()
    y_train = data.target
    x_train = data.data

    pop = Population(XgboostIndividual,
                     x_train,
                     y_train,
                     size=100,
                     additional_parameters={'kfold': 3},
                     maximize=False)
    ga = GeneticAlgorithm(pop)
    ga.run(10)