-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (50 loc) · 2.44 KB
/
main.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
import streamlit as st
from prediction_helper import predict # Ensure this is correctly linked to your prediction_helper.py
# Set the page configuration and title
st.set_page_config(page_title="Lauki Finance: Credit Risk Modelling", page_icon="📊")
st.title("Lauki Finance: Credit Risk Modelling")
# Create rows of three columns each
row1 = st.columns(3)
row2 = st.columns(3)
row3 = st.columns(3)
row4 = st.columns(3)
# Assign inputs to the first row with default values
with row1[0]:
age = st.number_input('Age', min_value=18, step=1, max_value=100, value=28)
with row1[1]:
income = st.number_input('Income', min_value=0, value=1200000)
with row1[2]:
loan_amount = st.number_input('Loan Amount', min_value=0, value=2560000)
# Calculate Loan to Income Ratio and display it
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}") # Display as a text field
# Assign inputs to the remaining controls
with row2[1]:
loan_tenure_months = st.number_input('Loan Tenure (months)', min_value=0, step=1, value=36)
with row2[2]:
avg_dpd_per_delinquency = st.number_input('Avg DPD', min_value=0, value=20)
with row3[0]:
delinquency_ratio = st.number_input('Delinquency Ratio', min_value=0, max_value=100, step=1, value=30)
with row3[1]:
credit_utilization_ratio = st.number_input('Credit Utilization Ratio', min_value=0, max_value=100, step=1, value=30)
with row3[2]:
num_open_accounts = st.number_input('Open Loan Accounts', min_value=1, max_value=4, step=1, value=2)
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', ['Unsecured', 'Secured'])
# Button to calculate risk
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, num_open_accounts,
residence_type, loan_purpose, loan_type)
# Display the results
st.write(f"Deafult Probability: {probability:.2%}")
st.write(f"Credit Score: {credit_score}")
st.write(f"Rating: {rating}")
# Footer
# st.markdown('_Project From Codebasics ML Course_')