Documentation
¶
Overview ¶
Package regresample is the one rule over a regression's jackknife knobs (types.RegressionSpec JackknifeGroups / JackknifeBy), shared by the no-execute predict pass (internal/descriptor) and the regression engines (internal/processing/regression) so the two refuse the same requests with the same code, message and details. It reads the spec only — never a schema or a record — and imports neither side.
It also holds the leave-one-out cost threshold predict's PULSE_ADVISORY_JACKKNIFE_COST reads, so the figure the advisory names lives beside the knobs it recommends.
Index ¶
Constants ¶
const LeaveOneOutCostRows = 10000
LeaveOneOutCostRows is the cohort record count at or above which a leave-one-out jackknife (Resample "jackknife" with neither JackknifeGroups nor JackknifeBy) draws PULSE_ADVISORY_JACKKNIFE_COST. Leave-one-out refits the model once per row, so its cost grows with n²: a two-predictor binomial REG_GLM leave-one-out jackknife takes ~1.4 s at 2,000 rows (internal/processing/regression BenchmarkJackknife, Apple M-series), so ~35 s at 10,000 and ~10 min at 42,000, while a delete-a-group jackknife with SuggestedGroups groups takes ~0.6 s at 42,000 rows.
const PCGStream = 0x9E3779B97F4A7C15
PCGStream is the second PCG word every seeded draw in Pulse pairs with its seed: rand.NewPCG(seed, seed^PCGStream).
const SuggestedGroups = 50
SuggestedGroups is the jackknife_groups value the cost advisory proposes: a conventional replicate count (survey JK1 designs commonly use 20–100), whose standard error carries roughly 1/√(2(g − 1)) ≈ 10% relative noise from the replicate count — at g refits instead of n.
Variables ¶
This section is empty.
Functions ¶
func CanonicalJSON ¶
CanonicalJSON is the ONE canonical form a raw JSON slot takes before an rng_seed 0 derivation hashes it (DeriveSeed's spec bytes): object keys sorted (byte order of the decoded key, as encoding/json sorts a map), recursively, and whitespace dropped. Array order is kept, and every number and string keeps its text exactly as written — `0.10` stays `0.10`, a 20-digit integer keeps every digit (no float round-trip) — so Pulse's own markers (`{"$var": "x"}`, `{{axis}}`) pass through untouched. Two bodies that differ only in key order or whitespace therefore derive the same seed; any value change still moves it. A body already in sorted key order (no duplicate or escaped keys) canonicalises to its compact form — exactly what json.Marshal of the raw slot wrote before — so its seed does not move.
Empty or malformed input is returned as given: the strict decoder refuses it later with its own error, and nil stays nil so an omitempty slot stays absent.
func Check ¶
func Check(spec *types.RegressionSpec) *errors.CodedError
Check returns the PROCESSING_CONFIG refusal of spec's jackknife knobs, or nil. Rules (every regression type; REG_BAYES_LINEAR refuses Resample itself, so it never reaches a jackknife):
- jackknife_groups and jackknife_by are mutually exclusive.
- either one is read only by resample "jackknife".
- jackknife_groups, when set, is at least 2 (zero is absent). The upper bound (at most the fitted row count) is data and is judged by the engine (PROCESSING_REGRESSION_INSUFFICIENT_DATA).
func DeriveSeed ¶
DeriveSeed is the ONE rng_seed 0 derivation every seeded draw shares (REG_RESAMPLE's bootstrap and jackknife groups, MAT_SEM's bootstrap, the Compose sampling sweep): an FNV-1a hash of spec — the slot's wire form with its seed zeroed or dropped — then the row count, then every value cells yields, in row order, as its little-endian float64 bits (a null, ok false, as a NaN payload no value carries). A pure function of the request and the rows: the same request over the same data draws the same replicates whatever the worker or shard count, as long as the rows arrive in record order (a buffered slot's do). A nil cells yields no value.
It lives here, below both the engine and the no-execute callers (internal/sweep, predict), so every surface derives the identical seed.
func Grouped ¶
func Grouped(spec *types.RegressionSpec) bool
Grouped reports whether spec asks for a delete-a-group jackknife (JackknifeGroups or JackknifeBy set).
func LeaveOneOut ¶
func LeaveOneOut(spec *types.RegressionSpec) bool
LeaveOneOut reports whether spec runs the leave-one-out jackknife.
Types ¶
This section is empty.