Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(
        description='Ensembling HyperSpace models')
    parser.add_argument('--results_dir',
                        type=str,
                        help='Path to results directory.')
    args = parser.parse_args()

    results = load_results(args.results_dir)

    clfs = []
    for _ in results:
        # Use default random forest for each of the ensemble models
        model = RandomForestClassifier()
        clfs.append(model)

    # Using the training and test sets from `optimize.py`
    X_train, _, X_test, y_train, _, y_test = load_data(0.25, 0.25)
    y_preds, y_proba = ensemble(clfs, X_train, y_train, X_test, y_test)

    acc_test = accuracy_score(y_test, y_preds)
    ll_test = log_loss(y_test, y_proba)

    print(
        f'\nEnsemble Test Accuracy: {acc_test:.4f}, Test Log Loss: {ll_test:.4f}'
    )
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Ensembling HyperSpace models')
    parser.add_argument('--results_dir',
                        type=str,
                        help='Path to results directory.')
    args = parser.parse_args()

    results = load_results(args.results_dir)

    clfs = []
    for result in results:
        # Get domain from best model in each hyperspace
        hyperparams = result.x
        n_estimators = hyperparams[0]
        max_depth = hyperparams[1]
        model = RandomForestClassifier(n_estimators=n_estimators,
                                       max_depth=max_depth)
        clfs.append(model)

    # Using the training and test sets from `optimize.py`
    X_train, _, X_test, y_train, _, y_test = load_data(0.25, 0.25)
    y_preds, y_proba = ensemble(clfs, X_train, y_train, X_test, y_test)

    acc_test = accuracy_score(y_test, y_preds)
    ll_test = log_loss(y_test, y_proba)

    print(
        f'\nEnsemble Test Accuracy: {acc_test:.4f}, Test Log Loss: {ll_test:.4f}'
    )