Kaggle competition: Toxic Comment Classification Challenge
<SOS> metric: MCAUC Kaggle data source: toxic-comment-classification-challenge<create_dataframe>
f_lstm = '.. /input/lstm-glove-lr-decrease-bn-cv-lb-0-047/LSTM-submission.csv'
f_nbsvm = '.. /input/nb-svm-strong-linear-baseline-eda-0-052-lb/submission.csv'
f_eaf = '.. /input/easy-and-fast-lb-044/feat_lr_2cols.csv'
f_tfidf = '.. /input/word-character-n-grams-tfidf-regressions-lb-051/output.csv'
def agg_numeric(df, group_var, df_name):

 for col in df:
if col != group_var and 'SK_ID' in col:
df = df.drop(columns = col)
 group_ids = df[group_var]
numeric_df = df.select_dtypes('number')
 numeric_df[group_var] = group_ids
agg = numeric_df.groupby(group_var ).agg(['count', 'mean', 'max', 'min', 'sum'] ).reset_index()
columns = [group_var]
for var in agg.columns.levels[0]:
if var != group_var:
for stat in agg.columns.levels[1][:-1]:
columns.append('%s_%s_%s' %(df_name, var, stat))
agg.columns = columns
return agg
bureau_agg = agg_numeric(bureau.drop(columns = ['SK_ID_BUREAU']), group_var = 'SK_ID_CURR', df_name = 'bureau')
 bureau_agg.head()<create_dataframe>
p_lstm = pd.read_csv(f_lstm)
 p_tfidf = pd.read_csv(f_tfidf)
def count_categorical(df, group_var, df_name):

 categorical = pd.get_dummies(df.select_dtypes('object'))
categorical[group_var] = df[group_var]
categorical = categorical.groupby(group_var ).agg(['sum', 'mean'])
 column_names = []
for var in categorical.columns.levels[0]:
for stat in ['count', 'count_norm']:
column_names.append('%s_%s_%s' %(df_name, var, stat))
categorical.columns = column_names
return categorical
bureau_counts = count_categorical(bureau, group_var = 'SK_ID_CURR', df_name = 'bureau')
 bureau_counts.head()<merge>
label_cols = ['toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
p_res = p_lstm.copy()
p_res[label_cols] =(1*p_tfidf[label_cols] + 2*p_lstm[label_cols])/ 3
<merge><EOS> 
p_res.to_csv('submission_ensemble.csv', index=False )