Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,61 +6,50 @@ def readiness_predictor(
|
|
| 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 = "
|
| 19 |
elif score < 60:
|
| 20 |
-
prediction = "
|
| 21 |
else:
|
| 22 |
-
prediction = "
|
| 23 |
|
| 24 |
-
return
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
with gr.Blocks(
|
| 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(
|
| 36 |
-
savings = gr.Number(label="
|
| 37 |
-
income = gr.Number(label="
|
| 38 |
-
bills = gr.Number(label="
|
| 39 |
-
entertainment = gr.Number(label="
|
| 40 |
-
sales_skills = gr.Slider(label="
|
| 41 |
-
dependents = gr.Slider(label="
|
| 42 |
-
assets = gr.Number(label="
|
| 43 |
-
age = gr.Number(label="
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 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 |
|
|
|
|
| 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 |
|