starboywilliam commited on
Commit
18c84a1
ยท
verified ยท
1 Parent(s): 2b1e0c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -7
app.py CHANGED
@@ -33,17 +33,34 @@ def predict_salary(age, education_num, sex, capital_gain, capital_loss, hours_pe
33
  return label, confidence, fig
34
 
35
  with gr.Blocks(css="""
36
- body { background-color: #0a0a23; color: white; }
37
- .gr-box { background-color: #1a1a3d !important; border-radius: 12px; padding: 20px; }
38
- h1, h3, p { color: white; text-align: center; font-family: 'Segoe UI', sans-serif; }
39
- .gr-button { background-color: #1db954 !important; color: white !important; border-radius: 10px; font-size: 1.1em; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  .gr-radio .gr-form { display: flex; justify-content: center !important; }
41
  """
42
  ) as demo:
43
 
44
  gr.Markdown("""
45
  <div style='max-width: 700px; margin: 0 auto;'>
46
- <h1 style='font-size: 2.5em;'>๐Ÿ’ผ Income Prediction App</h1>
47
  <p style='font-size: 1.2em;'>Predict whether someone earns more than $50K/year using financial and demographic data, with AI explainability via SHAP.</p>
48
  </div>
49
  """)
@@ -52,21 +69,26 @@ with gr.Blocks(css="""
52
  with gr.Column():
53
  gr.Markdown("<h3>๐ŸŽ‚ Age</h3>")
54
  age = gr.Slider(minimum=0, maximum=100, step=1, value=35, label="", interactive=True)
 
55
 
56
  gr.Markdown("<h3>๐ŸŽ“ Education Level</h3>")
57
  education = gr.Dropdown(choices=[str(i) for i in range(1, 17)], value="10", label="", interactive=True)
 
58
 
59
  gr.Markdown("<h3>โšง๏ธ Sex</h3>")
60
  sex = gr.Radio(choices=["Male", "Female"], value="Male", label="", interactive=True)
61
 
62
- gr.Markdown("<h3>๐Ÿ“ˆ Capital Gain</h3>")
63
  capital_gain = gr.Number(value=0, label="", interactive=True)
 
64
 
65
  gr.Markdown("<h3>๐Ÿ“‰ Capital Loss</h3>")
66
  capital_loss = gr.Number(value=0, label="", interactive=True)
 
67
 
68
  gr.Markdown("<h3>โฑ๏ธ Hours per Week</h3>")
69
  hours_per_week = gr.Number(value=40, label="", interactive=True)
 
70
 
71
  predict_btn = gr.Button("๐Ÿ”ฎ Predict", elem_id="predict-button")
72
 
@@ -83,6 +105,6 @@ with gr.Blocks(css="""
83
  outputs=[result, confidence, shap_plot]
84
  )
85
 
86
- demo.launch()
87
 
88
 
 
33
  return label, confidence, fig
34
 
35
  with gr.Blocks(css="""
36
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap');
37
+
38
+ body { background-color: #0a0a23; color: white; font-family: 'Poppins', sans-serif; }
39
+ .gr-box { background-color: #1a1a3d !important; border-radius: 12px; padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); transition: transform 0.3s ease; }
40
+ .gr-box:hover { transform: scale(1.02); }
41
+ h1, h3, p { color: white; text-align: center; }
42
+ .gr-button { background: linear-gradient(135deg, #1db954, #1ed760) !important; color: white !important; border-radius: 10px; font-size: 1.1em; transition: background 0.3s ease; }
43
+ #predict-button:hover { animation: pulseBtn 1s infinite; }
44
+ @keyframes pulseBtn {
45
+ 0% { transform: scale(1); }
46
+ 50% { transform: scale(1.05); }
47
+ 100% { transform: scale(1); }
48
+ }
49
+ input:hover, select:hover, textarea:hover {
50
+ box-shadow: 0 0 5px #1db954;
51
+ }
52
+ .gr-plot { animation: fadein 1s ease; }
53
+ @keyframes fadein {
54
+ from { opacity: 0; }
55
+ to { opacity: 1; }
56
+ }
57
  .gr-radio .gr-form { display: flex; justify-content: center !important; }
58
  """
59
  ) as demo:
60
 
61
  gr.Markdown("""
62
  <div style='max-width: 700px; margin: 0 auto;'>
63
+ <h1 style="animation: pulse 2s infinite;">๐Ÿ’ผ Income Prediction App</h1>
64
  <p style='font-size: 1.2em;'>Predict whether someone earns more than $50K/year using financial and demographic data, with AI explainability via SHAP.</p>
65
  </div>
66
  """)
 
69
  with gr.Column():
70
  gr.Markdown("<h3>๐ŸŽ‚ Age</h3>")
71
  age = gr.Slider(minimum=0, maximum=100, step=1, value=35, label="", interactive=True)
72
+ gr.Markdown("<p style='text-align:center;'>Enter age in years</p>")
73
 
74
  gr.Markdown("<h3>๐ŸŽ“ Education Level</h3>")
75
  education = gr.Dropdown(choices=[str(i) for i in range(1, 17)], value="10", label="", interactive=True)
76
+ gr.Markdown("<p style='text-align:center;'>1 = Preschool, 16 = Doctorate</p>")
77
 
78
  gr.Markdown("<h3>โšง๏ธ Sex</h3>")
79
  sex = gr.Radio(choices=["Male", "Female"], value="Male", label="", interactive=True)
80
 
81
+ gr.Markdown("<h3>๐Ÿ’ฐ Capital Gain</h3>")
82
  capital_gain = gr.Number(value=0, label="", interactive=True)
83
+ gr.Markdown("<p style='text-align:center;'>Income from asset sales</p>")
84
 
85
  gr.Markdown("<h3>๐Ÿ“‰ Capital Loss</h3>")
86
  capital_loss = gr.Number(value=0, label="", interactive=True)
87
+ gr.Markdown("<p style='text-align:center;'>Loss from asset disposal</p>")
88
 
89
  gr.Markdown("<h3>โฑ๏ธ Hours per Week</h3>")
90
  hours_per_week = gr.Number(value=40, label="", interactive=True)
91
+ gr.Markdown("<p style='text-align:center;'>Typical work hours weekly</p>")
92
 
93
  predict_btn = gr.Button("๐Ÿ”ฎ Predict", elem_id="predict-button")
94
 
 
105
  outputs=[result, confidence, shap_plot]
106
  )
107
 
108
+ demo.launch()
109
 
110