--- title: RL Study Scheduler emoji: ๐Ÿ“š colorFrom: blue colorTo: green sdk: gradio sdk_version: "4.0.0" app_file: inference.py pinned: false --- # RL-Based Adaptive Study Scheduler > Q-learning agent vs heuristic baseline for cognitive-aware study planning. ## Demo Output ![Results](comparison_results.png) --- ## Overview This project models study planning as a sequential decision-making problem under cognitive and temporal constraints. Instead of static prioritization rules, a **Reinforcement Learning (RL) agent** learns to optimize task scheduling dynamically. **Core insight**: Adaptive scheduling under stress is not a sorting problem โ€” it's a **learning problem**. --- ## Results: RL vs Heuristic Baseline | Metric | RL Agent | Baseline | Winner | |--------|----------|----------|--------| | Avg Reward | Higher | Lower | RL โœ… | | Tasks Completed | More | Less | RL โœ… | | Missed Deadlines | Fewer | More | RL โœ… | | Avg Stress | Lower | Higher | RL โœ… | | Efficiency Score | Higher | Lower | RL โœ… | **Key finding**: RL outperforms heuristic scheduling under high stress and tight deadlines. --- ## Live Demo ๐Ÿค— **[Try it on Hugging Face Spaces](https://huggingface.co/spaces/dee2004/rl-study-scheduler)** --- ## MDP Formulation ### State Space ``` energy (0-100), stress (0-100), focus (0-100), pending tasks, min deadline, max difficulty ``` ### Action Space ``` DO_TASK | BREAK | SKIP | SWITCH ``` ### Reward Function | Event | Reward | |-------|--------| | Task completion | +10 | | Difficult task (difficulty > 7) | +5 | | Urgent task completed (deadline < 2) | +4 | | Missed deadline | -8 | | Burnout (energy < 20) | -10 | | High stress (> 80) | -5 | | Context switching | -2 | | Self-care break | +2 | --- ## How to Run ```bash pip install -r requirements.txt python compare.py # Train + compare python plot.py # Generate chart python inference.py # Launch Gradio UI locally ``` --- ## Project Structure ``` rl-study-scheduler/ โ”œโ”€โ”€ env.py # RL environment (MDP) โ”œโ”€โ”€ agent_q.py # Q-learning agent โ”œโ”€โ”€ baseline.py # Heuristic policy โ”œโ”€โ”€ reward.py # Reward function โ”œโ”€โ”€ compare.py # Training + comparison โ”œโ”€โ”€ eval.py # Metrics โ”œโ”€โ”€ plot.py # Visualization โ”œโ”€โ”€ llm_grader.py # LLM qualitative evaluation โ”œโ”€โ”€ inference.py # Gradio app โ””โ”€โ”€ requirements.txt ``` --- ## Why RL? | Requirement | Rule-based | RL | |---|---|---| | Sequential decisions | โŒ | โœ… | | Delayed rewards (rest now โ†’ no burnout later) | โŒ | โœ… | | Adapts to energy/stress state | โŒ | โœ… | | Learns from experience | โŒ | โœ… | --- ## Tech Stack - Python 3.8+ ยท NumPy ยท Matplotlib ยท Gradio ยท Anthropic API ## License MIT