Manuscript Offprint
arXiv:2610.40579When Imputation Changes the Nearest Neighbor: Exact Certification of Similarity Retrieval for Incomplete Sensor Time Series
Jianru Shen
Columbia University
New York, NY, USA
Abstract—Sensor time series routinely reach similarity search with missing values, and the retrieved neighbours then depend on how the gaps were filled. We ask which retrieval conclusions hold for every admissible completion of an incomplete query. For a family of window-minimum distances that contains the L1 distance as its separable end we give a pairwise certificate that one candidate is strictly closer than another, a guaranteed candidate set that contains every possible nearest neighbour, and a certificate that a nearest-neighbour label cannot change. The guarantees hold uniformly over the specified box and apply to the true query whenever it lies inside. At the separable end a closed form is known, but beyond it the worst-case gap need not be attained at a corner of the box. We prove a finite reduction to critical values, give an exact interval dynamic programme for the worst-case ranking gap, and a quadratic-time fast layer of valid bounds and feasible witnesses, supported by an exact criterion for when the feature-box relaxation is tight. On three traffic-sensor collections with real gap patterns, linear interpolation changes the nearest neighbour in 15 to 33 percent of the queries. At the full band the feature-box relaxation misses up to 14 percent of the exactly stable boundary pairs, whereas fixed-completion and Monte Carlo checks issue false certificates. The fast layer resolves about 90 percent of all tested boundary pairs without dynamic programming, and on paired network-scale queries the exact method is 82 to 110 times faster than the programme alone. Label certificates transfer to three public benchmarks, and the band width trades forecasting accuracy and certification coverage for lower imputation sensitivity, with dataset-dependent crossovers.
Index Terms—similarity search, missing values, time series, certified retrieval, dynamic programming, sensor data
I. INTRODUCTION
A sensor produces one series per day, and a common way to use such data is to look up similar days. An operator asks which past afternoons looked like today on this loop detector, a forecaster averages the hours that followed those afternoons, and a classifier takes the label of the closest day. When today has gaps, practice fills them by some rule and then ranks the archive as if the data were complete. The ranking then belongs to the rule as much as to the data. On three public traffic-sensor collections with real gap patterns, filling the gaps by linear interpolation returns a nearest neighbour different from the one the true series would return for 15% to 33% of the queries, and the historical mean does so for up to 44%.
This paper asks a question that does not depend on any rule. Given only bounds on the missing values, which retrieval conclusions hold no matter how the gaps are filled. We answer it for a family of window-minimum distances, which compare two series through the minimum of every time span up to a chosen width. One end of the family is the L1 distance, where every coordinate is compared on its own. The other end compares the deepest congestion in every span, a natural quantity for speed data. In between, a band width trades one for the other. We do not claim that this family beats L1 or warping distances. It carries a window semantics that some users want, and it is a simple nonseparable family in which exact certification is needed, because the worst completion need not lie at a corner of the box. The unit of every guarantee is the worst-case ranking gap of a pair of candidates over the box, certified when negative, and the two-slot example in Fig. 1 shows a worst-case gap not attained at a corner, which corner-only checks miss. Section VI shows where the augmented fixed-completion and Monte Carlo baselines fail.
Our goal is exact certification for a distance family with overlapping-window semantics, and the guarantees hold uniformly over the specified uncertainty box and apply to the true query whenever it lies in that box. In summary, this paper makes three contributions.
• Exact worst-case analysis. We prove a finite reduction to critical values and derive an exact interval dynamic programme that computes the worst-case gap in time and space for the value, where is the number of critical values.
• Fast and complete pairwise certification. We characterise exactly when the feature-box relaxation is tight and construct a witness completion in time. Combining the bound, witness checks and the programme gives ExactCert, which decides whether for every pair and supports sound candidate sets and sufficient label-invariance certificates.
• Evaluation on six datasets. We quantify imputation-induced retrieval changes, certification quality, computational cost and band-width trade-offs on three traffic datasets with real gap patterns and three UCR benchmarks.
(a)

(b)

Fig. 1. Overview. (a) The two-slot example of Section IV. Filled circles are the two corners of the box, where is closer, but every completion with in the shaded range makes closer, so checking only the corners is insufficient. (b) ExactCert. The fast layer certifies a pair from a cheap bound or refutes it from a few witness completions, the exact layer runs the dynamic programme on the pairs that remain, and every outcome is an exact decision of . The pairwise verdicts assemble into the derived guarantees.
Certain answers and certain predictions. Certain answers over incomplete databases return what holds in every possible world [5]. Certain predictions carry the idea to nearest neighbour classifiers with uncertain training data [6], and Fan and Koutris [7] analyse robustness over subset repairs under functional dependencies, with a dichotomy between polynomial and coNP-hard cases. Both keep the test query fixed. Here the gallery is complete and one uncertain query is shared by all distances, with further coupling from the overlapping window minima.
Min-max regret with interval data. The worst-case gap is the maximum regret of choosing over when the data lie in a box. Min-max regret optimisation studies such worst cases for combinatorial problems with interval costs [8], [9]. For sum objectives the worst scenario sits at interval endpoints and several bottleneck problems are polynomial, while shortest paths and spanning trees become hard [10]. The example of Section IV shows that endpoints do not suffice for window minima, and Theorem 8 shows that the problem is nevertheless polynomial on a path.
Threshold decomposition and guaranteed mining under gaps. Window minima are flat erosions, and the proof of Lemma 7 uses the fact that they commute with monotone maps, which is threshold decomposition in the theory of median and stack filters [11], [12]. The mean absolute error of stack filters decomposes over thresholds in the same way [13]. The new element here is the dynamic programme that handles the coupling between thresholds and windows. Guaranteed mining under missing data has been studied for motif discovery, where an admissible bound produces no false
TABLE I MAIN NOTATION
| Symbol | Meaning |
|---|---|
| uncertainty box of the query, completions | |
| windows with and the window minimum | |
| window-minimum distance and the ranking gap | |
| worst-case gap over , stable when negative | |
| candidate window minima and the per-window term | |
| critical values, | |
| feature box of window | |
| independent bound, relaxation bound, witness | |
| dominators and the guaranteed candidate set |
negatives [14]. Our candidate sets are admissible in the same sense for retrieval.
Practice with missing sensor data. Practitioners fill gaps by interpolation, carry forward, historical means, nearest neighbour imputation [15] or learned imputers such as BRITS and SAITS [16], [17], and then retrieve as if the data were complete. Similar-day retrieval itself is a long-standing non-parametric forecaster for traffic [18], [19], and tuned dynamic time warping is the usual accuracy reference [20], [21]. The paper does not propose an imputer or a forecaster. It measures how much the retrieved answer depends on the imputer and certifies the part that does not.
III. PROBLEM AND GUARANTEES
This section fixes the setting, the distance family and the three guarantees that the rest of the paper computes. Table I collects the main notation.
A. Setting
A query is a sensor series of length with missing slots, and a gallery holds complete series of the same length, for example the earlier days of the same sensor. We ask which conclusions of nearest-neighbour retrieval hold for every admissible way of filling the gaps.
Definition 1 (Uncertain query and completions). An uncertain query is a box with . An observed slot has and a missing slot has a nontrivial interval. A completion is any .
The box is not a probability model. No completion is preferred, no smoothness across slots is assumed, and every guarantee below holds for all completions at once and is conditional on the true series lying in Q.
B. Distance family
Definition 2 (Window-minimum distance). For a band width let be the set of windows with and , and let . The distance between a query and a candidate is
The band width interpolates between two familiar ends. At the windows are the single slots and (1) is the L1 distance divided by . At every window counts and the distance compares the full multiscale profile of minima, which for speed data is the deepest congestion inside every time span. The normalisation by does not affect any ranking or sign below and is dropped in the implementation, which works on integer codes.
C. Guarantees
For two candidates and write , and , so that
Definition 3 (Certificates). The worst-case ranking gap of the ordered pair over Q is
The pair is stable when , since then is strictly closer than for every completion. When the candidate is never farther but some completion ties them, and when some completion makes closer. Candidate dominates candidate when . For a set of dominators and an integer the guaranteed candidate set is
When candidates carry labels, the label y is certified invariant if some candidate a with label y satisfies for every candidate b whose label differs from y.
The maximum in (3) exists because is continuous and Q is compact. Two consequences are used throughout. Any feasible completion gives the lower bound , so a single completion with refutes stability. Any upper bound on that is negative certifies stability. Algorithms that only ever certify from valid upper bounds are sound, and an algorithm that also decides exactly whether is complete.
The guarantees rest on four assumptions. A1, every candidate in G is complete. A2, the box is bounded and closed and contains the true query. A3, the band width is fixed and nothing is renormalised after completion. A4, slots are compared at fixed time positions, so no time warping is allowed. A1 and A4 are limitations that Section VII returns to.
D. The separable end and the two derived guarantees
Proposition 4 (Closed form at ). For ,
which is computable in time.
Proof. At the gap (2) is the sum of the terms , each depending on one coordinate. The function is piecewise linear with breakpoints at and , constant outside the interval between them and monotone inside it, nondecreasing when and nonincreasing otherwise. A monotone function on an interval attains its maximum at an endpoint, and the coordinates can be chosen independently.
The same endpoint argument covers the squared Euclidean distance, whose gap is linear in each coordinate. Coordinate-wise reasoning of this kind underlies domination tests for uncertain objects under such distances [1]. Nothing of the sort holds for , where a single coordinate enters up to overlapping windows and the maximum of (2) need not be attained at a corner of the box. Section IV starts from such an example.
Proposition 5 (Guaranteed candidate sets). Let and let be any top-k set of , that is, a set of candidates such that no candidate outside is strictly closer to than a candidate inside . Then for every . The inclusion still holds when in (4) is replaced by any upper bound on .
Proof. Let . Every candidate strictly closer to than belongs to , so at most candidates are strictly closer than . If then is strictly closer than under every completion, in particular under . Hence fewer than dominators satisfy and . Replacing by an upper bound can only remove certified dominations, which enlarges the set.
For the set contains the true nearest neighbour of every completion, and certifies the nearest neighbour outright. A test that declares dominations that do not hold, for instance because it inspects only a sample of completions, can exclude the true nearest neighbour. Section VI measures how often this happens.
Proposition 6 (Label invariance). If the label y is certified invariant in the sense of Definition 3, then for every completion every nearest neighbour of x in G carries the label y.
Proof. Fix and let be a nearest neighbour of . If the label of differed from , the certifying candidate would satisfy , contradicting the choice of .
The certificate says that the prediction cannot change, not that it is correct, and it is sufficient rather than necessary. It connects the pairwise gap to certain predictions for nearest-neighbour classifiers over incomplete data [6], where the training tuples are uncertain and the query is fixed. Here the query is uncertain, which couples the distances to all candidates through one completion and couples the coordinates through the window minima.
IV. EXACT CERTIFICATION
Two facts drive this section. For the worst completion need not sit at a corner of the box, so endpoint checks are not enough, and yet only finitely many completions matter, which is what makes an exact algorithm possible.
Example. Take , , a query with , and candidates and . The three windows give , which equals at , for every and at . Both endpoints of the box make closer, but the completions with make closer, so and the pair is not stable. The coupling comes from the window , whose minimum saturates at once while the window keeps moving.
A. Finite reduction
Let be the set of critical values and let , with sorted elements .
Lemma 7 (Finite reduction). There is a maximiser of over with for every .
Proof. Let and suppose some coordinates lie strictly between two consecutive critical values, . Since and belong to and , we have and , so the whole interval is feasible for each such coordinate. Draw uniformly from and let map a value to if , to if , and to otherwise. The map is nondecreasing on , so it commutes with minima, for every window, and .
Every breakpoint or of a term is a window minimum of a or b and hence a coordinate of a or b, so it lies in S and is affine on . For a value v in the open interval, with probability and otherwise, so and, by affinity, . For v outside the open interval . Summing over windows gives , so some satisfies . The rounded completion has no coordinate in and no coordinate has left S. Repeating the step for each of the open intervals produces a completion on the grid whose value is at least . Applying this to a maximiser, which exists by compactness, proves the claim.
The argument needs only that window minima commute with nondecreasing maps and that every is piecewise linear with breakpoints in S, so it also covers window maxima and other order statistics. The dynamic programme below is the part that needs minima over contiguous windows.
B. Exact dynamic programme
By Lemma 7 the coordinates may be restricted to S. The programme scans the critical values from the largest downwards and, inside each interval of positions, decides where the minimum sits. For and let be the largest value of
over assignments of the coordinates with and for every , with when no such assignment exists, for the empty interval and . Let
be the contribution of the windows inside that contain the position when all of them have minimum . Let be the positions where the value is admissible.
Theorem 8 (Exact worst-case gap). For all and ,
with when no position p is admissible, and . The values can be computed in time and space.
Proof. Fix and split the admissible assignments by their minimum over . If the minimum exceeds , every coordinate is at least and the assignment is admissible for level , so the best such value is . Otherwise the minimum equals and is attained at some position , which requires . Every window inside that contains then has minimum exactly , because all coordinates are at least and , and these windows contribute . The remaining windows lie inside or inside , and the coordinates there form admissible assignments for the same level , since they are at least and may equal it. Conversely, any two admissible assignments of and at level together with form an admissible assignment of whose value is the sum in (9). Induction on gives (8) and (9), and is the maximum of (6) over the whole grid, which equals by Lemma 7.
For the cost, fix a level . Two-dimensional prefix sums of the array over the band cost and afterwards return each in constant time, so the intervals and the positions per interval cost per level and over the levels. Level depends only on levels and , so two tables suffice when only the value is needed.
Two remarks. The recurrence lets both sides of the split reach the value again, so ties among coordinates need no perturbation, and recovering a worst completion rather than its value raises the space to . With integer codes every quantity in the programme is an integer and the sign of is decided exactly, which is the property the certificates in Definition 3 need.
The programme is polynomial but not cheap, at about a millisecond per pair for n = 48 and forty milliseconds for n = 144 in our implementation. Most pairs do not need it. The next section develops a quadratic-time fast layer and characterises exactly when the feature-box relaxation is tight.
V. FAST LAYER AND ALGORITHM
For every completion and every window the minimum lies in the feature box , and the two ends are attained by and . Relaxing the coupling between windows gives two upper bounds on that cost time each. The independent bound treats the two distances separately,
and the relaxation bound maximises every term of (2) on its own,
Each maximum in (11) is attained at an end of the feature box or at a breakpoint or . Clearly , so a negative value of either bound certifies the pair. The bound ignores that the same coordinates feed many windows. The following result says exactly when this loses nothing, and produces a completion as a by-product.
A. When the relaxation is exact
Call a window increasing when and , and set for such windows
where the inner maximum runs over the increasing windows that contain t and is when there are none.
Theorem 9 (Exactness of the relaxation). The completion lies in Q, and if and only if .
Proof. Feasibility holds because for every in the window. Equality holds if and only if some completion attains every maximum in (11) at once, so we describe, for each window, the set of completions that attain its maximum. A window with has and imposes nothing. For the term is constant below , increasing between and and constant above . If the term is constant on the feature box and imposes nothing. Otherwise its maximum is attained exactly when , that is, when for every in the window. For the term is nonincreasing on the whole line, so lowering any coordinate can only raise its value, and no condition needs to be recorded for such windows. The increasing windows impose a conjunction of lower bounds on coordinates, and is the coordinate-wise smallest point of that satisfies all of them.
If then . Conversely, if , let attain every maximum in (11). Then satisfies all lower bounds, so coordinate-wise. For a window with this gives and hence , which is the maximum, and the reverse inequality holds because is feasible. The increasing windows attain their maxima at by construction, and the remaining windows impose nothing, so .
The completion costs time through and , where is for windows that are not increasing, out-of-range entries are , and the table is filled in order of decreasing window length, because every window that contains other than itself contains or . Theorem 9 decides in quadratic time whether the cheap bound is already the exact gap.
B. Witnesses and the certification procedure
By Definition 3, any feasible completion with refutes stability. The fast layer tries five such witnesses, the completion , the two corners and , the midpoint of the box, and the linear interpolation of the observed slots clipped to the box. Each costs one evaluation of (2). On integer-coded inputs all five are integer points of the box, the midpoint by integer division and the interpolation by rounding and clipping, so every is evaluated in exact integer arithmetic and no witness verdict depends on floating point. The corner sets every gap to the lowest admissible value and pulls every window minimum that touches a gap to the bottom of its feature box, which is a strong perturbation at large , whereas raises coordinates only where the increasing windows need it. Section VI shows that the two are complementary.
Algorithm 1 combines the pieces and is stated for integer-coded inputs. For real-valued boxes the witness checks use the unrounded midpoint and interpolation, which are feasible, and nothing else changes. Every CERTIFIED answer rests on a valid upper bound or on the exact gap, and every REFUTED answer rests on a feasible completion or on the exact gap, so the procedure is sound and complete for deciding whether , which is the strict stability of Definition 3. It does not separate from , since a witness with already refutes strict stability. When , Theorem 9 identifies the exact gap as , and Algorithm 1 returns the corresponding decision. The cost is per pair whenever the fast layer decides, and otherwise.
Algorithm 1 PairCertify(Q, a, b, )
1: if then 2: return CERTIFIED if (5) is negative, else REFUTED 3: end if 4: compute by (11) and by (12) 5: if then 6: return CERTIFIED 7: end if 8: for z in , , u, integer midpoint of Q, do 9: if then 10: return REFUTED 11: end if 12: end for 13: compute by Theorem 8 14: return CERTIFIED if , else REFUTED
The guaranteed candidate set of Definition 3 needs a set of dominators. We rank the gallery by and take the first candidates as , then keep every that fewer than dominators defeat under Algorithm 1, stopping the tests of a candidate as soon as dominators defeat it. The interpolation needs at least one observed slot, which every query in our experiments has. The nominal completion chooses the dominators and serves as one witness, and Proposition 5 holds for any choice, so a poor can enlarge the set but never breaks its guarantee. For the label certificate we take the label of the first ranked candidate, the first three ranked candidates with label , and test each of them against all candidates with a different label, hardest first in the nominal order, stopping at the first refutation. A candidate set costs at most calls of Algorithm 1, and the label certificate at most three times the number of differently labelled candidates.
VI. EXPERIMENTS
A. Setup
Data. Table III lists the datasets. METR-LA, PEMS-BAY and PeMSD7-M are five-minute loop-detector speeds from the releases of [22] and [23], with zeros treated as missing as in those releases. Together they hold 760 sensors and 93 165 sensor-days. The three labelled UCR sets [24] add classification tasks. DodgerLoopDay [25] contains real gaps and is aggregated to fifteen-minute block sums, so that a bin with missing points becomes a training-bounded interval. ItalyPowerDemand and Wafer are complete and are used with controlled deletion.
Representation and boxes. Speeds are coded as integers at one eighth of a mile per hour, so all certificates are decided in exact integer arithmetic. Codes are rounded to the nearest integer, and every guarantee and every ground truth below refers to the coded data. Each traffic dataset is split in time, the first 80% of days form the history and the last 20% the test period. A query is one test day of one sensor in the afternoon window, and its gallery holds the complete history days of the same sensor, with median size 82, 144 and 35 for the three sets. A missing slot receives a history-bounded box from zero to the largest speed the sensor recorded in its history, a convention rather than a physical limit. The true value then lies inside the box for 100%, 99.7% and 100% of the queries used below. To have ground truth we take complete test days and transplant real gap patterns onto them. The pattern pool holds the 2773 partially missing METR-LA windows with one to 24 missing slots, median six, and 78% of them are a single contiguous block. Each experiment uses 1000 such queries per dataset with a fixed seed. The four band widths share the same queries, so the main experiment evaluates 3000 queries at four band widths, 12000 query and band-width combinations. The 621 METR-LA test days with real gaps are evaluated separately, without ground truth.
Band widths and baselines. We report , from L1 to the full band, with as the main setting. Certification tests are compared in three groups. Sound but incomplete tests are the independent bound IDB of (10) and the relaxation FBR of (11). Heuristics without guarantees declare a pair stable only when for every inspected completion , so an inspected tie also refutes strict stability. They are a fixed-completion check that inspects the two corners and , the midpoint of the box and the linear interpolation of the observed slots, and Monte Carlo sampling with or uniform completions of the box plus the same four. Neither uses , which depends on the pair. ExactCert with the fast layer removed, that is, the dynamic programme on every pair, is the ablation of Section V. Missing-data practices are linear interpolation, last observation carried forward, the historical mean of the slot, kNN imputation with five neighbours, and partial distance on the fully observed windows.
Metrics. Top-1 changed means that the candidate returned for the imputed query is not among the candidates at the minimum true distance, so ties are not counted as changes. Set size is the median of over the queries. Retention is the share of queries, among those whose truth lies inside the box, in which every candidate at the minimum true distance is kept in . Strict is the share of queries with . False is the share of certificates issued on the top-5 boundary pairs that are wrong, where a boundary pair joins the fourth or fifth and the sixth or seventh candidate of the nominal ranking. Time is the median milliseconds per query for building , after Numba warm-up and excluding the precomputation of gallery features. Quality metrics and the times of every row except one use all 1 000 queries per dataset, and the programme-only row was timed on the first 200 of them.
Protocol and uncertainty. All thresholds and budgets were fixed on a pseudo-split inside the history period before any test-period result was seen. The method is deterministic, so the uncertainty reported is a bootstrap over sensors with 1 000 resamples, and for the deletion experiments the spread over three seeds. For the percentage-valued metrics in Table II the bootstrap intervals have half-width at most 3 points for every entry except the set size of IDB on METR-LA, where it is 9 points. The kernel was verified against brute-force
TABLE II
CERTIFICATION TESTS AT AND ON 1 000 QUERIES PER DATASET WITH TRANSPLANTED REAL MASKS. BOLD MARKS THE BEST VALUE AMONG SOUND TESTS. COMPLETE REFERS TO THE PAIRWISE DECISION OF STRICT STABILITY, NOT TO MINIMALITY OF THE CANDIDATE SET. DP-ONLY TIMING USES THE FIRST 200 QUERIES, OTHER TIMINGS ALL 1 000.
| Test | Sound | Compl. | METR-LA | PEMS-BAY | PeMSD7-M | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Ret.↑ | Strict↑ | False↓ | ms↓ | Ret.↑ | Strict↑ | False↓ | ms↓ | Ret.↑ | Strict↑ | False↓ | ms↓ | ||||||
| IDB | ✓ | × | 91.7 | 100.0 | 0.2 | 0.0 | 1.5 | 100.0 | 100.0 | 0.1 | 0.0 | 2.9 | 97.1 | 100.0 | 0.0 | 0.0 | 0.7 |
| FBR | ✓ | × | 16.7 | 100.0 | 6.1 | 0.0 | 0.8 | 16.0 | 100.0 | 5.2 | 0.0 | 1.4 | 22.9 | 100.0 | 9.4 | 0.0 | 0.4 |
| Fixed completions | × | - | 13.1 | 98.6 | 7.3 | 26.5 | 0.4 | 13.9 | 98.2 | 6.5 | 20.2 | 0.7 | 17.1 | 99.5 | 11.2 | 14.6 | 0.2 |
| MC sampling, | × | - | 13.6 | 99.3 | 6.9 | 18.7 | 5.2 | 14.0 | 98.8 | 6.2 | 15.2 | 8.4 | 20.0 | 99.9 | 10.9 | 7.6 | 4.4 |
| MC sampling, | × | - | 14.3 | 99.6 | 6.8 | 15.9 | 43.7 | 14.6 | 99.1 | 6.0 | 13.3 | 77.4 | 20.0 | 99.9 | 10.8 | 5.8 | 19.7 |
| ExactCert w/o fast layer | ✓ | ✓ | 15.4 | 100.0 | 6.8 | 0.0 | 175.6 | 15.3 | 100.0 | 5.9 | 0.0 | 265.3 | 20.0 | 100.0 | 10.3 | 0.0 | 79.5 |
| ExactCert (ours) | ✓ | ✓ | 15.4 | 100.0 | 6.8 | 0.0 | 3.2 | 15.3 | 100.0 | 5.9 | 0.0 | 4.2 | 20.0 | 100.0 | 10.3 | 0.0 | 0.9 |
| Ablations of ExactCert | |||||||||||||||||
| one dominator | ✓ | ✓ | 18.8 | 100.0 | 6.8 | 0.0 | 1.8 | 18.5 | 100.0 | 5.9 | 0.0 | 2.0 | 25.7 | 100.0 | 10.3 | 0.0 | 0.3 |
| ten dominators | ✓ | ✓ | 12.0 | 100.0 | 6.8 | 0.0 | 6.4 | 12.5 | 100.0 | 5.9 | 0.0 | 7.7 | 17.1 | 100.0 | 10.3 | 0.0 | 2.5 |
| midpoint completion | ✓ | ✓ | 18.1 | 100.0 | 6.8 | 0.0 | 4.9 | 33.8 | 100.0 | 5.9 | 0.0 | 5.9 | 22.9 | 100.0 | 10.3 | 0.0 | 1.8 |
| , the L1 end | ✓ | ✓ | 6.1 | 100.0 | 22.6 | 0.0 | 0.1 | 2.8 | 100.0 | 27.7 | 0.0 | 0.2 | 5.7 | 100.0 | 33.3 | 0.0 | 0.1 |
ExactCert (ours)
FBR
IDB
MC sampling,
MC sampling,
ExactCert at
linear interpolation
LOCF
historical mean
kNN imputation
partial distance
(a)

PEMS-BAY
PeMSD7-M
(b)
missing slots per query
(c)
band width
Fig. 2. Certification results on three traffic-sensor datasets with transplanted real masks. (a) Share of top-5 boundary pairs that each test certifies as stable, for growing band width . ExactCert decides exactly, so its curve is the ground truth. (b) Median size of the guaranteed candidate set as a share of the gallery, by the number of missing slots out of 48, at , with ExactCert at shown as the L1 end of the family. Sets produced by ExactCert, FBR and IDB contain every true nearest neighbour whenever the true query lies in the box. (c) Share of queries whose top-1 changes under each missing-data practice, against . takes the values 0, 2, 8 and 47 on an evenly spaced axis, where is the L1 distance and the full window-minimum distance. Error bars are intervals from a bootstrap over sensors.
enumeration in exact rational arithmetic on 2350 random instances, including a refined grid between critical values for Lemma 7 and the equivalence of Theorem 9. Everything runs single-threaded in NumPy and Numba on one Mac M5 laptop.
B. Imputation changes retrieval
Fig. 2(c) reports how often the top-1 returned after imputation differs from the top-1 of the true query. With linear interpolation and the L1 distance this happens for ,
TABLE III DATASETS. SERIES AND TEST ARE SENSORS AND DAYS FOR THE TRAFFIC SETS AND TRAINING AND TEST SERIES FOR THE UCR SETS. GALLERY IS THE MEDIAN SAME-SENSOR GALLERY OR THE NUMBER OF COMPLETE TRAINING SERIES.
| Dataset | Sens./train | Days/test | n | Missing | Gallery |
|---|---|---|---|---|---|
| METR-LA | 207 | 119 | 48 | 8.1% | 82 |
| PEMS-BAY | 325 | 180 | 48 | <0.01% | 144 |
| PeMSD7-M | 228 | 44 | 48 | 0 | 35 |
| DodgerLoopDay | 78 | 80 | 96 | real | 67 |
| ItalyPowerDemand | 67 | 1 029 | 24 | 0 | 67 |
| Wafer | 1 000 | 6 164 | 152 | 0 | 1 000 |
24.9% and 20.7% of the queries on the three sets, and 22.6%, 17.7% and 14.8% at the full band. The historical mean is the worst practice at , at 33% to 43%, and partial distance, which discards every window that touches a gap, degrades as grows and is the worst at the full band with 36% to 47%, because long windows almost always touch the gap. The certificate separates the reliable answers from the rest. For linear interpolation, the top-1 change rate is 0% among the queries that ExactCert certifies strictly, on every dataset and at every , while among the remaining queries it is 42.4%, 34.4% and 31.0% at and 24.2%, 18.8% and 16.5% at .
C. Certificates against cheaper tests
Table II is the main comparison at and , and Fig. 2(a) and (b) show the same tests across and across the amount missing. Three findings.
Sound tests are sound, and ExactCert is the tightest of them. On queries whose true series lies in the box, all sound tests retain every true nearest neighbour, as Proposition 5 guarantees, and no strictly certified top-1 was wrong on any of the 1 000 queries per dataset. Table II shows how much each prunes. IDB prunes almost nothing, and ExactCert reduces the median candidate-set fraction by 0.7 to 2.9 points relative to FBR. The difference is larger at the pair level, on a challenging set of top-5 boundary pairs. Of the pairs that are exactly stable, FBR certifies 86.4%, 87.0% and 88.5% and IDB 1.2%, 0.0% and 1.9%, while ExactCert certifies all of them by construction, and Fig. 2(a) shows the growth of this margin with . At FBR coincides with the exact gap, as Proposition 4 predicts, while IDB stays loose because it maximises and minimises the two distances at different completions.
Heuristics look better and are wrong. The fixed-completion check and Monte Carlo sampling produce smaller sets than ExactCert by accepting additional, unverified dominations, and some of these exclusions remove true nearest neighbours. The fixed-completion check loses one in 14, 18 and 5 of the 1 000 queries, sampling with in 7, 12 and 1, and sampling with in 4, 9 and 1. On the boundary pairs, , and of the fixed-completion certificates and , and of the certificates are false. Sampling is the slowest of the bounds and heuristics, because every candidate costs evaluations of the distance, although it stays faster than the programme on every pair.
Exactness costs little. On the top-5 boundary pairs the fast layer decides 90.2%, 92.0% and 92.7% of them without the dynamic programme, and the relaxation is exactly tight on 34.5%, 48.3% and 53.2% of them. A candidate set costs 3.2, 4.2 and 0.9 milliseconds on the same-sensor galleries, against 176, 265 and 80 milliseconds for the dynamic programme alone, with identical sets. Ties, , occur on 0.1% to 2.3% of the boundary pairs.
D. What the band width trades
The forecast experiment uses complete test days as queries, so it compares distances rather than distances combined with an imputer. For each query the five nearest history days of the same sensor under the given distance are retrieved, the prediction is the average of their next-hour mean speed, and the error is the mean absolute error in miles per hour. DTW uses a Sakoe–Chiba band whose width fraction was chosen from on the history pseudo-split, with ties going to the smaller band, which selected 1 on METR-LA and 0.2 on the other two.
Fig. 3 shows what the band width trades. Accuracy falls. The forecast error grows from the L1 distance to the full band by 11.8%, 23.2% and 6.8%, while tuned DTW improves on L1 by 11.8%, 11.0% and 5.7% and remains outside the certifiable family. Strict certification falls too, from 22.6%, 27.7% and 33.3% of the queries at to 6.8%, 5.9% and 10.3% at . Robustness to imputation rises, as the change rates above show. The regime with many missing slots is where the full band pays. On METR-LA test days with real gaps and 13 to 24 missing slots, the median guaranteed set is 63.3% of the gallery under L1 and 39.5% under the full band, and the transplanted masks give the same picture on METR-LA with 51.9% against 34.5%. Fig. 2(b) shows that PEMS-BAY reverses the order and PeMSD7-M shows no difference, so the crossover is dataset dependent. In our experiments, L1 is cheaper and yields smaller candidate sets when few slots are missing.
E. Efficiency and scale
Table IV has two parts. The first varies the window length on PEMS-BAY from to at full band, on 200 boundary pairs per length with the same real gap patterns placed inside the window. The dynamic programme grows from 0.16 to 40 milliseconds per pair, the fast layer from 0.009 to 0.24 milliseconds, and the complete method from 0.02 to 5.4 milliseconds on average because it runs the programme on to of the pairs. The growth is slower than the bound since the admissibility test inside (9) prunes most positions. The second part uses every complete history day of every sensor as one gallery, with 16455, 46719 and 7980 candidates. At a guaranteed set then takes 0.31, 0.71 and 0.15 seconds per query, against 36, 76 and 17 seconds for the programme alone. On the ten queries per dataset that
METR-LA PEMS-BAY PeMSD7-M
(a)

(b)

(c)

Fig. 3. Effects of band width on forecasting accuracy and certified retrieval. Panels (b) and (c) use ExactCert. (a) Change of the 5-NN next-hour MAE relative to the L1 distance on each dataset, with hollow markers giving the same quantity for tuned DTW. (b) Share of test queries whose top-1 is strictly certified. (c) Median size of the guaranteed candidate set on METR-LA by the number of missing slots out of 48, for test days with real gaps and for complete test days with transplanted real masks. The axis and the error bars are as in Fig. 2. The real-gap stratum with 13 to 24 missing slots contains 45 queries and the transplanted one 184.
TABLE IV
COST OF CERTIFICATION. TOP: MILLISECONDS PER PAIR AGAINST THE WINDOW LENGTH ON PEMS-BAY AT FULL BAND, WHERE FAST AND DP REPORT MEDIAN TIME, DP p95 THE 95TH PERCENTILE, AND FULL MEAN TIME. m REPORTS THE MEDIAN CRITICAL-SET SIZE OVER THE SAMPLED PAIRS. BOTTOM: SECONDS PER QUERY ON THE NETWORK-WIDE GALLERY AT , MEDIANS OVER 100 QUERIES PER DATASET FOR EXACTCERT AND FBR AND OVER THE TEN QUERIES ON WHICH THE PROGRAMME ALONE WAS RUN. SPEEDUP IS THE RATIO OF UNROUNDED MEDIANS ON THOSE SAME TEN QUERIES, ON WHICH EXACTCERT TAKES 0.44, 0.76 AND 0.16 SECONDS.
| n | m | Fast | DP | DP p95 | Full | DP needed |
|---|---|---|---|---|---|---|
| 24 | 33 | 0.009 | 0.16 | 0.25 | 0.02 | 2.5% |
| 48 | 52 | 0.016 | 1.19 | 2.20 | 0.14 | 9.5% |
| 96 | 76 | 0.057 | 9.74 | 19.63 | 1.38 | 13.0% |
| 144 | 124 | 0.235 | 39.96 | 65.10 | 5.37 | 13.5% |
| Dataset | N | ExactCert | FBR | DP only | Speedup |
|---|---|---|---|---|---|
| METR-LA | 16455 | 0.31 | 0.14 | 36.2 | 82× |
| PEMS-BAY | 46719 | 0.71 | 0.40 | 75.8 | 100× |
| PeMSD7-M | 7980 | 0.15 | 0.07 | 17.2 | 110× |
were run both ways the speedup is 82, 100 and 110 with identical answers. On average 158, 310 and 77 of the 23674, 66392 and 11675 pair tests per query reach the programme, about ten million pair tests over the 300 queries. The relaxation alone takes 0.14, 0.40 and 0.07 seconds, so exactness costs about a factor of two at network scale.
F. Label invariance on public benchmarks
Protocol. ItalyPowerDemand and Wafer are coded by with the median absolute training value, an order-preserving map to integer codes in [0, 4096]. The transform fixes the representation on which both nominal retrieval and certification are defined, and nearest-neighbour rankings in the original units are not assumed to be preserved. DodgerLoopDay counts are summed over blocks of three five-minute points, and a block with missing points receives the interval from the sum of its observed points to that sum plus times the largest single count in the training set, which is 90. Its gallery is the 67 training series without gaps, and weekend means the official classes 1 and 7, Sunday and Saturday. Deletion removes one contiguous block covering the stated share of the slots, with a uniformly random start, and replaces it by the box [0, 4096] for the two coded sets and [0, 270] for DodgerLoopDay. On the 77 complete DodgerLoopDay test series the largest block sum is 181, so the deletion box covers every masked value, and the coded sets cover theirs by construction. Queries are all 1029 ItalyPowerDemand test series, the 77 complete DodgerLoopDay test series, and 100 Wafer test series per class, and each deletion level is repeated with three seeds.
Table V applies Proposition 6 with contiguous block deletion of of the slots on the three UCR sets. On ItalyPowerDemand the label of of the test series is certified invariant at , and the nominal 1-NN is correct on of the certified series against of the others. On DodgerLoopDay with weekday against weekend labels the numbers are certified and against , and on Wafer, with balanced accuracy, certified and against . In no cell does a certified label change under the true series, which is the guarantee. Deleting of the slots certifies to of the series on ItalyPowerDemand and Wafer at , and deleting certifies on ItalyPowerDemand and none on Wafer. The original seven-class task is challenging in our 1-NN experiments, with accuracy on complete series, and certifies of the queries at deletion. Wafer certifies its abnormal class less often than its normal class, to against to at .
G. Ablations
The last block of Table II varies one choice of Section V at a time. More dominators shrink the set with diminishing returns and rising cost, from and 1.8 milliseconds per query with one dominator on METR-LA to and 6.4 milliseconds with ten, while strict certification does not move at all, because it is decided by the first dominator. The nominal completion barely matters as long as it is sensible, since linear
TABLE V 1-NN LABEL INVARIANCE UNDER 25% CONTIGUOUS DELETION, MEAN AND POPULATION STANDARD DEVIATION OVER THREE SEEDS, IN PERCENT. WAFER USES BALANCED ACCURACY ON 100 QUERIES PER CLASS.
| τ | Certified↑ | Acc. certified | Acc. uncertified | Acc. all |
|---|---|---|---|---|
| ItalyPowerDemand, n = 24 | ||||
| 0 | 53.4 ± 1.0 | 98.1 ± 0.1 | 77.5 ± 2.1 | 88.5 ± 0.8 |
| 8 | 30.9 ± 0.7 | 97.3 ± 0.6 | 79.0 ± 0.8 | 84.6 ± 0.4 |
| 23 | 21.0 ± 1.0 | 97.5 ± 0.5 | 79.1 ± 0.6 | 83.0 ± 0.6 |
| DodgerLoopDay, weekday against weekend, n = 96 | ||||
| 0 | 49.8 ± 2.2 | 100.0 ± 0.0 | 89.7 ± 2.1 | 94.8 ± 1.1 |
| 8 | 43.7 ± 7.1 | 97.8 ± 1.6 | 89.9 ± 1.4 | 93.5 ± 1.1 |
| 95 | 8.2 ± 2.4 | 96.3 ± 5.2 | 95.3 ± 0.6 | 95.2 ± 0.6 |
| Wafer, balanced accuracy, n = 152 | ||||
| 0 | 64.8 ± 1.0 | 100.0 ± 0.0 | 95.2 ± 1.8 | 97.8 ± 0.5 |
| 8 | 64.8 ± 3.7 | 100.0 ± 0.0 | 95.3 ± 1.9 | 98.0 ± 0.4 |
| 151 | 30.3 ± 2.6 | 100.0 ± 0.0 | 92.4 ± 1.3 | 94.5 ± 1.1 |
interpolation, last observation carried forward, historical mean and kNN give median sets within 1.4 points of each other on the first two datasets, while the midpoint of the box, which sits far from any real speed, gives and . The witnesses are complementary. Among all pair tests made while building the candidate sets at , a population dominated by easy pairs unlike the boundary pairs above, the bound leaves about half undecided, and of those alone leaves the programme to , and , the four fixed completions alone to , and , and all five together to , and . At the order of the two witness groups reverses, which is why Algorithm 1 keeps both.
VII. LIMITATIONS AND CONCLUSION
We give a complete decision procedure for strict pairwise stability under window-minimum distances, combining a finite critical-value reduction, an exact interval dynamic programme and a quadratic-time fast layer. Pairwise decisions yield sound candidate sets and sufficient label-invariance certificates.
The guarantees hold over the specified box and apply to the true query only when it lies inside, which held for all but of the PEMS-BAY queries. The framework requires a complete gallery and fixed time positions. Broad boxes limit certification coverage, and tighter boxes impose stronger assumptions on the missing values. The programme takes time with , and its practicality is shown only at the tested window lengths and gallery sizes. The main retrieval experiments use traffic-speed data, and the three label benchmarks provide limited evidence beyond that setting. Future work includes incomplete galleries, window minima on trees or graphs, and retrieval by worst-case regret.
REFERENCES
[1] T. Emrich, H.-P. Kriegel, A. Züfle, P. Kröger, and M. Renz, “Complete and sufficient spatial domination of multidimensional rectangles,” in Proc. 1st ACM SIGSPATIAL Int. Workshop on Spatial Gems, 2019, arXiv:2001.05581.
[2] J. Aßfalg, H.-P. Kriegel, P. Kröger, and M. Renz, “Probabilistic similarity search for uncertain time series,” in Proc. 21st Int. Conf. on Scientific and Statistical Database Management (SSDBM), 2009, pp. 435–443.
[3] M. Dallachiesa, B. Nushi, K. Mirylenka, and T. Palpanas, “Uncertain time-series similarity: Return to the basics,” Proc. VLDB Endowment, vol. 5, no. 11, pp. 1662–1673, 2012.
[4] M. Dallachiesa, T. Palpanas, and I. F. Ilyas, “Top-k nearest neighbor search in uncertain data series,” Proc. VLDB Endowment, vol. 8, no. 1, pp. 13–24, 2014.
[5] T. Imieliński and W. Lipski, “Incomplete information in relational databases,” J. ACM, vol. 31, no. 4, pp. 761–791, 1984.
[6] B. Karlaš, P. Li, R. Wu, N. M. Gürel, X. Chu, W. Wu, and C. Zhang, "Nearest neighbor classifiers over incomplete information: From certain answers to certain predictions," Proc. VLDB Endowment, vol. 14, no. 3, pp. 255–267, 2021.
[7] A. Z. Fan and P. Koutris, “Certifiable robustness for nearest neighbor classifiers,” in Proc. 25th Int. Conf. on Database Theory (ICDT), ser. LIPIcs, vol. 220, 2022, pp. 6:1–6:20.
[8] P. Kouvelis and G. Yu, Robust Discrete Optimization and Its Applications. Dordrecht: Kluwer, 1997.
[9] H. Aissi, C. Bazgan, and D. Vanderpooten, “Min-max and min-max regret versions of combinatorial optimization problems: A survey,” European J. Operational Research, vol. 197, no. 2, pp. 427–438, 2009.
[10] I. Averbakh and V. Lebedev, “Interval data minmax regret network optimization problems,” Discrete Applied Mathematics, vol. 138, no. 3, pp. 289–301, 2004.
[11] J. P. Fitch, E. J. Coyle, and N. C. Gallagher, “Median filtering by threshold decomposition,” IEEE Trans. Acoust., Speech, Signal Process., vol. 32, no. 6, pp. 1183–1188, 1984.
[12] P. D. Wendt, E. J. Coyle, and N. C. Gallagher, “Stack filters,” IEEE Trans. Acoust., Speech, Signal Process., vol. 34, no. 4, pp. 898–911, 1986.
[13] E. J. Coyle and J.-H. Lin, “Stack filters and the mean absolute error criterion,” IEEE Trans. Acoust., Speech, Signal Process., vol. 36, no. 8, pp. 1244–1254, 1988.
[14] Y. Zhu, A. Mueen, and E. Keogh, “Matrix profile IX: Admissible time series motif discovery with missing data,” IEEE Trans. Knowl. Data Eng., vol. 33, no. 6, pp. 2616–2626, 2021.
[15] O. Troyanskaya, M. Cantor, G. Sherlock, P. Brown, T. Hastie, R. Tibshirani, D. Botstein, and R. B. Altman, “Missing value estimation methods for DNA microarrays,” Bioinformatics, vol. 17, no. 6, pp. 520–525, 2001.
[16] W. Cao, D. Wang, J. Li, H. Zhou, L. Li, and Y. Li, “BRITS: Bidirectional recurrent imputation for time series,” in Advances in Neural Information Processing Systems 31, 2018.
[17] W. Du, D. Côté, and Y. Liu, “SAITS: Self-attention-based imputation for time series,” Expert Systems with Applications, vol. 219, p. 119619, 2023.
[18] G. A. Davis and N. L. Nihan, “Nonparametric regression and short-term freeway traffic forecasting,” J. Transportation Engineering, vol. 117, no. 2, pp. 178–188, 1991.
[19] B. L. Smith and M. J. Demetsky, “Traffic flow forecasting: Comparison of modeling approaches,” J. Transportation Engineering, vol. 123, no. 4, pp. 261–266, 1997.
[20] H. Sakoe and S. Chiba, “Dynamic programming algorithm optimization for spoken word recognition,” IEEE Trans. Acoust., Speech, Signal Process., vol. 26, no. 1, pp. 43–49, 1978.
[21] C. A. Ratanamahatana and E. Keogh, “Three myths about dynamic time warping data mining,” in Proc. 2005 SIAM Int. Conf. on Data Mining, 2005, pp. 506–510.
[22] Y. Li, R. Yu, C. Shahabi, and Y. Liu, “Diffusion convolutional recurrent neural network: Data-driven traffic forecasting,” in Proc. Int. Conf. on Learning Representations (ICLR), 2018.
[23] B. Yu, H. Yin, and Z. Zhu, “Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting,” in Proc. 27th Int. Joint Conf. on Artificial Intelligence (IJCAI), 2018, pp. 3634–3640.
[24] H. A. Dau, A. Bagnall, K. Kamgar, C.-C. M. Yeh, Y. Zhu, S. Gharghabi, C. A. Ratanamahatana, and E. Keogh, “The UCR time series archive,” IEEE/CAA J. Automatica Sinica, vol. 6, no. 6, pp. 1293–1305, 2019.
[25] A. Ihler, J. Hutchins, and P. Smyth, “Adaptive event detection with time-varying Poisson processes,” in Proc. 12th ACM SIGKDD Int. Conf. on Knowledge Discovery and Data Mining, 2006, pp. 207–216.