Kaggle competition: Toxic Comment Classification Challenge
class MoADataset:
def __init__(self, features, targets):
self.features = features
self.targets = targets
def __len__(self):
return self.features.shape[0]
def __getitem__(self, idx):
return {
'input': torch.tensor(self.features[idx, :], dtype=torch.float),
'target': torch.tensor(self.targets[idx, :], dtype=torch.float)
 }
class TestDataset:
def __init__(self, features):
self.features = features
def __len__(self):
return self.features.shape[0]
def __getitem__(self, idx):
return {
'input': torch.tensor(self.features[idx, :], dtype=torch.float)
 }<import_modules>
f_attn_bi = '.. /input/module-12-attn-bi/10fold_attn_post_am(1 ).csv'
f_dpcnn = '.. /input/module-10-dpcnn/10fold_dpcnn_test(1 ).csv'
f_nbsvm = '.. /input/module-1-nbsvm/Module_1_submission.csv'
f_bilstm_f_pl = '.. /input/module-2-bilstm-f-pl/Module_2_submission.csv'
f_capsule_gru = '.. /input/module-7-capsule-gru/Module_7_submission.csv'
f_mish = '.. /input/module-6-mish/Mish_submission.csv'
f_bilstm_g_tta = '.. /input/module-3-bilstm-g-tta/Module_3_submission.csv'
f_capsule = '.. /input/module-11-capsule/10fold_capsule_am.csv'
f_dmcnn = '.. /input/module-9-dmcnn/10fold_dmcnn_am.csv'
f_bilstm_f = '.. /input/module-13-bilstm-f/Module_13_submission.csv'
f_dehyp = '.. /input/module-4-dehyph/Module_4_submission.csv'
f_bilstm_duembd_pl = '.. /input/module-5-bi-lstm-duembd-pl/Module_5_submission.csv'
f_bilstm_pp = '.. /input/module-8-bi-lstm-pp/10fold_lstmpp_am(1 ).csv'
import torch
import torch.nn as nn
import torch.nn.functional as F<normalization>
p_attn_bi = pd.read_csv(f_attn_bi)
 p_dpcnn = pd.read_csv(f_dpcnn)
 p_nbsvm = pd.read_csv(f_nbsvm)
 p_bilstm_f_pl = pd.read_csv(f_bilstm_f_pl)
 p_capsule_gru = pd.read_csv(f_capsule_gru)
 p_mish = pd.read_csv(f_mish)
 p_bilstm_g_tta = pd.read_csv(f_bilstm_g_tta)
 p_capsule = pd.read_csv(f_capsule)
 p_bilstm_f = pd.read_csv(f_bilstm_f)
 p_dmcnn = pd.read_csv(f_dmcnn)
 p_dehyp = pd.read_csv(f_dehyp)
 p_bilstm_duembd_pl = pd.read_csv(f_bilstm_duembd_pl)
 p_bilstm_pp = pd.read_csv(f_bilstm_pp )
class Model(nn.Module):
def __init__(self, num_features, num_targets, hidden_size):
super(Model, self ).__init__()
self.batch_norm1 = nn.BatchNorm1d(num_features)
 self.dropout1 = nn.Dropout(0.2)
 self.dense1 = nn.utils.weight_norm(nn.Linear(num_features, hidden_size))
self.batch_norm2 = nn.BatchNorm1d(hidden_size)
 self.dropout2 = nn.Dropout(0.2)
 self.dense2 = nn.utils.weight_norm(nn.Linear(hidden_size, hidden_size))
self.batch_norm3 = nn.BatchNorm1d(hidden_size)
 self.dropout3 = nn.Dropout(0.2)
 self.dense3 = nn.utils.weight_norm(nn.Linear(hidden_size, num_targets))
device = 'cuda' if torch.cuda.is_available() else 'cpu'
self.weight = torch.tensor([0.5] ).to(device)
 def forward(self, x):
x = self.batch_norm1(x)
 x = self.dropout1(x)
 x = F.prelu(self.dense1(x), self.weight)
 x = self.batch_norm2(x)
 x = self.dropout2(x)
 x = F.prelu(self.dense2(x), self.weight)
 x = self.batch_norm3(x)
 x = self.dropout3(x)
 x = self.dense3(x)
 return x<define_variables>
label_cols = ['toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
p_res = p_attn_bi.copy()
p_res[label_cols] =(p_attn_bi[label_cols] + p_dpcnn[label_cols] + p_nbsvm[label_cols] + p_bilstm_f_pl[label_cols] + p_capsule_gru[label_cols] + p_mish[label_cols] + p_bilstm_g_tta[label_cols] +(p_capsule[label_cols] * 3)+ p_bilstm_f[label_cols] + p_dmcnn[label_cols] + p_dehyp[label_cols] + p_bilstm_duembd_pl[label_cols] + p_bilstm_pp[label_cols])/ 15
<set_options><EOS> 
p_res.to_csv('submission.csv', index=False )