Temporal Smoothing
Temporal posterior smoothing can be run directly on probability observations exported by time decoding:
python -m neureptrace.temporal_smoothing \
results/nod_animate_logistic_temporal_smoothing_all/observations/*_observations.csv \
--out-observations results/nod_animate_logistic_temporal_smoothing_all/temporal_smoothing/smoothed_observations.csv \
--out-metrics results/nod_animate_logistic_temporal_smoothing_all/temporal_smoothing/smoothed_metrics.csv \
--fit-window 0.1 0.8
For benchmark comparisons, prefer neureptrace.benchmark
--temporal-smoothing-dir. That runs smoothing on the exact held-out
observations from the decoder run and aggregates raw plus smoothed metrics in
one summary table. The companion provenance.csv records the raw and smoothed
emission modes side by side with selected accuracy, log loss, and ECE, so
calibration-only changes are easy to spot.
neureptrace.temporal_smoothing
metrics_from_probability_observations(observations, *, ece_bins=10)
Compute fold/time decoding metrics directly from probability observations.
This is useful after temporal smoothing because the updated posterior probabilities are the result object; averaging old per-fold CSV metrics would silently discard the temporal posterior.
Source code in src/neureptrace/temporal_smoothing.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
smooth_probability_observations(observation_csvs, *, fit_window=DEFAULT_FIT_WINDOW, stay_grid_size=200, mode='forward_backward', apply_window=None, emission_suffix=DEFAULT_EMISSION_SUFFIX, ece_bins=10, out_observations=None, out_metrics=None)
Replace decoder probabilities by sticky-switching temporal posteriors.
The sticky transition probability is fit without labels from held-out probability observations within
fit_window for each decoder/emission group, then applied to every complete sequence in that group.
forward_backward uses all times in a sequence, forward_only only uses observations up to each
time, and poststimulus_forward_only applies forward filtering only inside apply_window while
leaving probabilities outside that window unchanged.
The returned observation table preserves the NeuRepTrace probability-observation schema but changes
prob_class_* to temporally smoothed posterior probabilities and updates prediction columns.
Source code in src/neureptrace/temporal_smoothing.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |