-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (39 loc) · 1.88 KB
/
main.py
File metadata and controls
49 lines (39 loc) · 1.88 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
import streamlit as st
from prediction_helper import predict
st.title('Credit Risk Modelling')
row1 = st.columns(3)
row2 = st.columns(3)
row3 = st.columns(3)
row4 = st.columns(3)
with row1[0]:
age = st.number_input('Age', min_value= 18, max_value= 100, step = 1)
with row1[1]:
income = st.number_input('Income', min_value=0, max_value=10000000, step=1)
with row1[2]:
loan_amount = st.number_input('Loan Amount', min_value = 0, max_value = 10000000)
loan_to_income_ratio = loan_amount / income if income > 0 else 0
with row2[0]:
st.text('Loan to Income Ratio')
st.text(f'{loan_to_income_ratio:.2f}')
with row2[1]:
loan_tenure_months = st.number_input('Loan Tenure Months', min_value = 0, max_value = 36)
with row2[2]:
avg_dpd_per_delinquency = st.number_input('Average DPD', min_value = 0, max_value = 20)
with row3[0]:
delinquency_ratio = st.number_input('Delinquency Ratio', min_value = 0, max_value = 30, step = 1)
with row3[1]:
credit_utilization_ratio = st.number_input('Credit Utilization Ratio', min_value = 0, max_value = 100, step = 1)
with row3[2]:
number_of_open_accounts = st.number_input('Loan Accounts', min_value = 0, max_value = 4, step = 1)
with row4[0]:
residence_type = st.selectbox('Residence Type', ['Owned', 'Rented', 'Mortgage'])
with row4[1]:
loan_purpose = st.selectbox('Loan Purpose', ['Education', 'Home', 'Auto', 'Personal'])
with row4[2]:
loan_type = st.selectbox('Loan Type', ['Secured', 'Unsecured'])
if st.button('Calculate Risk'):
probability, credit_score, rating = predict(age, income, loan_amount, loan_tenure_months, avg_dpd_per_delinquency, delinquency_ratio,
credit_utilization_ratio,number_of_open_accounts,residence_type,loan_purpose,loan_type)
st.write(f'Probability : {probability:.2f}')
st.write(f'Credit Score: {credit_score}')
st.write(f'Rating : {rating}')