Bjerring98 commited on
Commit
6aa72d4
·
verified ·
1 Parent(s): 6c942cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -449,8 +449,10 @@ elif option == "Financial Recommender Engine":
449
  elif option == "SML Classification":
450
  st.title("SML Classification - Financial Product Prediction")
451
 
 
 
 
452
  # User inputs
453
- age = st.slider("Your Age", 18, 70, 30)
454
  income_bracket = st.selectbox("Income Bracket (1 = Lowest, 5 = Highest)", [1, 2, 3, 4, 5])
455
  has_internet_access = st.radio("Do you have Internet Access?", ["Yes", "No"])
456
  employed = st.radio("Are you employed?", ["Yes", "No"])
@@ -460,7 +462,7 @@ elif option == "SML Classification":
460
  education_level = st.selectbox("Education Level", ["Primary", "Secondary", "Tertiary"])
461
  age_group = st.selectbox("Age Group", ["Teen", "Young Adult", "Adult", "Middle Age", "Older Adult", "Elder", "Senior"])
462
 
463
- # Prepare categorical features
464
  input_data = pd.DataFrame({
465
  'Income Bracket': [income_bracket],
466
  'Has Internet Access': [1 if has_internet_access == "Yes" else 0],
@@ -482,11 +484,12 @@ elif option == "SML Classification":
482
  'Age Group_Senior': [1 if age_group == "Senior" else 0]
483
  })
484
 
485
- # One-hot encode the categorical features
486
  input_data_encoded = pd.DataFrame(ohe.transform(input_data).todense(), columns=ohe.get_feature_names_out())
487
 
488
  # Prediction
489
  if st.button("Predict"):
 
490
  prediction = xgb_model.predict(input_data_encoded)[0]
491
  st.write(f"Prediction: {prediction}")
492
 
 
449
  elif option == "SML Classification":
450
  st.title("SML Classification - Financial Product Prediction")
451
 
452
+ # Collect user inputs for prediction
453
+ st.markdown("### Provide the details to predict the financial product:")
454
+
455
  # User inputs
 
456
  income_bracket = st.selectbox("Income Bracket (1 = Lowest, 5 = Highest)", [1, 2, 3, 4, 5])
457
  has_internet_access = st.radio("Do you have Internet Access?", ["Yes", "No"])
458
  employed = st.radio("Are you employed?", ["Yes", "No"])
 
462
  education_level = st.selectbox("Education Level", ["Primary", "Secondary", "Tertiary"])
463
  age_group = st.selectbox("Age Group", ["Teen", "Young Adult", "Adult", "Middle Age", "Older Adult", "Elder", "Senior"])
464
 
465
+ # Prepare input data to match the model's expected features
466
  input_data = pd.DataFrame({
467
  'Income Bracket': [income_bracket],
468
  'Has Internet Access': [1 if has_internet_access == "Yes" else 0],
 
484
  'Age Group_Senior': [1 if age_group == "Senior" else 0]
485
  })
486
 
487
+ # One-hot encode the input data
488
  input_data_encoded = pd.DataFrame(ohe.transform(input_data).todense(), columns=ohe.get_feature_names_out())
489
 
490
  # Prediction
491
  if st.button("Predict"):
492
+ # Predict using the loaded model
493
  prediction = xgb_model.predict(input_data_encoded)[0]
494
  st.write(f"Prediction: {prediction}")
495