Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 10 |
-
+ disposable_income / 500
|
| 11 |
-
+ sales_skills * 2
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
|
|