-
Notifications
You must be signed in to change notification settings - Fork 1
/
predict_model.py
45 lines (34 loc) · 1.07 KB
/
predict_model.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
36
37
38
39
40
41
42
43
44
45
import numpy as np
import pickle
def load_model(filename = "classifier.pkl"):
pickle_in = open(filename, 'rb')
return pickle.load(pickle_in)
classifier = load_model("models/classifier.pkl")
# defining the function which will make the prediction using the data which the user inputs
def prediction(Gender, Married, ApplicantIncome, LoanAmount, Credit_History):
# Pre-processing user input
if Gender == "Masculino":
Gender = 0
else:
Gender = 1
if Married == "Solteiro":
Married = 0
else:
Married = 1
if Credit_History == "Com dividas":
Credit_History = 0
else:
Credit_History = 1
if ApplicantIncome == "":
ApplicantIncome = 0
if LoanAmount == "":
LoanAmount = 0
LoanAmount = LoanAmount / 1000
# Making predictions
prediction = classifier.predict(
[[Gender, Married, ApplicantIncome, LoanAmount, Credit_History]])
if prediction == 0:
pred = 'Rejected'
else:
pred = 'Approved'
return pred