Spaces:
Sleeping

File size: 2,729 Bytes
eaad5ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# coding: utf-8

# In[4]:


import gradio as gr

def recommend(age, grade, study_hours, sleep_hours, junk_food_score, activity_level, interests):
    # Convert inputs to correct types
    age = int(age)
    study_hours = float(study_hours)
    sleep_hours = float(sleep_hours)
    junk_food_score = int(junk_food_score)
    interests = interests.lower()
    
    # 🎭 Extracurricular Recommendation
    if "music" in interests:
        extracurricular = "Join a music club or explore online classes."
    elif "drawing" in interests:
        extracurricular = "Join an art or sketching group."
    elif "sports" in interests:
        extracurricular = "Try for the school team or join local sports academies."
    else:
        extracurricular = "Explore school clubs that match your interest."

    # πŸŽ“ Academic Feedback
    if study_hours >= 5:
        academic_feedback = "Excellent dedication! Keep up the good work."
    elif study_hours >= 3:
        academic_feedback = "Good progress. Slight improvement in time management recommended."
    else:
        academic_feedback = "Needs to focus more on studies."

    # 🍽 Food Lifestyle
    if junk_food_score > 7:
        food_advice = "High junk intake. Reduce snacks and drink more water."
    elif junk_food_score > 4:
        food_advice = "Moderate junk intake. Watch portions and increase fruits/veggies."
    else:
        food_advice = "Healthy diet. Keep it up!"

    # 😴 Attitude Suggestion
    if sleep_hours >= 8:
        attitude = "Great rest habits. Maintain consistency!"
    elif sleep_hours >= 6:
        attitude = "Stable but can improve with better rest."
    else:
        attitude = "Low rest. Try to improve your sleep schedule for better focus."

    # Final response
    return (
        f"🎭 Recommended Extracurricular Activity: {extracurricular}\n\n"
        f"πŸŽ“ Academic Performance Feedback: {academic_feedback}\n\n"
        f"🍽 Food Lifestyle Advice: {food_advice}\n\n"
        f"😴 Attitude Suggestion: {attitude}"
    )

# Gradio UI
demo = gr.Interface(
    fn=recommend,
    inputs=[
        gr.Number(label="Age"),
        gr.Textbox(label="Grade"),
        gr.Textbox(label="Study Hours (e.g. 3.5)"),
        gr.Textbox(label="Sleep Hours (e.g. 6.5)"),
        gr.Textbox(label="Junk Food Score (1-10)"),
        gr.Dropdown(["Low", "Medium", "High"], label="Activity Level"),
        gr.Textbox(label="Interests (comma separated, e.g. music, drawing)")
    ],
    outputs="text",
    title="πŸŽ“ Student Recommendation System",
    description="Enter student details to get dynamic recommendations on extracurriculars, academics, food lifestyle, and attitude."
)

demo.launch()


# In[ ]: