Arunachalam S commited on
Commit
eb2a78b
1 Parent(s): d719f82

updated app

Browse files
Files changed (2) hide show
  1. app.py +16 -10
  2. model.joblib → model_final.joblib +2 -2
app.py CHANGED
@@ -4,22 +4,22 @@ import pandas as pd
4
 
5
  st.title("Welcome to ABC Bank")
6
 
7
- model = joblib.load('model.joblib')
8
  #Even though we are not going to use gender to predict the loan status,
9
  #we will be getting the gender data for future plans/schemes.
10
- with st.form('Loan Form'):
11
  col1,col2 = st.columns(2)
12
  with col1:
13
  Gender = st.selectbox('Gender',('Male','Female'))
14
- Applicant_Income = st.number_input('Applicant Income',min_value=0)
15
  Coapplicant_Income = st.number_input('Co-applicant Income',min_value=0)
16
- Loan_amount = st.number_input('Loan Amount',min_value=0)
17
- Loan_Amount_Term = st.number_input('Loan Amount Term (Months)',min_value=0)
18
  with col2:
19
  Property_Area = st.selectbox('Property Area',('Urban','Rural','Semiurban'))
20
  Credit_History = st.number_input('Credit History',min_value=0,max_value=1)
21
  Self_Employed = st.selectbox('Self Employed',('Yes','No'))
22
- Dependents = st.selectbox('Dependents',('0','1','2','3','3+'))
23
  Education = st.selectbox('Education',('Graduate','Not Graduate'))
24
  Married = st.selectbox('Married',('Yes','No'))
25
 
@@ -35,14 +35,20 @@ with st.form('Loan Form'):
35
  'Credit_History': [Credit_History],
36
  'Property_Area': [Property_Area]}
37
  )
 
 
 
 
 
 
 
 
 
38
  submit = st.form_submit_button('Predict')
39
  if submit:
40
  prediction = model.predict(df)
41
  if prediction:
42
  st.success('Congratulations, Your Home Loan is Approved!!')
43
  else:
44
- st.error('We are extremely sorry to inform you that you Home Loan is not approved. Please reach out to nearest Branch for further clarification')
45
-
46
- st.write(df)
47
-
48
 
 
4
 
5
  st.title("Welcome to ABC Bank")
6
 
7
+ model = joblib.load('model_final.joblib')
8
  #Even though we are not going to use gender to predict the loan status,
9
  #we will be getting the gender data for future plans/schemes.
10
+ with st.form('Loan Form',clear_on_submit=True):
11
  col1,col2 = st.columns(2)
12
  with col1:
13
  Gender = st.selectbox('Gender',('Male','Female'))
14
+ Applicant_Income = st.number_input('Applicant Income',min_value=150)
15
  Coapplicant_Income = st.number_input('Co-applicant Income',min_value=0)
16
+ Loan_amount = st.number_input('Loan Amount (In thousands)',min_value=5)
17
+ Loan_Amount_Term = st.number_input('Loan Amount Term (Months)',min_value=12)
18
  with col2:
19
  Property_Area = st.selectbox('Property Area',('Urban','Rural','Semiurban'))
20
  Credit_History = st.number_input('Credit History',min_value=0,max_value=1)
21
  Self_Employed = st.selectbox('Self Employed',('Yes','No'))
22
+ Dependents = st.selectbox('Dependents',('0','1','2','3+'))
23
  Education = st.selectbox('Education',('Graduate','Not Graduate'))
24
  Married = st.selectbox('Married',('Yes','No'))
25
 
 
35
  'Credit_History': [Credit_History],
36
  'Property_Area': [Property_Area]}
37
  )
38
+ def emi_calculator(principle,term):
39
+ #interest = PNR/100
40
+ interest = (principle * 1000 * 8.5 * term )/float(12*100)
41
+ emi = ((principle*1000) + interest)/term
42
+ return emi
43
+ df['EMI'] = df.apply(lambda row: emi_calculator(row['Loan_Amount'],row['Loan_Amount_Term']),axis =1)
44
+ df['Balance_Income'] = df['Applicant_Income'] + df['Coapplicant_Income'] - df['EMI']
45
+ df.drop(columns = ['Applicant_Income','Coapplicant_Income','Loan_Amount','Loan_Amount_Term'])
46
+
47
  submit = st.form_submit_button('Predict')
48
  if submit:
49
  prediction = model.predict(df)
50
  if prediction:
51
  st.success('Congratulations, Your Home Loan is Approved!!')
52
  else:
53
+ st.error('We are extremely sorry to inform you that you Home Loan is not approved. Please reach out to nearest branch for further clarification')
 
 
 
54
 
model.joblib → model_final.joblib RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7167812dfb03f255d78695e8936eead9bd5fb0790ff99d819401ef85537b2a64
3
- size 5518
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f507f76658ab5c5e1be35367b2683f70fd5a0e415702795dbbed8c2e2996e22
3
+ size 104047