Du, Lai, Hu & Ye (2026) on LINK: estimator families¶
Paper doi:10.64898/2026.08.04.742876; dataset DANDI:001201 version 0.251023.2336 (the cited version;
see 02_link_development.ipynb for the header, the full claims table and the data check).
This notebook tests estimator-family-link on the 18 development sessions.
| Claim | Status |
|---|---|
| estimator-family-link | tested; reading (b) of the nonlinear context (every setting of Methods 4.6) not run, see below |
import collections, resource, time, zlib
import numpy as np
import pandas as pd
import du2026 as d
PAPER = "du-2026"
def claim_seed(claim_id):
return zlib.crc32(f"{PAPER}/{claim_id}".encode())
T0 = time.time()
EXTRA = (1000, 2000, 3000, 4000)
assets = d.list_assets(d.LINK_ID, d.LINK_VERSION)
by_date = collections.defaultdict(list)
for a in assets:
by_date[d.session_date(a["path"])].append(a)
paired_dates = sorted(k for k, v in by_date.items() if len(v) > 1)
dev_assets = [a for k in paired_dates for a in sorted(by_date[k], key=lambda a: a["path"])]
print(f"{len(assets)} assets in DANDI:{d.LINK_ID} {d.LINK_VERSION}; {len(paired_dates)} dates with two sessions, {len(dev_assets)} development sessions")
def table(results, name, field="gain"):
return pd.DataFrame([{"date": r["date"], "task": r["task"], field: r[name][field]} for r in results])
312 assets in DANDI:001201 0.251023.2336; 9 dates with two sessions, 18 development sessions
sessions = [d.load_link_session(a["asset_id"], a["path"], signals=("SpikingBandPower", "ThresholdCrossings")) for a in dev_assets]
check = pd.DataFrame([dict(session=s.identifier, trials=len(s.trials), bins=len(s.timestamps),
dt_ms=1000 * float(np.median(np.diff(s.timestamps))),
sbp_range=f"{s.signals['SpikingBandPower'].min():.3g}..{s.signals['SpikingBandPower'].max():.3g}",
tcr_range=f"{s.signals['ThresholdCrossings'].min():.3g}..{s.signals['ThresholdCrossings'].max():.3g}",
pos_range=f"{s.position.min():.3g}..{s.position.max():.3g}",
vel_range=f"{s.velocity.min():.3g}..{s.velocity.max():.3g}") for s in sessions])
print(check.to_string())
print("tasks:", collections.Counter(s.task for s in sessions), "; units:", sessions[0].units)
print("The full data check of these sessions (duplicates, clock, velocity) is in 02_link_development.ipynb.")
del sessions
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
session trials bins dt_ms sbp_range tcr_range pos_range vel_range
0 2021-10-15_CO_nwb 375 21825 20.0 0.794..30.5 0..6 0.066..1 -0.0998..0.154
1 2021-10-15_RD_nwb 375 26836 20.0 0.725..25.7 0..7 0..1 -0.202..0.308
2 2022-02-25_RD_nwb 375 27135 20.0 0.719..16.6 0..6 0..1 -0.138..0.544
3 2022-02-25_CO_nwb 375 23816 20.0 0.719..15.8 0..6 0.0307..0.981 -0.12..0.153
4 2022-04-08_CO_nwb 375 22384 20.0 0.725..21.1 0..5 0.0529..1 -0.135..0.21
5 2022-04-08_RD_nwb 375 24997 20.0 0.7..21.3 0..5 0.028..1 -0.18..0.254
6 2022-04-15_CO_nwb 375 22568 20.0 0.725..23.5 0..7 0.0838..1 -0.113..0.215
7 2022-04-15_RD_nwb 375 24874 20.0 0.663..28.1 0..7 0.00575..1 -0.223..0.361
8 2022-04-29_RD_nwb 375 24682 20.0 0.731..21.1 0..7 0.0211..1 -0.245..0.228
9 2022-04-29_CO_nwb 375 22364 20.0 0.667..20.5 0..6 0.0789..1 -0.162..0.183
10 2022-05-13_RD_nwb 375 25290 20.0 0.75..19.4 0..6 0.0315..1 -0.219..0.219
11 2022-05-13_CO_nwb 375 23653 20.0 0.712..40.2 0..6 0.0785..0.952 -0.118..0.114
12 2022-08-10_CO_nwb 375 22292 20.0 0.769..24.9 0..7 0.0868..0.991 -0.123..0.153
13 2022-08-10_RD_nwb 375 23475 20.0 0.681..31 0..11 0..1 -0.182..0.261
14 2022-09-21_CO_nwb 375 22725 20.0 0.744..24.6 0..5 0.0383..1 -0.174..0.199
15 2022-09-21_RD_nwb 375 25015 20.0 0.706..25.1 0..5 0..1 -0.211..0.263
16 2022-11-02_RD_nwb 375 24786 20.0 0.706..21.6 0..8 0.0321..1 -0.272..0.236
17 2022-11-02_CO_nwb 375 22194 20.0 0.681..22.3 0..7 0.0615..1 -0.135..0.155
tasks: Counter({'CO': 9, 'RD': 9}) ; units: {'SpikingBandPower': 'volts', 'ThresholdCrossings': 'volts', 'index_position': 'flexion units', 'index_velocity': 'flexion units per time bin'}
The full data check of these sessions (duplicates, clock, velocity) is in 02_link_development.ipynb.
peak memory 0.62 GB
estimator-family-link¶
Separately penalized context and neural blocks and nonlinear context random features retained positive LINK task means, with magnitudes that differed between estimator families.
Block penalties: du2026.block_ridge, port of evaluate_block_ridge_audit (the pair of penalties
over the grid squared on the inner 80/20 split). Nonlinear context: du2026.rff_context, port of
evaluate_rff_context_audit (D = 256, g chosen from 0.25, 1, 4 with the penalties on the inner split,
five cross-fitting folds), the claims file's reading (a). Reading (b), every setting of Methods 4.6
(D 128/256/512 by three map seeds by g 0.25/1/4, 27 settings), was not run: one setting takes about
18 s per session and context, so 27 settings on 18 sessions and 4 signal-context pairs are about 27
times this notebook's nonlinear-context part (estimated 9 h on four processes). The fully nested
linear means for comparison are those of 02_link_development.ipynb; they are recomputed here for
the magnitudes.
jobs = []
for signal, tag in (("SpikingBandPower", "SBP"), ("ThresholdCrossings", "TCR")):
for context in ("geometry_tensor", "causal_history"):
build_kw = dict(signal=signal, context_mode=context, seed=20260726)
jobs.append((f"{tag}_{context}_block", build_kw, "block", {"seed": 20260726}, False))
jobs.append((f"{tag}_{context}_rffctx", build_kw, "rff_context", {"seed": 20260726}, False))
jobs.append((f"{tag}_{context}_nested", build_kw, "nested", {"seed": 20260726}, False))
t = time.time()
results = d.run_parallel(d.link_session_jobs, [(a["asset_id"], a["path"], jobs) for a in dev_assets])
print(f"{len(jobs)} fits per session on {len(results)} sessions in {(time.time() - t) / 60:.1f} min")
rows = []
for tag in ("SBP", "TCR"):
for context in ("geometry_tensor", "causal_history"):
for family, key in (("fully nested linear", "nested"), ("block penalties", "block"), ("nonlinear context", "rffctx")):
t_ = table(results, f"{tag}_{context}_{key}")
rows.append(dict(signal=tag, context=d.LADDER_NAMES[context], family=family, CO=t_[t_.task == "CO"].gain.mean(),
RD=t_[t_.task == "RD"].gain.mean(), all18=t_.gain.mean(), positive=int((t_.gain > 0).sum()),
min=t_.gain.min(), max=t_.gain.max()))
fam = pd.DataFrame(rows)
print(fam.to_string(float_format=lambda v: f"{v:.5f}"))
alt = fam[fam.family != "fully nested linear"]
print("reading (a), every CO and RD mean positive for both families:", bool((alt[["CO", "RD"]] > 0).all().all()))
print("reading (b), every 18-session mean positive for both families:", bool((alt.all18 > 0).all()))
print("nonlinear-context g chosen:", collections.Counter(r[f"{tag}_{ctx}_rffctx"]["gamma"] for r in results for tag in ("SBP", "TCR") for ctx in ("geometry_tensor", "causal_history")))
print("block penalty pairs chosen:", collections.Counter(r[f"{tag}_{ctx}_block"]["penalties"] for r in results for tag in ("SBP", "TCR") for ctx in ("geometry_tensor", "causal_history")).most_common(6))
print(f"run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
12 fits per session on 18 sessions in 13.4 min
signal context family CO RD all18 positive min max
0 SBP geometry by phase fully nested linear 0.01933 0.02085 0.02009 18 0.00283 0.03347
1 SBP geometry by phase block penalties 0.01953 0.01894 0.01924 18 0.00267 0.02970
2 SBP geometry by phase nonlinear context 0.01461 0.02006 0.01733 18 0.00087 0.03205
3 SBP plus measured-output history fully nested linear 0.00766 0.00980 0.00873 17 -0.00061 0.01894
4 SBP plus measured-output history block penalties 0.00759 0.00952 0.00856 18 0.00079 0.01671
5 SBP plus measured-output history nonlinear context 0.00491 0.00835 0.00663 17 -0.00262 0.01768
6 TCR geometry by phase fully nested linear 0.01042 0.01269 0.01155 17 -0.00382 0.02571
7 TCR geometry by phase block penalties 0.01071 0.01137 0.01104 17 -0.00325 0.02520
8 TCR geometry by phase nonlinear context 0.00686 0.01212 0.00949 17 -0.00478 0.02987
9 TCR plus measured-output history fully nested linear 0.00329 0.00510 0.00420 16 -0.00165 0.01246
10 TCR plus measured-output history block penalties 0.00306 0.00514 0.00410 18 0.00028 0.01286
11 TCR plus measured-output history nonlinear context 0.00075 0.00472 0.00274 15 -0.00209 0.01233
reading (a), every CO and RD mean positive for both families: True
reading (b), every 18-session mean positive for both families: True
nonlinear-context g chosen: Counter({0.25: 37, 1.0: 19, 4.0: 16})
block penalty pairs chosen: [((0.1, 10000.0), 49), ((0.1, 100000.0), 9), ((100.0, 10000.0), 5), ((1.0, 10000.0), 4), ((10.0, 10000.0), 3), ((100.0, 1000.0), 2)]
run time 13.8 min; peak memory 0.62 GB
Result: reproduced. Under both families every CO and RD mean is positive for SBP and TCR, geometry by phase and plus history (reading a), and so is every 18-session mean (reading b). The nonlinear-context means over 18 sessions (0.01733, 0.00663, 0.00949 and 0.00274 for SBP geometry, SBP history, TCR geometry and TCR history) are smaller than the fully nested linear ones (0.02009, 0.00873, 0.01155, 0.00420), and the block-penalty means lie close to the linear ones, so the magnitudes differ between families. Reading (b) of the nonlinear context, every setting of Methods 4.6, was not run.
The block-penalty Ridge above is solved exactly (Cholesky). The release solves it with lsqr (tolerance 1e-6), which is about five times slower and too slow for all 18 sessions within the cell time limit; the next cell compares the two solvers on one session (2021-10-15 CO, SBP, geometry by phase).
one = [a for a in dev_assets if d.session_date(a["path"]) == "2021-10-15"]
s = [x for x in (d.load_link_session(a["asset_id"], a["path"], signals=("SpikingBandPower",)) for a in one) if x.task == "CO"][0]
ds = d.build_link_dataset(s, signal="SpikingBandPower", context_mode="geometry_tensor", seed=20260726)
for solver in ("cholesky", "lsqr"):
t = time.time()
r = d.block_ridge(ds, seed=20260726, solver=solver)
print(f"{s.identifier}, SBP geometry by phase, {solver}: gain {r['gain']:.7f}, penalties {r['penalties']}, {time.time() - t:.0f} s")
del s, ds
print(f"run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
2021-10-15_CO_nwb, SBP geometry by phase, cholesky: gain 0.0261224, penalties (100.0, 10000.0), 13 s
2021-10-15_CO_nwb, SBP geometry by phase, lsqr: gain 0.0261220, penalties (100.0, 10000.0), 50 s run time 14.9 min; peak memory 0.62 GB
On this session the two solvers choose the same penalties and the gains differ by about 2e-7, far below the smallest block-penalty task mean (0.00306), so the solver cannot change a sign above. The other sessions were not run under lsqr.
Summary¶
| Claim | Outcome |
|---|---|
| estimator-family-link | reproduced (nonlinear context under the release's setting only) |
The block-penalty Ridge is solved exactly (Cholesky) where the release uses lsqr with tolerance 1e-6;
on one session the two give the same penalties and gains that differ by about 2e-7 (printed above). The nonlinear-context sensitivity follows the release's
evaluate_rff_context_audit (D = 256, g chosen on the inner split); the other settings Methods 4.6
lists were not run.