-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.py
More file actions
60 lines (44 loc) · 1.26 KB
/
app.py
File metadata and controls
60 lines (44 loc) · 1.26 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pickle
import flask
from flask import Flask, request, Response, jsonify
## loading the model
model_pickle = open("classifier.pkl", 'rb')
clf = pickle.load(model_pickle)
app = Flask(__name__)
# defining the function which will make the prediction using the data which the user inputs
@app.route('/predict', methods = ['POST'])
def predict():
# Pre-processing user input
loan_req = request.get_json()
print(loan_req)
if loan_req['Gender'] == "Male":
Gender = 0
else:
Gender = 1
if loan_req['Married'] == "Unmarried":
Married = 0
else:
Married = 1
if loan_req['Credit_History'] == "Unclear Debts":
Credit_History = 0
else:
Credit_History = 1
ApplicantIncome = loan_req['ApplicantIncome']
LoanAmount = loan_req['LoanAmount'] / 1000
# Making predictions
prediction = clf.predict(
[[Gender, Married, ApplicantIncome, LoanAmount, Credit_History]])
if prediction == 0:
pred = 'Rejected'
else:
pred = 'Approved'
result = {
'loan_approval_status': pred
}
return jsonify(result)
@app.route('/ping', methods=['GET'])
def ping():
return "Pinging Model!!"
@app.route('/', methods=['GET'])
def hello():
return "Hello Shivank!!"