Kaggle competition: Jigsaw Multilingual Toxic Comment Classification
<SOS> metric: AUC Kaggle data source: jigsaw-multilingual-toxic-comment-classification<prepare_x_and_y>
!git clone https://github.com/henrique/jigsaw20.git
sys.path.append('/kaggle/working/jigsaw20' )
@timeit
def prep_lgbm_data(self):
self.dtrain = lgb.Dataset(
 self.X_train.values, self.y_train,
feature_name = self.selected_variables,
categorical_feature = self.categorical_columns,
free_raw_data = False)
 self.dvalid = lgb.Dataset(
 self.X_valid.values, self.y_valid,
feature_name = self.selected_variables,
categorical_feature = self.categorical_columns,
free_raw_data = False)
 self.dvalid.params = {'extra_time': self.t_valid.factorize() [0]}
two_sigma_model.prep_lgbm_data = prep_lgbm_data.__get__(two_sigma_model)
 two_sigma_model.prep_lgbm_data()<compute_test_metric>
params = dict(
 pooling='first',
optimizer='LAMB',
batch_size=27,
lr=0.000277952,
mom_min=0.806579,
mom_max=0.922184,
div_factor=55.477,
final_div_factor=1123.49,
weight_decay=7.72285e-06,
dropout=0.4,
loss_fn='bce',
label_smoothing=0.0483175,
warm_up=1.2361,
epochs=41,
steps_per_epoch=250,
dataset='.. /input/jigsaw20-ds-tt6-36/jigsaw20_ds1789117tt6_fold5.npz',
path=f'jigsaw',
tpu_id=None, gcs=None,
seed=1083, 
)
def sigma_score(preds, valid_data):
df_time = valid_data.params['extra_time']
labels = valid_data.get_label()
val = pd.DataFrame()
val['time'] = df_time
val['y'] = preds * labels.values
output = val.groupby('time' ).sum()
score = output['y'].mean() / output['y'].std()
return 'sigma_score', score, True<drop_column>
!rm -r jigsaw20
def clean_frames(self):
del self.merged_df
two_sigma_model.clean_frames = clean_frames.__get__(two_sigma_model)
 two_sigma_model.clean_frames()<set_options>
pd.read_csv('params0.965669.csv' ).T
gc.collect()
show_mem_usage()<train_model>
sub = pd.read_csv('submission.csv')
 test = pd.read_csv('.. /input/jigsaw-multilingual-toxic-comment-classification/test.csv')
 sub.loc[test["lang"] == "es", "toxic"] *= 1.06
sub.loc[test["lang"] == "fr", "toxic"] *= 1.04
sub.loc[test["lang"] == "it", "toxic"] *= 0.97
sub.loc[test["lang"] == "pt", "toxic"] *= 0.96
sub.loc[test["lang"] == "tr", "toxic"] *= 0.98
sub.toxic -= sub.toxic.min()
sub.toxic /= sub.toxic.max()
sub.toxic.hist(bins=100, log=True, alpha=0.6)
 sub.to_csv('submission0.csv', index=False )
<categorify><EOS> 
ensemble = pd.read_csv('.. /input/jigsaw20xiwuhanjmtc2ndplacesolution/submission.csv')
 ensemble.toxic -= ensemble.toxic.min()
ensemble.toxic /= ensemble.toxic.max()
ensemble.toxic.hist(bins=100, log=True, alpha=0.6)
 sub.toxic.hist(bins=100, log=True, alpha=0.6)
 ensemble.toxic = ensemble.toxic * 0.8 + sub.toxic * 0.2
ensemble.to_csv('submission.csv', index=False )