Kaggle competition: Home Credit Default Risk
<SOS> metric: AUC Kaggle data source: home-credit-default-risk<import_modules>
import numpy as np
import pandas as pd
import os
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPool2D, Flatten, Dense
from tensorflow.keras.optimizers import Adam<choose_model_class>
app_train = pd.read_csv('.. /input/home-credit-simple-featuers/simple_features_train.csv')
 app_test = pd.read_csv('.. /input/home-credit-simple-featuers/simple_features_test.csv' )
model = Sequential()
model.add(Conv2D(16, 3, input_shape=(28, 28, 1), activation='relu', padding='same'))
model.add(Conv2D(16, 3, activation='relu', padding='same'))
model.add(MaxPool2D(2, 2))
model.add(Conv2D(32, 3, activation='relu', padding='same'))
model.add(Conv2D(32, 3, activation='relu', padding='same'))
model.add(MaxPool2D(2, 2))
model.add(Flatten())
 model.add(Dense(128, activation='relu'))
model.add(Dense(10, activation='softmax'))
optimizer = Adam(learning_rate=3e-3)
 model.compile(optimizer=optimizer, loss='categorical_crossentropy', metrics=['acc'] )<data_type_conversions>
sk_id = pd.read_csv('.. /input/home-credit-default-risk/application_test.csv' )
xtr = np.expand_dims(xtr, -1 ).astype(np.float32)/ 255
xte = np.expand_dims(xte, -1 ).astype(np.float32)/ 255
ytr = to_categorical(ytr )<train_model>
train = app_train.drop(columns = ['TARGET'])
 train_labels = app_train['TARGET']
history = model.fit(xtr, ytr, validation_split=0.3, batch_size=128, epochs=5 )<predict_on_test>
X_train, X_test, y_train, y_test = train_test_split(
 train, train_labels, test_size=0.2 )
pred = model.predict(xte)
 categorical_pred = np.argmax(pred, axis=1 )<save_to_csv>
clf = LGBMClassifier(nthread=4,n_estimators=10000,learning_rate=0.02,num_leaves=34,colsample_bytree=0.9497036,subsample=0.8715623,max_depth=8,reg_alpha=0.041545473,reg_lambda=0.0735294,min_split_gain=0.0222415,min_child_weight=39.3259775,silent=-1,verbose=-1)
 clf.fit(X_train, y_train, eval_set=[(X_train, y_train),(X_test, y_test)],
eval_metric= 'auc', verbose= 100, early_stopping_rounds= 200)
submission = pd.read_csv('/kaggle/input/comp-850-project-1/sample_submission.csv')
 submission['Category'] = categorical_pred
submission.to_csv('my_first_submission.csv', index=False )<load_from_csv>
df = pd.read_csv('.. /input/TWHM-WebAttacksTrain.csv', index_col='IDNum' )<data_type_conversions>
y_pred = clf.predict_proba(app_test, num_iteration=clf.best_iteration_)[:, 1]
submit = sk_id[['SK_ID_CURR']]
submit['TARGET'] = y_pred
submit.to_csv('sub1.csv', index = False)