Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Earn Break — Adaptive Focus-Based Work Timer

Earn Break is an adaptive productivity system that changes how time feels based on how focused you actually are.

Instead of rigid rules like “work 25 minutes → rest 5 minutes”, Earn Break dynamically speeds up or slows down time depending on your real behavior:

  • Focused → time moves faster (you earn breaks sooner)
  • Distracted → time slows down
  • Idle → time slows down even more
  • Neutral → normal speed

The result is a system that rewards real focus and penalizes fake productivity.

Step 1 — Data Collection (Training Phase)

  • Collect raw signals
  • Aggregate features
  • Ask user for labels
  • Train the model
Screenshot 2025-12-27 210501 Screenshot 2025-12-27 210543

Step 2 — Inference (Prediction Phase)

  • Load the trained model
  • Aggregate features
  • Predict focus state
  • Adjust time speed automatically
Screenshot 2025-12-27 210154 Screenshot 2025-12-27 210002 Screenshot 2025-12-27 174201 Screenshot 2025-12-27 210342

Why this project exists

Most productivity tools measure time spent, not quality of attention.

People often:

  • Keep a timer running while scrolling

  • Move the mouse to look “busy”

  • Wait for the break instead of earning it Earn Break solves this by:

  • Observing real signals (window usage, browser behavior, camera cues)

  • Learning your focus patterns

  • Adapting time dynamically using machine learning

This makes productivity behavior-driven, not time-driven.

Architecture Overview

Backend (FastAPI)

  • Collects system, browser, and camera signals
  • Aggregates features into time windows
  • Trains and runs the ML model
  • Streams live state via WebSockets

Frontend (Vue + Tauri)

  • Displays adaptive time progress
  • Shows focus state, speed, and remaining time
  • Allows labeling during training phase
  • Runs as a desktop app

Why Machine Learning?

Focus is not a simple rule.

For example:

  • Being in a browser can mean research or doomscrolling
  • Looking away briefly doesn’t always mean distraction
  • Low mouse activity can mean deep thinking or being idle
  • Hard-coded rules fail here.

Machine learning allows the system to:

  • Combine many weak signals
  • Learn non-linear patterns
  • Adapt to individual behavior
  • Improve over time as more data is collected

Why this model?

The system uses a Random Forest classifier for focus detection.

Reasons:

  • Works well with small to medium datasets
  • Handles non-linear interactions between signals
  • Requires minimal preprocessing
  • Robust to noisy, real-world data
  • Provides feature importance (great for debugging and explainability)

📊 About the Datase

The model is trained on 60-second aggregated time windows.

Each row represents one minute of behavior, labeled as:

  • focused
  • neutral
  • distracted
  • idle

Example features:

  • Time spent on primary app
  • Context switching frequency
  • Browser usage and doomscroll probability
  • Face presence and gaze direction
  • Head motion, blink rate, fatigue signals
  • Time since last break

The dataset starts with manual labeling (human-in-the-loop), then transitions into fully automatic inference once a model is trained.

📈 Model Training Results

After collecting labeled behavioral data and training the focus classifier, the following evaluation was obtained on a held-out test set:

              precision    recall  f1-score   
  distracted       1.00      1.00      1.00        
     focused       0.86      1.00      0.92        
        idle       1.00      1.00      1.00        
     neutral       1.00      0.83      0.91        

    accuracy                           0.96        
   macro avg       0.96      0.96      0.96        
weighted avg       0.97      0.96      0.96        
  • Overall accuracy: 96%
  • Slight overlap between focused and neutral, which is expected in real human behavior
  • No class collapse or bias toward a single state

🔍 Feature Importance

=== Feature Importance ===
percent_time_on_primary        0.233
gaze_on_screen_ratio           0.153
percent_browser_time           0.138
doomscroll_prob_mean           0.134
time_away_from_primary         0.092
head_motion_mean               0.092
face_present_ratio             0.065
doomscroll_duration            0.049
num_context_switches           0.022
blink_per_min                  0.012
yawn_prob_mean                 0.008
time_since_last_break          0.002

🚀 Setup Instructions

1️⃣ Backend setup (Python)

Install dependencies:

pip install -r requirements.txt

Run the backend:

uvicorn main:app --reload --port 8000

2️⃣ Train the ML model

After collecting labeled data:

python -m ml.training.train_focus_model

This will:

  • Load the dataset
  • Train the focus classifier
  • Print evaluation metrics
  • Save the trained model

3️⃣ Frontend setup (Vue)

Install dependencies:

npm install

Run the dev server:

npm run dev

4️⃣ Tauri (Desktop App) setup

Install Rust:

winget install Rustlang.Rustup

Verify installation:

rustc --version
cargo --version

Install Tauri CLI:

npm install -D @tauri-apps/cli

Initialize Tauri:

npx tauri init

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages