<jupyter_start><jupyter_text>pos_train = X_train[X_train['is_duplicate'] == 1]neg_train = X_train[X_train['is_duplicate'] == 0]p = 0.165scale = ((len(pos_train) / (len(pos_train) + len(neg_train))) / p) - 1while scale > 1:    neg_train = pd.concat([neg_train, neg_train])    scale -=1neg_train = pd.concat([neg_train, neg_train[:int(scale * len(neg_train))]])X_train2 = pd.concat([pos_train, neg_train])<jupyter_code>def kappa(preds, y):
    score = []
    a = 0.165 / 0.37
    b = (1 - 0.165) / (1 - 0.37)
    for pp,yy in zip(preds, y.get_label()):
        score.append(a * yy * np.log (pp) + b * (1 - yy) * np.log(1-pp))
    score = -np.sum(score) / len(score)
    return 'kappa', score

params = {
    'seed': 1337,
    'colsample_bytree': 0.7,
    'silent': 1,
    'subsample': 0.7,
    'eta': 0.05,
    'objective': 'binary:logistic',
    'eval_metric': 'logloss',
    'max_depth': 4,
    'min_child_weight': 1,
    'nthread': 6,
    }

X_tr, X_val, y_tr, y_val = train_test_split(X_train2.iloc[:, 8:], X_train2['is_duplicate'], 
                                            test_size = 0.2, random_state = 111)

dtrain = xgb.DMatrix(X_tr, label = y_tr)
dval = xgb.DMatrix(X_val, label = y_val)
watchlist = [(dtrain, 'train'), (dval, 'valid')]

bst = xgb.train(params, dtrain, 100000, watchlist, early_stopping_rounds=100, verbose_eval=50)
#                feval = kappa)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17852062588904694, 'fraction_numerical': 0.044096728307254626, 'mean_word_length': 3.2507552870090635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '513306', 'license': 'MIT', 'n_tokens_mistral': 616, 'n_tokens_neox': 570, 'n_words': 107, 'path': 'models/.ipynb_checkpoints/19.04 - XGB Debugging-checkpoint.ipynb', 'repo_name': 'susantamoh84/Kaggle-Quora', 'size': '1406'}