Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,7 @@ model = load('loandefaulter.joblib')
|
|
| 7 |
scaler = load('scaler.joblib')
|
| 8 |
|
| 9 |
# Define numerical features for scaling
|
| 10 |
-
num_features = [
|
| 11 |
-
'loan_amnt', 'int_rate', 'installment', 'annual_inc', 'dti', 'revol_bal', 'revol_util', 'total_acc', 'mort_acc'
|
| 12 |
-
]
|
| 13 |
|
| 14 |
# Create the Streamlit app
|
| 15 |
st.set_page_config(page_title='Loan Default Prediction', layout='wide')
|
|
@@ -29,13 +27,9 @@ st.markdown("""
|
|
| 29 |
# Input fields with sliders
|
| 30 |
loan_amnt = st.slider('Loan Amount', min_value=0.0, max_value=1000000.0, step=1000.0, value=10000.0)
|
| 31 |
int_rate = st.slider('Interest Rate (%)', min_value=0.0, max_value=30.0, step=0.1, value=5.0)
|
| 32 |
-
installment = st.slider('
|
| 33 |
annual_inc = st.slider('Annual Income', min_value=0.0, max_value=1000000.0, step=1000.0, value=50000.0)
|
| 34 |
-
|
| 35 |
-
revol_bal = st.slider('Revolving Balance', min_value=0.0, max_value=500000.0, step=100.0, value=10000.0)
|
| 36 |
-
revol_util = st.slider('Revolving Utilization (%)', min_value=0.0, max_value=100.0, step=0.1, value=30.0)
|
| 37 |
-
total_acc = st.slider('Total Accounts', min_value=0, max_value=100, step=1, value=10)
|
| 38 |
-
mort_acc = st.slider('Mortgage Accounts', min_value=0, max_value=10, step=1, value=1)
|
| 39 |
loan_amnt_by_income = loan_amnt / (annual_inc + 1)
|
| 40 |
|
| 41 |
# Create a DataFrame for the input
|
|
@@ -44,11 +38,7 @@ input_data = pd.DataFrame({
|
|
| 44 |
'int_rate': [int_rate],
|
| 45 |
'installment': [installment],
|
| 46 |
'annual_inc': [annual_inc],
|
| 47 |
-
'
|
| 48 |
-
'revol_bal': [revol_bal],
|
| 49 |
-
'revol_util': [revol_util],
|
| 50 |
-
'total_acc': [total_acc],
|
| 51 |
-
'mort_acc': [mort_acc]
|
| 52 |
})
|
| 53 |
|
| 54 |
# Scale the numerical features that were used to fit the scaler
|
|
@@ -65,3 +55,4 @@ if st.button('Predict'):
|
|
| 65 |
st.markdown(f"""
|
| 66 |
<div style="font-size: 24px; color: {color}; font-weight: bold;">Prediction: {result}</div>
|
| 67 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
| 7 |
scaler = load('scaler.joblib')
|
| 8 |
|
| 9 |
# Define numerical features for scaling
|
| 10 |
+
num_features = ['loan_amnt', 'int_rate', 'installment', 'annual_inc', 'cibil_score']
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Create the Streamlit app
|
| 13 |
st.set_page_config(page_title='Loan Default Prediction', layout='wide')
|
|
|
|
| 27 |
# Input fields with sliders
|
| 28 |
loan_amnt = st.slider('Loan Amount', min_value=0.0, max_value=1000000.0, step=1000.0, value=10000.0)
|
| 29 |
int_rate = st.slider('Interest Rate (%)', min_value=0.0, max_value=30.0, step=0.1, value=5.0)
|
| 30 |
+
installment = st.slider('EMI Amount', min_value=0.0, max_value=10000.0, step=10.0, value=200.0)
|
| 31 |
annual_inc = st.slider('Annual Income', min_value=0.0, max_value=1000000.0, step=1000.0, value=50000.0)
|
| 32 |
+
cibil_score = st.number_input('CIBIL Score', min_value=300, max_value=900, step=1, value=700)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
loan_amnt_by_income = loan_amnt / (annual_inc + 1)
|
| 34 |
|
| 35 |
# Create a DataFrame for the input
|
|
|
|
| 38 |
'int_rate': [int_rate],
|
| 39 |
'installment': [installment],
|
| 40 |
'annual_inc': [annual_inc],
|
| 41 |
+
'cibil_score': [cibil_score]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
})
|
| 43 |
|
| 44 |
# Scale the numerical features that were used to fit the scaler
|
|
|
|
| 55 |
st.markdown(f"""
|
| 56 |
<div style="font-size: 24px; color: {color}; font-weight: bold;">Prediction: {result}</div>
|
| 57 |
""", unsafe_allow_html=True)
|
| 58 |
+
|