text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import accuracy_score

from sklearn.model_selection import train_test_split

from sklearn.neighbors import KNeighborsClassifier

from sklearn.svm import SVC

from sklearn.tree import DecisionTreeClassifier

import pandas as pd

data = pd.read_csv('/kaggle/input/loan-data-set/loan_data_set.csv')

data.drop('Loan_ID', axis=1, inplace=True)

data.shape

data = data.dropna()

data.shape

X = data.drop('Loan_Status', axis=1)
y = data['Loan_Status']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

knn = KNeighborsClassifier()
knn.fit(X_train, y_train)
y_train_pred = knn.predict(X_train)
y_test_pred = knn.predict(X_test)
train_acc_knn = accuracy_score(y_train, y_train_pred)
test_acc_knn = accuracy_score(y_test, y_test_pred)

dt = DecisionTreeClassifier()
dt.fit(X_train, y_train)
y_train_pred = dt.predict(X_train)
y_test_pred = dt.predict(X_test)
train_acc_dt = accuracy_score(y_train, y_train_pred)
test_acc_dt = accuracy_score(y_test, y_test_pred)

svm = SVC()
svm.fit(X_train, y_train)
y_train_pred = svm.predict(X_train)
y_test_pred = svm.predict(X_test)
train_acc_svm = accuracy_score(y_train, y_train_pred)
test_acc_svm = accuracy_score(y_test, y_test_pred)

lr = LogisticRegression()
lr.fit(X_train, y_train)
y_train_pred = lr.predict(X_train)
y_test_pred = lr.predict(X_test)
train_acc_lr = accuracy_score(y_train, y_train_pred)
test_acc_lr = accuracy_score(y_test, y_test_pred)

lr = LogisticRegression()
lr.fit(X, y)