Kaggle competition: DonorsChoose.org Application Screening
<SOS> metric: AUC Kaggle data source: donorschoose.org-application-screening<define_variables>
import copy
import gc
import re
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
siamese_learning_rate = 1e-5
automl_num_monte_carlo = 3
final_num_monte_carlo = 10
max_iters_of_cls = 60000
dataset_dir = '/kaggle/input/jigsaw-multilingual-toxic-comment-classification'
tmp_roberta_name = '/kaggle/working/siamese_xlmr.h5'
tmp_cls_name = '/kaggle/working/bayesian_cls.h5'<load_pretrained>
train = pd.read_csv(".. /input/donorschoose-application-screening/train.csv")
 test = pd.read_csv(".. /input/donorschoose-application-screening/test.csv")
 train["set"] = "train"
test["set"] = "test"
data = pd.concat([train, test] ).reset_index(drop=True)
 assert train.shape[0] + test.shape[0] == data.shape[0]
del train, test
gc.collect() ;
xlmroberta_tokenizer = AutoTokenizer.from_pretrained(model_name)
 xlmroberta_config = XLMRobertaConfig.from_pretrained(model_name)
 print(xlmroberta_config )<define_variables>
def clean_data(data, lower=True, initial_filters=r"[^a-z0-9!@

 data = copy.deepcopy(data)
 if lower:
data = data.str.lower()
if initial_filters is not None:
data = data.str.replace(initial_filters, ' ')
 if remove_repetitions:
pattern = re.compile(r" (.) \1{2,}", re.DOTALL)
 data = data.str.replace(pattern, r"\1")
 data = data.str.replace(r"[^a-z' ]", ' ')
 return data.str.split().str.join(" " )
sentence_embedding_size = xlmroberta_config.hidden_size
print('Sentence embedding size is {0}'.format(sentence_embedding_size))
assert max_seq_len <= xlmroberta_config.max_position_embeddings
hidden_layer_of_cls = sentence_embedding_size<load_from_csv>
data = data.fillna(" ")
 cols_to_drop = list(set(data.columns)- set(["id", "project_is_approved", "set"]))
data["application_text"] = data["project_title"].str.cat([data["project_essay_%d"%(i+1)] for i in range(4)] + [data["project_resource_summary"]], sep=" ")
 data.drop(cols_to_drop, axis=1, inplace=True)
 data.application_text = clean_data(data.application_text,
initial_filters=r"[^a-z0-9!@
corpus_for_training = load_train_set(
 os.path.join(dataset_dir, "jigsaw-toxic-comment-train.csv"),
text_field="comment_text", lang_field="lang",
sentiment_fields=["toxic", "severe_toxic", "obscene", "threat", "insult",
"identity_hate"] 
)
 assert 'en' in corpus_for_training<randomize_order>
<load_from_csv><EOS> 
LABELS = ["project_is_approved"]
base = ".. /input/donorschooseorg-application-screening-predictions/predictions/predictions/"
predict_list = []
for i in range(1,3):
for j in range(10):
predict_list.append(np.load(base + "predictions_%03d/test_predicts%d.npy"%(i, j)))
 print(len(predict_list))
predcitions = np.zeros_like(predict_list[0])
 for predict in predict_list:
predcitions = np.add(predcitions.flatten() , rankdata(predict)/predcitions.shape[0])
 predcitions /= len(predict_list)
 submission = pd.read_csv('.. /input/donorschoose-application-screening/sample_submission.csv')
 submission[LABELS] = predcitions
submission.to_csv('submission.csv', index=False )