-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
32 lines (26 loc) · 996 Bytes
/
temp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset=pd.read_csv('loan2.csv')
newdf=dataset.interpolate()
newdf=newdf.fillna(method="ffill")
newdf=newdf.fillna(method="bfill")
X=newdf.iloc[:,1:12]
Y=newdf.iloc[:,[12]]
X=pd.get_dummies(X)
X=X.drop(['Gender_Female','Married_No','Dependents_0','Education_Graduate','Self_Employed_No','Property_Area_Rural'],axis='columns')
Y=pd.get_dummies(Y)
Y=Y.drop(['Loan_Status_N'],axis='columns')
from sklearn.cross_validation import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,Y,test_size=0.25,random_state=0)
from sklearn.preprocessing import StandardScaler
Sc_x=StandardScaler()
X_train=Sc_x.fit_transform(X_train)
X_test=Sc_x.transform(X_test)
from sklearn.svm import SVC
classifier=SVC(random_state=0)
classifier.fit(X_train,y_train)
y_pred=classifier.predict(X_test)
#confusion metrics
from sklearn.metrics import confusion_matrix
cm=confusion_matrix(y_test,y_pred)