Kaggle competition: Toxic Comment Classification Challenge
<SOS> metric: MCAUC Kaggle data source: toxic-comment-classification-challenge<load_from_csv>
nbsvm = '.. /input/nbsvm/submissionNBSVM.csv'
tfidflr = '.. /input/tfidf-and-lr/word_submission.csv'
train_features = pd.read_csv('/kaggle/input/lish-moa/train_features.csv')
 non_ctl_idx = train_features.loc[train_features['cp_type']!='ctl_vehicle'].index.to_list()
train_features = train_features.drop(['sig_id','cp_type'],axis=1)
 train_targets_scored = pd.read_csv('/kaggle/input/lish-moa/train_targets_scored.csv')
 train_targets_scored = train_targets_scored.drop('sig_id',axis=1)
 labels_train = train_targets_scored.values
train_features = train_features.iloc[non_ctl_idx]
labels_train = labels_train[non_ctl_idx]
test_features = pd.read_csv('/kaggle/input/lish-moa/test_features.csv')
 test_features = test_features.drop(['sig_id'],axis=1 )<categorify>
p_nbsvm = pd.read_csv(nbsvm)
 p_tfidflr = pd.read_csv(tfidflr )
cat = 'cp_dose'
le = preprocessing.LabelEncoder()
le.fit(train_features[cat])
 train_features[cat] = le.transform(train_features[cat])
 test_features[cat] = le.transform(test_features[cat] )<normalization>
label_cols = ['toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
p_res = p_nbsvm.copy()
p_res[label_cols] =(p_tfidflr[label_cols] + p_nbsvm[label_cols])/ 2
scaler = preprocessing.QuantileTransformer(output_distribution='normal')
 data_train = scaler.fit_transform(train_features.iloc[:,2:])
 data_test = scaler.transform(test_features.drop('cp_type',axis=1 ).iloc[:,2:])
 scaler = preprocessing.StandardScaler()
data_train = np.concatenate(( scaler.fit_transform(train_features.iloc[:,:2]),data_train),axis=1)
 data_test = np.concatenate(( scaler.transform(test_features.drop('cp_type',axis=1 ).iloc[:,:2]),data_test),axis=1 )<define_variables>
p_res2 = p_nbsvm.copy()
for i, j in enumerate(p_res2):
if j == 'id':
continue
temp_df = pd.concat([p_tfidflr[j], p_nbsvm[j]], axis=1)
 print(temp_df.head())
 p_res2[j] = temp_df.apply(max, axis=1 )
n_features = data_train.shape[1]
n_labels = labels_train.shape[1]
n_train = data_train.shape[0]
n_test = data_test.shape[0]<categorify>
p_res3 = p_nbsvm.copy()
for i, j in enumerate(p_res2):
if j == 'id':
continue
temp_df = pd.concat([p_tfidflr[j], p_nbsvm[j]], axis=1)
 print(temp_df.head())
 p_res3[j] = temp_df.apply(lambda r: np.max(r)if np.mean(r)> 0.5 else np.mean(r), axis=1)
 p_res3.head()
<categorify><EOS> 
p_res.to_csv('submissionAvg.csv', index=False)
 p_res2.to_csv('submissionMax.csv', index=False)
 p_res3.to_csv('submissionCondMax.csv', index=False )