Exemple #1
0
def test_automl_default_classification():
    for data_id in [
            179,
            4135,
    ]:
        dataset = fetch_openml(data_id=data_id, as_frame=True)
        dataset.target = dataset.target.astype('category').cat.codes
        if len(dataset.data) < 2000:
            crop = len(dataset.data)
        else:
            crop = 2000
        X_train, X_test, y_train, y_test = train_test_split(
            dataset.data[:crop],
            dataset.target[:crop],
            test_size=0.2,
            random_state=RANDOM_SEED,
        )
        model = AutoMLClassifier(random_state=RANDOM_SEED, )
        model.fit(X_train, y_train, timeout=600)
        predicts = model.predict(X_test)

        score = round(sklearn.metrics.roc_auc_score(y_test, predicts), 4)
        assert score is not None
        assert 0.5 < score <= 1

        model.save('AutoML_model_1', folder=TMP_FOLDER)
        model_new = AutoMLClassifier(random_state=RANDOM_SEED, )
        model_new = model_new.load('AutoML_model_1', folder=TMP_FOLDER)
        predicts = model_new.predict(X_test)
        score2 = round(sklearn.metrics.roc_auc_score(y_test, predicts), 4)
        assert score2 is not None
        assert 0.5 < score2 <= 1
        assert (score - score2) == 0.
Exemple #2
0
def load_model(model_name, folder):
    model = AutoMLClassifier()
    model = model.load(model_name, folder=folder)
    return(model)