コード例 #1
0
def _fit_model(population_df, peripheral_df, population_ph, peripheral_ph,
               seed, units):

    # ----------------------------------------------------------------

    predictor = predictors.LinearRegression()

    # ----------------------------------------------------------------

    model = models.RelboostModel(population=population_ph,
                                 peripheral=[peripheral_ph],
                                 loss_function=loss_functions.SquareLoss(),
                                 predictor=predictor,
                                 num_features=10,
                                 max_depth=1,
                                 reg_lambda=0.0,
                                 shrinkage=0.3,
                                 num_threads=1,
                                 seed=seed,
                                 units=units).send()

    # ----------------------------------------------------------------

    model = model.fit(population_table=population_df,
                      peripheral_tables=[peripheral_df])

    # ----------------------------------------------------------------

    features = model.transform(population_table=population_df,
                               peripheral_tables=[peripheral_df])

    # ----------------------------------------------------------------

    yhat = model.predict(population_table=population_df,
                         peripheral_tables=[peripheral_df])

    # ----------------------------------------------------------------

    scores = model.score(population_table=population_df,
                         peripheral_tables=[peripheral_df])

    # ----------------------------------------------------------------

    return model, features, yhat, scores
コード例 #2
0
# GROUP BY t1.join_key,
#          t1.time_stamp;

population_table, peripheral_table = datasets.make_numerical()

population_placeholder = population_table.to_placeholder()
peripheral_placeholder = peripheral_table.to_placeholder()
population_placeholder.join(peripheral_placeholder, "join_key", "time_stamp")

predictor = predictors.LinearRegression()

model = models.RelboostModel(population=population_placeholder,
                             peripheral=[peripheral_placeholder],
                             loss_function=loss_functions.SquareLoss(),
                             predictor=predictor,
                             num_features=10,
                             max_depth=1,
                             reg_lambda=0.0,
                             shrinkage=0.3,
                             num_threads=0).send()

# ----------------

model = model.fit(population_table=population_table,
                  peripheral_tables=[peripheral_table])

# ----------------

features = model.transform(population_table=population_table,
                           peripheral_tables=[peripheral_table])
    n_estimators=100,
    n_jobs=6,
    max_depth=7,
    reg_lambda=500
)

#predictor = predictors.LogisticRegression()

model = models.RelboostModel(
    population=population_placeholder,
    peripheral=[expd_placeholder, memd_placeholder],
    loss_function=loss_functions.CrossEntropyLoss(),
    shrinkage=0.1,
    gamma=0.0,
    min_num_samples=200,
    num_features=20,
    share_selected_features=1.0,
    reg_lambda=0.01,
    sampling_factor=1.0,
    predictor=predictor,
    feature_selector=feature_selector,
    num_threads=4
).send()

# ----------------
# Build a hyperparameter space 

param_space = dict()

param_space['max_depth'] = [3, 10]
param_space['min_num_samples'] = [100, 500]