-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
131 lines (107 loc) · 3.58 KB
/
app.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# save this as app.py
from flask import Flask, request, render_template, send_from_directory
import pickle
import numpy as np
import os
app = Flask(__name__)
model = pickle.load(open('model.pkl', 'rb'))
@app.route('/')
def home():
return render_template("index.html")
@app.route('/index.html')
def home1():
return render_template("index.html")
@app.route('/about.html')
def about():
return render_template("about.html")
@app.route('/contact.html')
def contact():
return render_template("contact.html")
@app.route('/privacy.html')
def privacy():
return render_template("privacy.html")
@app.route('/prediction.html')
def prediction():
return render_template("prediction.html")
@app.route('/predict.html', methods=['GET', 'POST'])
def predict():
if request.method == 'POST':
#1 Gender
Gender = request.form['Gender']
#2 Married
Married = request.form['Married']
#3 Dependents
Dependents = request.form['Dependents']
#4 Education
Education = request.form['Education']
#5 Self_Employeed
Self_Employed = request.form['Self_Employed']
#6 ApplicantIncome
ApplicantIncome = request.form['ApplicantIncome']
#7 CoapplicantIncome
CoapplicantIncome = request.form['CoapplicantIncome']
#8 Loan_Amount
LoanAmount = request.form['LoanAmount']
#9 Loan_Amount_Term
Loan_Amount_Term = request.form['Loan_Amount_Term']
#10 Credit_History
Credit_History = request.form['Credit_History']
#11 Property_Area
Property_Area = request.form['Property_Area']
#Gender
if(Gender == "Male"):
Gender = 1
else:
Gender = 0
#Married
if(Married == "Yes"):
Married = 1
else:
Married = 0
#Dependents
if(Dependents=="0"):
Dependents=0
elif(Dependents=="1"):
Dependents=1
elif(Dependents=="2"):
Dependents=2
elif(Dependents=="3+"):
Dependents=4
#Education
if(Education == "Graduated"):
Education = 1
else:
Education = 0
#Self_Employed
if(Self_Employed == "Yes"):
Self_Employed = 1
else:
Self_Employed = 0
#Credit_History
if(Credit_History == 0.0):
Credit_History = 0.0
else:
Credit_History = 0.1
#Property_Area
if(Property_Area == "Urban"):
Property_Area = 2
elif(Property_Area == "Rural"):
Property_Area = 0
else:
Property_Area = 1
#Calling model
prediction = model.predict([[Gender, Married, Dependents, Education, Self_Employed, ApplicantIncome, CoapplicantIncome, LoanAmount, Loan_Amount_Term, Credit_History, Property_Area]])
message = f"This is the variable: {prediction}"
print(message)
#Loan Status Condition
if(prediction=="0"):
prediction="No"
elif(prediction=='1'):
prediction="Yes"
else:
prediction="Invalid"
return render_template("predict_txt.html", prediction_text=format(prediction))
else:
return render_template("prediction.html")
if __name__ == '__main__':
app.run(debug=True)