features/dynamics¶
Temporal dynamics features: rolling means over 5/15-minute windows and inter-bucket deltas for interaction metrics.
DynamicsTracker is implemented as a slotted dataclass with the same
constructor arguments (rolling_5, rolling_15).
taskclf.features.dynamics
¶
Temporal dynamics: rolling means and inter-bucket deltas.
These features capture how interaction patterns change over time, which is a strong signal for distinguishing tasks that look similar in a single bucket but differ in trajectory (e.g. sustained coding vs. switching between reading and chatting).
All functions are pure — they take a history buffer and return a
single value (or None when insufficient history is available).
DynamicsTracker
dataclass
¶
Stateful tracker that accumulates per-bucket metrics and emits dynamics features.
Maintains rolling buffers for keys_per_min, clicks_per_min,
and mouse_distance so that each call to :meth:update returns
the computed rolling means and deltas for the latest bucket.
For batch mode, call :meth:compute_batch instead.
Source code in src/taskclf/features/dynamics.py
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
update(keys_per_min, clicks_per_min, mouse_distance)
¶
Record one bucket's metrics and return dynamics features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys_per_min
|
float | None
|
Current bucket's keys_per_min (may be None). |
required |
clicks_per_min
|
float | None
|
Current bucket's clicks_per_min (may be None). |
required |
mouse_distance
|
float | None
|
Current bucket's mouse_distance (may be None). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float | None]
|
Dict with keys matching the FeatureRow field names. |
Source code in src/taskclf/features/dynamics.py
compute_batch(keys_series, clicks_series, mouse_series, *, rolling_5=5, rolling_15=15)
staticmethod
¶
Compute dynamics features for an entire ordered sequence of buckets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys_series
|
Sequence[float | None]
|
keys_per_min values, one per bucket. |
required |
clicks_series
|
Sequence[float | None]
|
clicks_per_min values, one per bucket. |
required |
mouse_series
|
Sequence[float | None]
|
mouse_distance values, one per bucket. |
required |
rolling_5
|
int
|
Short rolling window size. |
5
|
rolling_15
|
int
|
Long rolling window size. |
15
|
Returns:
| Type | Description |
|---|---|
list[dict[str, float | None]]
|
List of dicts (one per bucket) with dynamics feature values. |
Source code in src/taskclf/features/dynamics.py
rolling_mean(history, window)
¶
Compute the mean of the last window non-None values in history.
Returns None when there are zero non-None values in the window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
deque[float | None]
|
Ordered buffer of recent metric values (newest last). |
required |
window
|
int
|
Number of recent entries to consider. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Mean of available values, or |
Source code in src/taskclf/features/dynamics.py
delta_from_previous(current, previous)
¶
Compute the change from previous to current.
Returns None when either value is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float | None
|
Current bucket's metric value. |
required |
previous
|
float | None
|
Previous bucket's metric value. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
|