DetectiveShadow commited on
Commit
5ef5a58
ยท
verified ยท
1 Parent(s): bb1bdda

Update app.py

Browse files

Change the layout

Files changed (1) hide show
  1. app.py +45 -33
app.py CHANGED
@@ -6,49 +6,61 @@ def readiness_predictor(
6
  # Simple heuristic formula
7
  disposable_income = income - bills - entertainment
8
  score = (
9
- (savings + assets) / 1000 # more savings/assets = better
10
- + disposable_income / 500 # more free income = better
11
- + sales_skills * 2 # sales skills matter a lot
12
- - dependents # more dependents = more pressure
13
- + (40 - abs(35 - age)) / 5 # ideal range ~35 years old
14
  )
15
-
16
- # Clamp score to 0โ€“100
17
  score = max(0, min(100, score))
18
 
19
  if score < 30:
20
- prediction = "Low readiness"
21
  elif score < 60:
22
- prediction = "Moderate readiness"
23
  else:
24
- prediction = "High readiness"
25
 
26
- return {
27
- "Readiness Score": round(score, 2),
28
- "Prediction": prediction
29
- }
30
 
31
- with gr.Blocks() as demo:
32
- gr.Markdown("# ๐Ÿš€ Entrepreneurial Readiness Predictor")
 
 
 
 
 
33
 
34
  with gr.Row():
35
- with gr.Column():
36
- savings = gr.Number(label="Savings Amount ($)", value=1000)
37
- income = gr.Number(label="Monthly Income ($)", value=4000)
38
- bills = gr.Number(label="Monthly Bills ($)", value=2500)
39
- entertainment = gr.Number(label="Monthly Entertainment ($)", value=300)
40
- sales_skills = gr.Slider(label="Sales Skills (1โ€“5)", minimum=1, maximum=5, step=1, value=3)
41
- dependents = gr.Slider(label="Dependents (0โ€“6)", minimum=0, maximum=6, step=1, value=1)
42
- assets = gr.Number(label="Assets ($)", value=8000)
43
- age = gr.Number(label="Age", value=28)
44
-
45
- with gr.Column():
46
- output = gr.JSON(label="Prediction")
47
- btn = gr.Button("Predict")
48
- btn.click(
49
- readiness_predictor,
50
- inputs=[savings, income, bills, entertainment, sales_skills, dependents, assets, age],
51
- outputs=output
 
 
 
 
 
52
  )
 
 
 
 
 
 
53
 
54
  demo.launch()
 
 
6
  # Simple heuristic formula
7
  disposable_income = income - bills - entertainment
8
  score = (
9
+ (savings + assets) / 1000
10
+ + disposable_income / 500
11
+ + sales_skills * 2
12
+ - dependents
13
+ + (40 - abs(35 - age)) / 5
14
  )
 
 
15
  score = max(0, min(100, score))
16
 
17
  if score < 30:
18
+ prediction = "๐Ÿ”ด Low readiness"
19
  elif score < 60:
20
+ prediction = "๐ŸŸก Moderate readiness"
21
  else:
22
+ prediction = "๐ŸŸข High readiness"
23
 
24
+ return score, prediction
 
 
 
25
 
26
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
27
+ gr.Markdown(
28
+ """
29
+ # ๐Ÿš€ Entrepreneurial Readiness Predictor
30
+ Enter your details below to estimate your readiness to start a business.
31
+ """
32
+ )
33
 
34
  with gr.Row():
35
+ with gr.Column(scale=1):
36
+ savings = gr.Number(label="๐Ÿ’ฐ Savings Amount ($)", value=1000)
37
+ income = gr.Number(label="๐Ÿ’ต Monthly Income ($)", value=4000)
38
+ bills = gr.Number(label="๐Ÿ“‘ Monthly Bills ($)", value=2500)
39
+ entertainment = gr.Number(label="๐ŸŽ‰ Monthly Entertainment ($)", value=300)
40
+ sales_skills = gr.Slider(label="๐Ÿ—ฃ๏ธ Sales Skills (1โ€“5)", minimum=1, maximum=5, step=1, value=3)
41
+ dependents = gr.Slider(label="๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง Dependents (0โ€“6)", minimum=0, maximum=6, step=1, value=1)
42
+ assets = gr.Number(label="๐Ÿ  Assets ($)", value=8000)
43
+ age = gr.Number(label="๐ŸŽ‚ Age", value=28)
44
+ btn = gr.Button("๐Ÿ”ฎ Predict Readiness")
45
+
46
+ with gr.Column(scale=1):
47
+ score_bar = gr.Progress(label="Readiness Score", value=0, maximum=100)
48
+ prediction_text = gr.Label(label="Result")
49
+ info = gr.Markdown(
50
+ "โ„น๏ธ **What does this mean?**\n\n"
51
+ "The readiness score (0โ€“100) is a simple index based on savings, income, "
52
+ "expenses, skills, dependents, and age. Higher values suggest stronger "
53
+ "financial and personal preparedness for entrepreneurship.\n\n"
54
+ "- **0โ€“29:** Low readiness ๐Ÿ”ด\n"
55
+ "- **30โ€“59:** Moderate readiness ๐ŸŸก\n"
56
+ "- **60โ€“100:** High readiness ๐ŸŸข"
57
  )
58
+
59
+ btn.click(
60
+ readiness_predictor,
61
+ inputs=[savings, income, bills, entertainment, sales_skills, dependents, assets, age],
62
+ outputs=[score_bar, prediction_text]
63
+ )
64
 
65
  demo.launch()
66
+