DetectiveShadow commited on
Commit
c87a3cf
ยท
verified ยท
1 Parent(s): 64ad713

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -35
app.py CHANGED
@@ -1,55 +1,67 @@
1
  import gradio as gr
2
 
3
  def readiness_predictor(
4
- savings, income, bills, entertainment, sales_skills, dependents, assets, age
5
  ):
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()
55
-
 
1
  import gradio as gr
2
 
3
  def readiness_predictor(
4
+ savings, income, bills, entertainment, sales_skills, dependents, assets, age, idea_level
5
  ):
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
+ + idea_level * 3 # <-- new factor: strong weight for business idea quality
13
+ - dependents
14
+ + (40 - abs(35 - age)) / 5
15
  )
 
 
16
  score = max(0, min(100, score))
17
 
18
  if score < 30:
19
+ prediction = "๐Ÿ”ด Low readiness"
20
  elif score < 60:
21
+ prediction = "๐ŸŸก Moderate readiness"
22
  else:
23
+ prediction = "๐ŸŸข High readiness"
24
 
25
+ return score, prediction
 
 
 
26
 
27
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
28
+ gr.Markdown(
29
+ """
30
+ # ๐Ÿš€ Entrepreneurial Readiness Predictor
31
+ Enter your details below to estimate your readiness to start a business.
32
+ """
33
+ )
34
 
35
  with gr.Row():
36
+ with gr.Column(scale=1):
37
+ savings = gr.Number(label="๐Ÿ’ฐ Savings Amount ($)", value=1000)
38
+ income = gr.Number(label="๐Ÿ’ต Monthly Income ($)", value=4000)
39
+ bills = gr.Number(label="๐Ÿ“‘ Monthly Bills ($)", value=2500)
40
+ entertainment = gr.Number(label="๐ŸŽ‰ Monthly Entertainment ($)", value=300)
41
+ sales_skills = gr.Slider(label="๐Ÿ—ฃ๏ธ Sales Skills (1โ€“5)", minimum=1, maximum=5, step=1, value=3)
42
+ dependents = gr.Slider(label="๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง Dependents (0โ€“6)", minimum=0, maximum=6, step=1, value=1)
43
+ assets = gr.Number(label="๐Ÿ  Assets ($)", value=8000)
44
+ age = gr.Number(label="๐ŸŽ‚ Age", value=28)
45
+ idea_level = gr.Slider(label="๐Ÿ’ก Business Idea Quality (1โ€“10)", minimum=1, maximum=10, step=1, value=5)
46
+ btn = gr.Button("๐Ÿ”ฎ Predict Readiness")
47
+
48
+ with gr.Column(scale=1):
49
+ score_bar = gr.Slider(label="Readiness Score", minimum=0, maximum=100, value=0, interactive=False)
50
+ prediction_text = gr.Label(label="Result")
51
+ info = gr.Markdown(
52
+ "โ„น๏ธ **What does this mean?**\n\n"
53
+ "The readiness score (0โ€“100) is based on savings, income, "
54
+ "expenses, skills, dependents, age, and your business idea quality. "
55
+ "Higher values suggest stronger preparedness for entrepreneurship.\n\n"
56
+ "- **0โ€“29:** Low readiness ๐Ÿ”ด\n"
57
+ "- **30โ€“59:** Moderate readiness ๐ŸŸก\n"
58
+ "- **60โ€“100:** High readiness ๐ŸŸข"
59
  )
60
+
61
+ btn.click(
62
+ readiness_predictor,
63
+ inputs=[savings, income, bills, entertainment, sales_skills, dependents, assets, age, idea_level],
64
+ outputs=[score_bar, prediction_text]
65
+ )
66
 
67
  demo.launch()