<jupyter_start><jupyter_text><jupyter_code>from google.colab import drive
drive.mount('/content/drive')
import numpy as np
import pandas as pd
import os
import sys
dataset_path = 'drive/My Drive/Dataset/Home Credit Default Risk/'
path_train = os.path.join(dataset_path, 'application_train.csv')
path_test = os.path.join(dataset_path, 'application_test.csv')

train = pd.read_csv(path_train)
test = pd.read_csv(path_test)
train.head()
train = train.fillna(0)
test = test.fillna(0)
test
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
for col in train.columns:
  if(train[col].dtype=='object'):
    le.fit(train[col].tolist())
    train[col] = le.transform(train[col].tolist())

for col in test.columns:
  if(test[col].dtype=='object'):
    le.fit(test[col].tolist())
    test[col] = le.transform(test[col].tolist())
y_train = train['TARGET']
id_train = train['SK_ID_CURR']
X_train = train.drop(columns=['SK_ID_CURR', 'TARGET'])
id_test = test['SK_ID_CURR']
X_test = test.drop(columns=['SK_ID_CURR'])
for col in X_train.columns:
  print(train[col].nunique())
from sklearn.model_selection import train_test_split
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.1, random_state=42)

from sklearn.linear_model import LinearRegression
from sklearn.linear_model import Ridge
from sklearn.svm import SVR
lr = SVR()
lr.fit(X_train, y_train)
from sklearn.metrics import roc_auc_score

print("Validation accuracy: ", roc_auc_score(y_val, lr.predict(X_val)))
submit = pd.DataFrame(index=None)

ans = lr.predict(X_test)
for i in range(0, ans.shape[0]):
  if(ans[i]<0):
    ans[i]=0.0

submit['SK_ID_CURR'] = id_test
submit['TARGET'] = ans

submit.head()
submit.to_csv('submit.csv', index=None)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup