Kaggle competition: IEEE-CIS Fraud Detection
<SOS> metric: AUC Kaggle data source: ieee-cis-fraud-detection<feature_engineering>
warnings.filterwarnings("ignore")
 %matplotlib inline
def fill_Ages(row):
if pd.isnull(row['Age']):
return mean_age[row['Sex'],row['Pclass']]
else:
return row['Age']
data['Age'] =data.apply(fill_Ages, axis=1 )<feature_engineering>
LABELS = ["isFraud"]
all_files = glob.glob(".. /input/lgmodels/*.csv")
 scores = np.zeros(len(all_files))
for i in range(len(all_files)) :
scores[i] = float('.'+all_files[i].split(".")[3])
 print(i,scores[i],all_files[i] )
mean_age = test.groupby(['Sex','Pclass'])['Age'].mean()
mean_age.reset_index(name = 'm_Age')
 test['Age'] =test.apply(fill_Ages, axis=1)
 test.Fare.fillna(test.Fare.mean() ,inplace=True )<count_values>
top = scores.argsort() [::-1]
for i, f in enumerate(top):
print(i,scores[f],all_files[f] )
data.Embarked.value_counts()<correct_missing_values>
outs = [pd.read_csv(all_files[f], index_col=0)for f in top]
concat_sub = pd.concat(outs, axis=1)
 cols = list(map(lambda x: "m" + str(x), range(len(concat_sub.columns))))
concat_sub.columns = cols
data.Embarked.fillna('S', inplace=True )<feature_engineering>
rank = np.tril(corr.values,-1)
 rank[rank<0.92] = 1
m =(rank>0 ).sum() -(rank>0.97 ).sum()
m_gmean, s = 0, 0
for n in range(m):
mx = np.unravel_index(rank.argmin() , rank.shape)
 w =(m-n)/m
m_gmean += w*(np.log(concat_sub.iloc[:,mx[0]])+np.log(concat_sub.iloc[:,mx[1]])) /2
s += w
rank[mx] = 1
m_gmean = np.exp(m_gmean/s )
<categorify><EOS> 
concat_sub['isFraud'] = m_gmean
concat_sub[['isFraud']].to_csv('stack_gmean.csv' )