Spaces:
Sleeping
Sleeping
Commit ·
312421e
verified ·
0
Parent(s):
add: prediction
Browse files- .gitignore +1 -0
- app.py +35 -0
- model/classifier.pkl +0 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request
|
| 2 |
+
import pickle
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
model = pickle.load(open("model/classifier.pkl", "rb"))
|
| 7 |
+
|
| 8 |
+
@app.route("/prediction", methods=["POST"])
|
| 9 |
+
def predict():
|
| 10 |
+
loan_req = request.get_json()
|
| 11 |
+
print(loan_req)
|
| 12 |
+
if loan_req['Gender'] == "Male":
|
| 13 |
+
Gender = 0
|
| 14 |
+
else:
|
| 15 |
+
Gender = 1
|
| 16 |
+
if loan_req['Married'] == "Unmarried":
|
| 17 |
+
Married = 0
|
| 18 |
+
else:
|
| 19 |
+
Married = 1
|
| 20 |
+
if loan_req['Credit_History'] == "Unclear Debts":
|
| 21 |
+
Credit_History = 0
|
| 22 |
+
else:
|
| 23 |
+
Credit_History = 1
|
| 24 |
+
|
| 25 |
+
ApplicantIncome = loan_req['ApplicantIncome']
|
| 26 |
+
LoanAmount = loan_req['LoanAmount']
|
| 27 |
+
|
| 28 |
+
result = model.predict([[Gender, Married, ApplicantIncome, LoanAmount, Credit_History]])
|
| 29 |
+
|
| 30 |
+
if result == 0:
|
| 31 |
+
pred = "Rejected"
|
| 32 |
+
else:
|
| 33 |
+
pred = "Approved"
|
| 34 |
+
|
| 35 |
+
return {"loan_approval_status": pred}
|
model/classifier.pkl
ADDED
|
Binary file (902 Bytes). View file
|
|
|