コード例 #1
0
def test_compare_model_classification():
    x_train, y_train = make_classification(n_samples=50,
                                           n_features=4,
                                           n_informative=2,
                                           n_redundant=0,
                                           random_state=0,
                                           shuffle=False)
    model_list = [
        RandomForestClassifier(n_estimators=5, max_depth=2, random_state=0),
        GradientBoostingClassifier(n_estimators=5, max_depth=2, random_state=0)
    ]
    fitted_model, model_scores = model.compare_model(model_list, x_train,
                                                     y_train, 'accuracy')
    assert type(fitted_model) is list
    assert type(model_scores) is list
    assert hasattr(fitted_model[0], "predict")
コード例 #2
0
ファイル: test_model.py プロジェクト: tosi-n/datasist
def test_compare_model():
    x_train, y_train = make_classification(
        n_samples=50, 
        n_features=4,
        n_informative=2, 
        n_redundant=0, 
        random_state=0,
        shuffle=False
    )
    model_list = [
        RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0),
        BaggingClassifier(),
        GradientBoostingClassifier()
    ]
    scoring_metrics = ['accuracy']
    fitted_model, model_scores = model.compare_model(model_list, x_train, y_train, True, scoring_metrics)
    assert type(fitted_model) is list
    assert type(model_scores) is list
コード例 #3
0
ファイル: test_model.py プロジェクト: mes-src/featurengine
def test_compare_model_regression():
    x_train, y_train = make_classification(n_samples=50,
                                           n_features=4,
                                           n_informative=2,
                                           n_redundant=0,
                                           random_state=0,
                                           shuffle=False)
    model_list = [
        RandomForestRegressor(n_estimators=5, max_depth=2, random_state=0),
        GradientBoostingRegressor(n_estimators=5, max_depth=2, random_state=0)
    ]
    fitted_model, model_scores = compare_model(model_list,
                                               x_train,
                                               y_train,
                                               'neg_mean_absolute_error',
                                               plot=False)
    assert type(fitted_model) is list
    assert type(model_scores) is list
    assert hasattr(fitted_model[0], "predict")