forked from A7mad7sn/Loan-Prediction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecision_Tree.py
35 lines (22 loc) · 1.06 KB
/
Decision_Tree.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
33
34
35
#impoting Libraries :-
from sklearn.tree import DecisionTreeClassifier
from sklearn import metrics
def Decision_Tree_Algoithm(Data):
print('Using Decision Tree Algorithm :-')
print('---------------------------------')
x_train, x_test, y_train, y_test = Data
loan_Model = DecisionTreeClassifier(max_depth=2,random_state=6,splitter='best')
loan_Model.fit(x_train, y_train)
y_predict = loan_Model.predict(x_test)
print('ID3 accuracy for Loan Prediction = ', metrics.accuracy_score(y_predict,y_test))
print('Y_Real : ', y_test)
print("Y_Predicted : ",y_predict)
def ID3_Predictor(Data,features):
print('Using Decision Tree Algorithm :-')
print('---------------------------------')
x_train, x_test, y_train, y_test = Data
loan_Model = DecisionTreeClassifier(max_depth=2,random_state=6,splitter='best')
loan_Model.fit(x_train, y_train)
#Prediction for features :-
predicted_val = loan_Model.predict(features)
print("Prediction for loan : ",predicted_val)