Kaggle competition: SIIM-ISIC Melanoma Classification
<SOS> metric: MCAUC Kaggle data source: siim-isic-melanoma-classification<load_from_csv>
import numpy as np
import pandas as pd
from scipy.stats import rankdata
import os
import re
train_df = pd.read_csv('.. /input/nlp-getting-started/train.csv')
 train_df.head()<load_from_csv>
def Stacking(input_folder,
best_base,
output_path,
column_names,
cutoff_lo,
cutoff_hi):

 sub_base = pd.read_csv(best_base)
 all_files = os.listdir(input_folder)
 nb_files = len(all_files)
 assert type(input_folder)== str, "Wrong type"
assert type(best_base)== str, "Wrong type"
assert type(output_path)== str, "Wrong type"
assert type(cutoff_lo)in [float, int], "Wrong type"
assert type(cutoff_hi)in [float, int], "Wrong type"
assert(cutoff_lo >= 0)&(cutoff_lo <= 1)&(cutoff_hi >= 0)&(cutoff_hi <= 1), "cutoff_lo and cutoff_hi must be between 0 and 1"
assert len(column_names)== 2, "Only two columns must be in column_names"
assert type(column_names[0])== str, "Wrong type"
assert type(column_names[1])== str, "Wrong type"
concat_sub = pd.DataFrame()
concat_sub[column_names[0]] = sub_base[column_names[0]]
for index, f in enumerate(all_files):
concat_sub[column_names[1]+str(index)] = pd.read_csv(input_folder + f)[column_names[1]]
print(" ***** 1/4 Read and concatenate submissions SUCCESSFUL *****")
 concat_sub['target_max'] = concat_sub.iloc[:, 1:].max(axis=1)
 concat_sub['target_min'] = concat_sub.iloc[:, 1:].min(axis=1)
 concat_sub['target_mean'] = concat_sub.iloc[:, 1:].mean(axis=1)
 concat_sub['target_median'] = concat_sub.iloc[:, 1:].median(axis=1)
 print(" ***** 2/4 Get the data fields ready for stacking SUCCESSFUL *****")
 concat_sub['target_base'] = sub_base[column_names[1]]
concat_sub[column_names[1]] = np.where(np.all(concat_sub.iloc[:, 1:] > cutoff_lo, axis=1),
concat_sub['target_max'],
np.where(np.all(concat_sub.iloc[:, 1:] < cutoff_hi, axis=1),
concat_sub['target_min'],
concat_sub['target_base']))
print(" ***** 3/4 Set up cutoff threshold for lower and upper bounds SUCCESSFUL *****")
 concat_sub[column_names].to_csv(output_path, index=False, float_format='%.12f')
 print(" ***** 4/4 Generating Stacked dataframe SUCCESSFUL *****")
 print(" ***** COMPLETED *****" )
test_df = pd.read_csv('.. /input/nlp-getting-started/test.csv')
 test_df.head()<train_model>
Stacking(input_folder = '.. /input/siim-isic-baseline-models/',
best_base = '.. /input/siim-isic-baseline-models/RESNET_0946.csv',
output_path = 'stacking.csv',
column_names = ['image_name', 'target'],
cutoff_lo = 0.85,
cutoff_hi = 0.17 )
<count_missing_values><EOS> 
Ensemble(input_folder = '.. /input/siim-isic-baseline-models/',
output_path = 'ensemble.csv',
method = 'weights',
column_names = ['image_name', 'target'],
sorted_files = True,
reverse = False )