Example 06: Polarized lead-vehicle intent
This experiment demonstrates a practical use for polarized state dynamics: maintaining a latent interpretation of a recent sensor trajectory after the instantaneous evidence has disappeared.
An adaptive cruise controller observes another vehicle through radar. A noisy range trajectory initially indicates one of two hidden hypotheses:
SLOWING— the lead vehicle is continuing a braking tendency;RECOVERING— the lead vehicle is recovering and increasing the gap again.
After six informative samples, both scenarios produce exactly the same settled radar input for seven more samples. Correct classification is then impossible from the current sample alone. The controller must retain the interpretation formed from the preceding trajectory.
STABLE is deliberately not a latent class in this experiment. Stability is directly
observable from current range-rate and belongs in the ordinary control path. Mixing
an instantaneous state with historical hypotheses produced a misleading three-class
task and obscured the property being tested.
Input features
A small deterministic radar front-end produces five values:
[normalized range, closing evidence, stable evidence, opening evidence, valid]
This is analogous to a cortex stage: the Cognia network is responsible for temporal
interpretation, not for relearning absolute value and sign operations. During the
settled tail, all five features are identical for SLOWING and RECOVERING.
Controlled ablation
The experiment contains two otherwise identical models:
lead-intent.cognia: polarization ON (alpha: 0.8);lead-intent-off.cognia: polarization OFF (alpha: 0.0).
They share:
- seed
6026; - 64-neuron fixed recurrent reservoir;
- 71 neurons and 616 synapses in total;
- radar features, training sequences and test sequences;
- softmax classification readout and training schedule;
- leak, gain,
eta,muand every connection weight.
Only the reservoir-to-readout classifier is trained. The reservoir topology and weights remain fixed.
Dataset separation
Training data:
- centres: 44, 50 and 56 metres;
- slopes: 0.8 and 1.4 metres per step;
- two deterministic noise profiles;
- five identical-input tail samples;
- 24 balanced sequences, 264 samples.
Test data:
- unseen centres: 47 and 53 metres;
- unseen slopes: 0.6, 1.1 and 1.7 metres per step;
- a third, stronger noise profile;
- seven identical-input tail samples;
- 12 balanced sequences, 156 samples.
The split tests interpolation, extrapolation to a steeper trend, new noise and longer state retention. Test rows never participate in training.
Expectations
If polarization adds useful latent context, the ON model should:
- outperform the OFF control during the identical-input tail;
- lose accuracy more slowly as tail depth increases;
- switch its inferred intent less often;
- preserve both classes rather than collapse to a majority prediction.
The informative prefix should remain easy for both models. The tail is the primary metric because it isolates memory from current-input classification.
Reproduction
Generate the checked-in deterministic datasets:
php lead-intent-gen.php --split=train --output=lead-intent-train.seq
php lead-intent-gen.php --split=test --output=lead-intent-test.seq
Train both variants:
.\cmake-build-debug\cognia_train.exe lead-intent.cognia lead-intent-train.seq 300 LeadIntent --sequential --save lead-intent.bin
.\cmake-build-debug\cognia_train.exe lead-intent-off.cognia lead-intent-train.seq 300 LeadIntent --sequential --save lead-intent-off.bin
Run and evaluate the ON model:
.\cmake-build-debug\cognia_serve.exe lead-intent.cognia lead-intent.bin --network LeadIntent --port 8097
php lead-intent-eval.php --url=http://127.0.0.1:8097
Repeat with the OFF model and another port. The evaluator uses the same pre-tanh classification logits as softmax training.
Measured results
Training used 300 epochs with deterministic sequence shuffling and a softmax cross-entropy classification head.
| Metric | Polarization ON | Polarization OFF | Difference |
|---|---|---|---|
| Accuracy after warm-up | 95.5% (126/132) | 90.2% (119/132) | +5.3 pp |
| Identical-current-input tail | 92.9% (78/84) | 84.5% (71/84) | +8.4 pp |
| Decision switches per scenario | 0.17 | 0.25 | -0.08 |
| Scenarios detected | 12/12 | 12/12 | equal |
Tail accuracy by depth:
| Tail step | ON | OFF |
|---|---|---|
| 1 | 100.0% | 100.0% |
| 2 | 100.0% | 91.7% |
| 3 | 91.7% | 91.7% |
| 4 | 91.7% | 83.3% |
| 5 | 91.7% | 75.0% |
| 6 | 91.7% | 75.0% |
| 7 | 83.3% | 75.0% |
Confusion matrices after warm-up:
ON predicted
expected SLOWING RECOVERING
SLOWING 66 0
RECOVERING 6 60
OFF predicted
expected SLOWING RECOVERING
SLOWING 66 0
RECOVERING 13 53
Interpretation
Both networks detect the initial trend, but the ordinary leaky reservoir forgets the
RECOVERING hypothesis sooner and falls back to SLOWING. Polarization roughly
halves these errors (13 to 6) and retains useful separation deeper into an interval
where the current sensor vector contains no class information.
This is the appropriate role for the current polarization mechanism: a continuous, temporary context that biases later computation. It is not a permanent mode bit and not a replacement for direct range-rate calculation.
The gain is meaningful but modest: +8.4 percentage points on the primary metric, not an order-of-magnitude improvement. A stronger claim would require repeated seeds, larger simulated traffic distributions and comparison with GRU/LSTM/state-space baselines. This example establishes the controlled ablation, not production safety.