예제 #1
0
    model.fit(train_loader)
    toc = time.time()
    training_time = toc - tic

    tic = time.time()
    testing_mse = model.predict(test_loader)
    toc = time.time()
    evaluating_time = toc - tic

    records.append(
        ('BaggingRegressor', training_time, evaluating_time, testing_mse))

    # GradientBoostingRegressor
    model = GradientBoostingRegressor(estimator=MLP,
                                      n_estimators=n_estimators,
                                      output_dim=output_dim,
                                      lr=lr,
                                      weight_decay=weight_decay,
                                      epochs=epochs)

    tic = time.time()
    model.fit(train_loader)
    toc = time.time()
    training_time = toc - tic

    tic = time.time()
    testing_mse = model.predict(test_loader)
    toc = time.time()
    evaluating_time = toc - tic

    records.append(('GradientBoostingRegressor', training_time,
                    evaluating_time, testing_mse))
    tic = time.time()
    model.fit(train_loader, epochs=epochs)
    toc = time.time()
    training_time = toc - tic

    tic = time.time()
    testing_mse = model.predict(test_loader)
    toc = time.time()
    evaluating_time = toc - tic

    records.append(
        ("BaggingRegressor", training_time, evaluating_time, testing_mse))

    # GradientBoostingRegressor
    model = GradientBoostingRegressor(estimator=MLP,
                                      n_estimators=n_estimators,
                                      cuda=True)

    # Set the optimizer
    model.set_optimizer("Adam", lr=lr, weight_decay=weight_decay)

    tic = time.time()
    model.fit(train_loader, epochs=epochs)
    toc = time.time()
    training_time = toc - tic

    tic = time.time()
    testing_mse = model.predict(test_loader)
    toc = time.time()
    evaluating_time = toc - tic