<jupyter_start><jupyter_text>Model training<jupyter_code>#xgb params
params_final = {'learning_rate': 0.1, 'objective': 'multi:softmax', 'max_depth': 6, 'min_child_weight': 6, 'subsample': 0.8,'num_class':5,'colsample_bytree':0.4,
 'reg_alpha':0.05}<jupyter_output><empty_output><jupyter_text>dmatrix xgboost<jupyter_code>start = time.time()
#train val dmat
xgdmat_train = xgb.DMatrix(X_train, y_train)
xgdmat_val = xgb.DMatrix(X_val, y_val)
#dict
dct = {
    xgdmat_train:'train',
    xgdmat_val:'eval',
    'eval_metric' : 'mlogloss'
}
#eval list
evals=[(xgdmat_train, 'train'), (xgdmat_val, 'valid')]
#training
xgb_final = xgb.train(params_final, xgdmat_train, num_boost_round = 3000,
                      evals=evals,early_stopping_rounds=100,evals_result=dct ,verbose_eval=5)
print(time.time()-start)<jupyter_output><empty_output><jupyter_text>Run for pred and sub<jupyter_code>#test dmat
xgdmat_test = xgb.DMatrix(test)
#predictions on val n train
y_val_pred = xgb_final.predict(xgdmat_val)
y_train_pred = xgb_final.predict(xgdmat_train)
#prediction on test
prediction = xgb_final.predict(xgdmat_test)
#print score
f1sc = f1_score(y_val,y_val_pred,average='weighted')
print('f1 validation score ',f1sc)

f1sc_train = f1_score(y_train,y_train_pred,average='weighted')
print('f1 train score ',f1sc_train)
#modelsave
#make submission csv file 
prediction = np.array(prediction, np.int)
pd.DataFrame(prediction, columns=['prediction']).to_csv('prediction80988.csv')
#save model
xgb_final.save_model("xgbmodel__fe2d")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1368624919302776, 'fraction_numerical': 0.02194964493221433, 'mean_word_length': 8.171597633136095, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '355859', 'license': 'MIT', 'n_tokens_mistral': 647, 'n_tokens_neox': 622, 'n_words': 95, 'path': 'model/Team_Ragrun_cascade_cup.ipynb', 'repo_name': 'rtharungowda/cascade-cup-2020', 'size': '1549'}