Exemplo n.º 1
0
def test_get_model_metrics_ensemble():
    boston_train_X, boston_test_X, boston_train_y, boston_test_y = dataset_split(
        boston_dataset, boston_label)
    model = LinearRegression()
    model.fit(boston_train_X, boston_train_y)
    assert check(get_model_metrics_ensemble, [], 'prediction', boston_test_y,
                 model.predict(boston_test_X))
    diabetes_train_X, diabetes_test_X, diabetes_train_y, diabetes_test_y = dataset_split(
        diabetes_dataset, diabetes_label)
    model = LogisticRegression()
    model.fit(diabetes_train_X, diabetes_train_y)
    assert check(get_model_metrics_ensemble, [0, 1], 'classification',
                 diabetes_test_y, model.predict(diabetes_test_X))
Exemplo n.º 2
0
 def test_func(meta_model, new_models):
     meta_model = meta_model or 'RandomForestClassifier'
     super_learner_obj = SuperLearnerClassifier(meta_model=meta_model)
     if new_models:
         super_learner_obj.add_models(new_models)
     diabetes_train_X, diabetes_test_X, diabetes_train_y, diabetes_test_y = dataset_split(
         diabetes_dataset, diabetes_label)
     super_learner_obj.fit(diabetes_train_X, diabetes_train_y)
     super_learner_obj.predict(diabetes_test_X)
Exemplo n.º 3
0
 def test_func(meta_model, new_models):
     meta_model = meta_model or 'RandomForestRegressor'
     super_learner_obj = SuperLearnerRegressor(meta_model=meta_model)
     if new_models:
         super_learner_obj.add_models(new_models)
     boston_train_X, boston_test_X, boston_train_y, boston_test_y = dataset_split(
         boston_dataset, boston_label)
     super_learner_obj.fit(boston_train_X, boston_train_y)
     super_learner_obj.predict(boston_test_X)
Exemplo n.º 4
0
from auto_machine_learning.hyperparameter_optimization.hpo_methods import *
from auto_machine_learning.data_preprocessing.preprocessing import dataset_split
from auto_machine_learning.utils import check
from auto_machine_learning.datasets.load_dataset import load_dataset
from sklearn.linear_model import LinearRegression, Ridge, Lasso, LogisticRegression
from sklearn.ensemble import RandomForestClassifier
import warnings

warnings.filterwarnings('ignore')
boston_dataset, boston_label = load_dataset('boston')
diabetes_dataset, diabetes_label = load_dataset('diabetes')
boston_X_train, boston_X_test, boston_y_train, boston_y_test = dataset_split(
    boston_dataset, boston_label)
diabetes_X_train, diabetes_X_test, diabetes_y_train, diabetes_y_test = dataset_split(
    diabetes_dataset, diabetes_label)


def test_grid_search():
    for model in [LinearRegression, Lasso, Ridge]:
        # grid_search(boston_dataset, boston_label, model)
        assert check(grid_search, model, boston_X_train, boston_y_train)
    for model in [LogisticRegression, RandomForestClassifier]:
        assert check(grid_search, model, diabetes_X_train, diabetes_y_train)


def test_random_search():
    for model in [LinearRegression, Lasso, Ridge]:
        assert check(random_search, model, boston_X_train, boston_y_train)
    for model in [LogisticRegression, RandomForestClassifier]:
        assert check(random_search, model, diabetes_X_train, diabetes_y_train)