infer.baseline¶
Rule-based baseline classifier (no ML).
Applies heuristic rules to feature windows in priority order:
- BreakIdle — lockscreen / OS login window (
app_category == "lockscreen") - BreakIdle — near-zero activity or long idle run
- ReadResearch — browser foreground with high scroll and low typing
- Build — editor/terminal foreground with high typing and shortcuts
- Mixed/Unknown — fallback reject label
Rule 0 fires when the foreground app is an OS lock screen (macOS
loginwindow, Windows LockApp.exe, Linux screen lockers). Since no
productive task is possible while the screen is locked, this overrides
all other signals unconditionally.
This establishes the cold-start performance floor that ML models must beat.
Thresholds¶
All thresholds are defined in taskclf.core.defaults and can be overridden
per-call:
| Constant | Default | Used by |
|---|---|---|
BASELINE_IDLE_ACTIVE_THRESHOLD |
5.0 s | BreakIdle rule |
BASELINE_IDLE_RUN_THRESHOLD |
50.0 s | BreakIdle rule |
BASELINE_SCROLL_HIGH |
3.0 events/min | ReadResearch rule |
BASELINE_KEYS_LOW |
10.0 keys/min | ReadResearch rule |
BASELINE_KEYS_HIGH |
30.0 keys/min | Build rule |
BASELINE_SHORTCUT_HIGH |
1.0 shortcuts/min | Build rule |
taskclf.infer.baseline
¶
Rule-based baseline classifier (no ML).
Applies heuristic rules to feature windows in priority order:
- BreakIdle — near-zero activity or long idle run
- ReadResearch — browser foreground with high scroll and low typing
- Build — editor/terminal foreground with high typing and shortcuts
- Mixed/Unknown — fallback reject label
This establishes the cold-start performance floor that ML models must beat.
classify_single_row(row, *, idle_active_threshold=BASELINE_IDLE_ACTIVE_THRESHOLD, idle_run_threshold=BASELINE_IDLE_RUN_THRESHOLD, scroll_high=BASELINE_SCROLL_HIGH, keys_low=BASELINE_KEYS_LOW, keys_high=BASELINE_KEYS_HIGH, shortcut_high=BASELINE_SHORTCUT_HIGH)
¶
Classify a single feature row using heuristic rules.
Rules are applied in strict priority order so that BreakIdle always overrides other signals (e.g. an idle browser window is BreakIdle, not ReadResearch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
A pandas Series with feature columns from |
required |
idle_active_threshold
|
float
|
Max |
BASELINE_IDLE_ACTIVE_THRESHOLD
|
idle_run_threshold
|
float
|
Min |
BASELINE_IDLE_RUN_THRESHOLD
|
scroll_high
|
float
|
Min |
BASELINE_SCROLL_HIGH
|
keys_low
|
float
|
Max |
BASELINE_KEYS_LOW
|
keys_high
|
float
|
Min |
BASELINE_KEYS_HIGH
|
shortcut_high
|
float
|
Min |
BASELINE_SHORTCUT_HIGH
|
Returns:
| Type | Description |
|---|---|
str
|
A label string: one of the :class: |
str
|
data: |
Source code in src/taskclf/infer/baseline.py
predict_baseline(features_df, *, idle_active_threshold=BASELINE_IDLE_ACTIVE_THRESHOLD, idle_run_threshold=BASELINE_IDLE_RUN_THRESHOLD, scroll_high=BASELINE_SCROLL_HIGH, keys_low=BASELINE_KEYS_LOW, keys_high=BASELINE_KEYS_HIGH, shortcut_high=BASELINE_SHORTCUT_HIGH)
¶
Apply heuristic rules to every row and return one label per window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features_df
|
DataFrame
|
Feature DataFrame conforming to |
required |
idle_active_threshold
|
float
|
Threshold for |
BASELINE_IDLE_ACTIVE_THRESHOLD
|
idle_run_threshold
|
float
|
Threshold for |
BASELINE_IDLE_RUN_THRESHOLD
|
scroll_high
|
float
|
Threshold for |
BASELINE_SCROLL_HIGH
|
keys_low
|
float
|
Upper bound on |
BASELINE_KEYS_LOW
|
keys_high
|
float
|
Lower bound on |
BASELINE_KEYS_HIGH
|
shortcut_high
|
float
|
Lower bound on |
BASELINE_SHORTCUT_HIGH
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Predicted label per row (same length as features_df). |
Source code in src/taskclf/infer/baseline.py
run_baseline_inference(features_df, *, smooth_window=DEFAULT_SMOOTH_WINDOW, bucket_seconds=DEFAULT_BUCKET_SECONDS, idle_active_threshold=BASELINE_IDLE_ACTIVE_THRESHOLD, idle_run_threshold=BASELINE_IDLE_RUN_THRESHOLD, scroll_high=BASELINE_SCROLL_HIGH, keys_low=BASELINE_KEYS_LOW, keys_high=BASELINE_KEYS_HIGH, shortcut_high=BASELINE_SHORTCUT_HIGH)
¶
Predict, smooth, and segmentize using the rule baseline.
Mirrors :func:taskclf.infer.batch.run_batch_inference but uses
heuristic rules instead of a trained model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features_df
|
DataFrame
|
Feature DataFrame (must contain feature columns
and |
required |
smooth_window
|
int
|
Window size for rolling-majority smoothing. |
DEFAULT_SMOOTH_WINDOW
|
bucket_seconds
|
int
|
Width of each time bucket in seconds. |
DEFAULT_BUCKET_SECONDS
|
idle_active_threshold
|
float
|
Threshold for |
BASELINE_IDLE_ACTIVE_THRESHOLD
|
idle_run_threshold
|
float
|
Threshold for |
BASELINE_IDLE_RUN_THRESHOLD
|
scroll_high
|
float
|
Threshold for |
BASELINE_SCROLL_HIGH
|
keys_low
|
float
|
Upper bound on |
BASELINE_KEYS_LOW
|
keys_high
|
float
|
Lower bound on |
BASELINE_KEYS_HIGH
|
shortcut_high
|
float
|
Lower bound on |
BASELINE_SHORTCUT_HIGH
|
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[Segment]]
|
A |