<jupyter_start><jupyter_text><jupyter_code>#Importing libraries
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# Input data files are available in the "../input/" directory.
import os
import matplotlib.pyplot as plt#visualization
%matplotlib inline
import pandas as pd
import seaborn as sns#visualization
import itertools
import warnings
warnings.filterwarnings("ignore")
import io
import plotly.offline as py#visualization
py.init_notebook_mode(connected=True)#visualization
import plotly.graph_objs as go#visualization
import plotly.tools as tls#visualization
import plotly.figure_factory as ff#visualization
cd /content/drive/My Drive/DSN-AI-Bootcamp
from google.colab import drive
drive.mount('/content/drive')
train = pd.read_csv("./Train.csv")
test = pd.read_csv("./Test.csv")
submission = pd.read_csv('./SampleSubmission.csv')
test_id = test['Applicant_ID']
print ("Rows     : " ,train.shape[0])
print ("Columns  : " ,train.shape[1])
print ("\nFeatures : \n" ,train.columns.tolist())
print ("\nMissing values :  ", train.isnull().sum().values.sum())
print ("\nUnique values :  \n",train.nunique())
train.isnull().sum()
from sklearn.model_selection import train_test_split,cross_val_score
from sklearn.metrics import accuracy_score,confusion_matrix,recall_score,precision_recall_curve, f1_score
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import LabelEncoder
train
test
dropcols = ['Applicant_ID', 'default_status']
y = train['default_status'] # labels
x = train.drop(columns=dropcols, axis=1)
test = test.drop(columns=['Applicant_ID'], axis=1) #will use this for predicting and submitting the resulting
print(x.shape)
print(y.shape)
print(test.shape)
pip install catboost
from catboost import CatBoostClassifier
cate_features_index=np.where(x.dtypes != float) [0]; cate_features_index
from sklearn.metrics import accuracy_score,confusion_matrix,roc_auc_score, log_loss
errcb=[]
y_pred_totcb=[]
from sklearn.model_selection import KFold,StratifiedKFold, TimeSeriesSplit, GroupKFold
fold=StratifiedKFold(n_splits=5,shuffle=True, random_state=12345)
i=1
for train_index, test_index in fold.split(x,y):
    X_train, X_test = x.iloc[train_index], x.iloc[test_index]
    y_train, y_test = y[train_index], y[test_index]
    m=CatBoostClassifier(n_estimators=10000, max_depth=6,  bootstrap_type='Bernoulli',
                              subsample=0.9,
                              eval_metric='AUC',
                              metric_period=20,)
    m.fit(X_train,y_train,cat_features=cate_features_index,eval_set=[(X_train, y_train),(X_test, y_test)],verbose=100, early_stopping_rounds=200)#,verbose=100)
    preds=m.predict_proba(X_test)[:, 1]
    print("err: ",log_loss(y_test,preds))
    print("err: ",roc_auc_score(y_test,preds))
    errcb.append(log_loss(y_test,preds))
    p = m.predict_proba(test)[:, 1]
    y_pred_totcb.append(p)
d = {"Applicant_ID": test_id, 'default_status': np.mean(y_pred_totcb, 0)}
test_predictions = pd.DataFrame(data=d)
test_predictions = test_predictions[["Applicant_ID", 'default_status']]
test_predictions.to_csv('25kfoldwith2train.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12009803921568628, 'fraction_numerical': 0.011642156862745098, 'mean_word_length': 5.946808510638298, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '160309', 'license': 'MIT', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1114, 'n_words': 224, 'path': 'My_work_with_DSN_Hackathon.ipynb', 'repo_name': 'dmarinere/DSN-Bootcamp', 'size': '3264'}