Beispiel #1
0
train_model_input = {name: train_X[name].values for name in get_feature_names(feature_columns)}
print("########################################")

# histroy输入必须是二维数组
from tqdm import tqdm

for fea in ['hist_merchant_id', 'hist_action_type']:
    list = []
    for i in tqdm(train_model_input[fea]):
        list.append(i)
    train_model_input[fea] = np.array(list)

history = model.fit(train_model_input, train_y.values, verbose=True, epochs=10, validation_split=0.2, batch_size=512)

# 转换test__model_input
test_data['action_type'] = 3
test_model_input = {name: test_data[name].values for name in feature_names}
from tqdm import tqdm

for fea in ['hist_merchant_id', 'hist_action_type']:
    list = []
    for i in tqdm(test_model_input[fea]):
        list.append(i)
    test_model_input[fea] = np.array(list)

# 得到预测结果
prob = model.predict(test_model_input)
submission['prob'] = prob
submission.drop(['origin'], axis=1, inplace=True)
submission.to_csv('prediction.csv', index=False)
Beispiel #2
0
                att_activation='dice',
                att_weight_normalization=False,
                hist_len_max=sess_len_max,
                dnn_hidden_units=(200, 80),
                att_hidden_size=(
                    64,
                    16,
                ),
                l2_reg_embedding=REG,
                seed=2019)

    model.compile('adagrad',
                  'binary_crossentropy',
                  metrics=[
                      'binary_crossentropy',
                  ])

    hist_ = model.fit(
        train_input[:],
        train_label,
        batch_size=BATCH_SIZE,
        epochs=1,
        initial_epoch=0,
        verbose=1,
    )
    pred_ans = model.predict(test_input, TEST_BATCH_SIZE)

    print()
    print("test LogLoss", round(log_loss(test_label, pred_ans), 4), "test AUC",
          round(roc_auc_score(test_label, pred_ans), 4))