ifiecas commited on
Commit
6c0b217
·
verified ·
1 Parent(s): 663c0e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -10
app.py CHANGED
@@ -185,20 +185,55 @@ with tab1:
185
  dti = (loan_amount / total_income) if total_income > 0 else 0
186
  dti_percent = dti * 100
187
 
188
- # Show important metrics with context
189
- st.markdown("<p>Debt-to-Income Ratio: <strong>{:.1f}%</strong></p>".format(dti_percent), unsafe_allow_html=True)
190
 
191
- # Add helpful context about DTI
192
- dti_status = ""
 
 
193
  if dti_percent <= 36:
194
- dti_status = "📗 Good (below 36%)"
 
 
195
  elif dti_percent <= 43:
196
- dti_status = "📙 Acceptable (36-43%)"
 
 
197
  else:
198
- dti_status = "📕 High (above 43%)"
199
-
200
- st.markdown(f"<p>DTI Status: {dti_status}</p>", unsafe_allow_html=True)
201
- st.markdown("<p style='font-size:0.8rem;color:#666;'>A lower Debt-to-Income ratio improves your chances of loan approval. Most lenders prefer ratios below 43%.</p>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  st.markdown('</div>', unsafe_allow_html=True)
204
 
 
185
  dti = (loan_amount / total_income) if total_income > 0 else 0
186
  dti_percent = dti * 100
187
 
188
+ # Show DTI with visual gauge instead of raw number
189
+ st.markdown("<h4>Debt-to-Income Assessment</h4>", unsafe_allow_html=True)
190
 
191
+ # Cap the displayed percentage at 100% for the visual
192
+ display_percent = min(dti_percent, 100)
193
+
194
+ # Determine the status and color
195
  if dti_percent <= 36:
196
+ dti_status = "Good"
197
+ dti_color = "#4CAF50" # Green
198
+ emoji = "✅"
199
  elif dti_percent <= 43:
200
+ dti_status = "Moderate"
201
+ dti_color = "#FF9800" # Orange
202
+ emoji = "⚠️"
203
  else:
204
+ dti_status = "High"
205
+ dti_color = "#F44336" # Red
206
+ emoji = "❗"
207
+
208
+ # Create a visual progress bar
209
+ st.markdown(f"""
210
+ <div style="margin-bottom: 10px;">
211
+ <div style="background-color: #e0e0e0; border-radius: 10px; height: 20px; width: 100%;">
212
+ <div style="background-color: {dti_color}; width: {display_percent}%; height: 20px; border-radius: 10px;"></div>
213
+ </div>
214
+ <div style="display: flex; justify-content: space-between; font-size: 0.8rem;">
215
+ <span>0%</span>
216
+ <span>50%</span>
217
+ <span>100%+</span>
218
+ </div>
219
+ </div>
220
+ """, unsafe_allow_html=True)
221
+
222
+ # Show a simple, friendly interpretation
223
+ if dti_percent > 100:
224
+ st.markdown(f"""
225
+ <div style="padding: 10px; background-color: #FFEBEE; border-radius: 5px; margin-bottom: 15px;">
226
+ {emoji} <strong>Your monthly loan payment would be {dti_percent/100:.1f}× your monthly income</strong>
227
+ <p style="margin: 5px 0 0 0; font-size: 0.9rem;">Most lenders look for a ratio below 43% (0.43× your income)</p>
228
+ </div>
229
+ """, unsafe_allow_html=True)
230
+ else:
231
+ st.markdown(f"""
232
+ <div style="padding: 10px; background-color: #F5F5F5; border-radius: 5px; margin-bottom: 15px;">
233
+ {emoji} <strong>Your monthly loan payment would be {dti_percent:.1f}% of your monthly income</strong>
234
+ <p style="margin: 5px 0 0 0; font-size: 0.9rem;">Most lenders look for this to be below 43%</p>
235
+ </div>
236
+ """, unsafe_allow_html=True)
237
 
238
  st.markdown('</div>', unsafe_allow_html=True)
239