Why Define a Lookback Window?
A predictor based on past activity is not fully defined by saying “use the customer’s history.” History could mean the last month, the last year, or all records that happen to be present in a database. Those choices can produce different values for the same person and prediction date. A lookback window specifies which portion of the past is used to construct a predictor.
The window is anchored to the prediction index date: the date and time at which the prediction is intended to be made. Its length should reflect the information the analysis is meant to capture. A short window emphasizes recent activity; a longer window includes older activity as well. The chosen window is a data-design decision, not just a coding detail.
The half-open interval makes the boundary rule explicit: an event exactly at the start is included, and an event at the prediction time is excluded. A project may use a different convention for date-only data, but it must define that convention and apply it consistently. When a prediction is made at a specific time, a record should be considered only if it was available by then; a lookback window does not make unavailable information usable.
Constructing a Historical Predictor
A window can be used to create a count, sum, average, indicator, or other summary of historical records. For example, an insurer might count recent service calls for a policy, total prior claim payments for an account, or flag whether a customer had any late payments in a defined period. These are different predictors, even when they use the same window.
For a count of events, write the predictor for record \(i\) as:
where \(s_{ij}\) is the timestamp of historical event \(j\) associated with prediction record \(i\), and \(I(\cdot)\) equals 1 when the condition is true and 0 otherwise. A sum of event amounts can be defined similarly by summing each event amount only when its timestamp falls in the window.
The same window rule must be applied separately to each prediction index date. If one customer has multiple prediction dates, the historical records selected for one prediction may differ from those selected for another. The window is attached to the prediction, not permanently to the customer.
Worked Example: Counting Historical Claims in a 90-Day Window
A hypothetical insurer plans to make a prediction at 00:00 on July 1, 2025. It wants a predictor equal to the total paid amount on claims with payment timestamps in the preceding 90 days. The claim payment records are:
- March 28 at 10:00: $120
- April 2 at 00:00: $80
- April 18 at 12:00: $250
- June 29 at 09:00: $150
- June 30 at 23:00: $60
- July 1 at 00:00: $500
Step 1: Find the window start. Ninety days before July 1 at 00:00 is April 2 at 00:00. The window is therefore \([\,\text{April 2 at 00:00},\text{July 1 at 00:00}\,)\).
Step 2: Apply both boundaries. The March 28 payment is before the start, so it is excluded. The April 2 payment is exactly at the start and is included. The April 18, June 29, and June 30 payments are also included. The July 1 payment is at the excluded endpoint, so it is not included.
Step 3: Calculate the predictor. The selected payment amounts total \(80+250+150+60=540\). Thus, the historical paid-amount predictor is $540, based on four payment records.
Check and common mistake. There are four eligible records, and their amounts sum to $540. Counting the March 28 record or including the July 1 payment would use a record outside the specified interval. This method avoids treating “around the last 90 days” as an adequate boundary rule.
What Changes When the Window Gets Longer?
For the same prediction time and the same underlying event records, a longer trailing window contains every event from a shorter window, plus any events in the additional earlier period. This gives a useful check for count and nonnegative amount predictors: their values cannot decrease as the window expands, provided the records are equally complete and are measured using the same rules.
The reason is set inclusion. Every event counted in the shorter interval also falls in the longer interval. The longer-window count adds the number of events in the earlier portion \([t_i-L_2,t_i-L_1)\), which cannot be negative. This reasoning applies to event counts and sums of nonnegative amounts; it does not automatically apply to averages, signed amounts, or predictors whose definition changes with the window.
Worked Example: Comparing 30-Day, 90-Day, and 365-Day Counts
For a hypothetical account, a prediction is made at 00:00 on January 1, 2025. Historical contact timestamps are January 2, 2024 at 00:00; September 15, 2024 at 12:00; October 2, 2024 at 23:00; October 3, 2024 at 00:00; November 20, 2024; December 1, 2024; December 2, 2024 at 00:00; December 20, 2024; December 31, 2024; and January 1, 2025 at 00:00. Compare the number of contacts in the preceding 30, 90, and 365 days.
Step 1: Determine the start of each interval. Using exact elapsed days, the 30-day window starts December 2, 2024 at 00:00; the 90-day window starts October 3, 2024 at 00:00; and the 365-day window starts January 2, 2024 at 00:00. Each interval ends at, but excludes, January 1, 2025 at 00:00.
Step 2: Count the 30-day records. The eligible contacts are December 2 at 00:00, December 20, and December 31. The count is \(3\). The contact on December 1 is too early; the one on January 1 at 00:00 is at the excluded endpoint.
Step 3: Count the 90-day records. The eligible contacts are October 3 at 00:00, November 20, December 1, December 2 at 00:00, December 20, and December 31. The count is \(6\). October 2 at 23:00 is before the start, while October 3 at 00:00 is exactly at the included start.
Step 4: Count the 365-day records. The eligible contacts are January 2, September 15, October 2, October 3, November 20, December 1, December 2, December 20, and December 31. The count is \(9\). The January 2, 2024 record is included at the start, while the January 1, 2025 record is excluded at the end.
Check. The counts are \(3\), \(6\), and \(9\), in order of increasing window length. Each is at least as large as the preceding count, as expected for nested windows. The 30-day count describes very recent contacts; the 365-day count also reflects older activity.
A longer window does not simply provide “more accurate” information. It may capture persistent behavior, but it may also give substantial weight to activity that is no longer relevant to the current prediction. A short window may respond more quickly to recent changes but omit useful evidence about less frequent events. The appropriate choice depends on the prediction task and on a clear rationale for the history being summarized.
Window Length, Coverage, and Interpretation
A window definition includes more than a number. It should specify the anchor, the duration and its unit, the endpoint convention, the event being counted or summarized, and any eligibility rule for records. “Count contacts in the prior 90 days” is clearer than “count recent contacts,” but still needs an explicit rule when timestamps are rounded to dates or when records arrive late.
Also check whether the data source actually covers the full window for each prediction. If an account first appears in the records 45 days before the index date, a 90-day count from the available extract is not necessarily a true 90-day history. It could be a count from only the observed 45 days. Missing history should not silently be treated as zero activity. At minimum, distinguish a genuine zero in a fully observed window from a count based on partial observation.
When comparing windows, be precise about what the feature means. A raw count over 365 days will often exceed a raw count over 30 days simply because it covers more time. Those two counts answer different questions. Dividing by window length to create an average rate changes the predictor’s definition; it does not make the original counts directly interchangeable. Such choices should be stated explicitly rather than hidden in a data-processing step.
State the prediction index date and time for each prediction record.
Give the duration and time unit, then define whether records exactly at each boundary are included.
Keep records within the interval and usable at the prediction time; do not count later or unavailable records.
Apply the stated aggregation, verify boundary cases, and check whether the full window is covered.
Common Exam Traps
- Using a calendar label instead of a duration. “Previous year” could mean the prior calendar year or the preceding 365 days. State which one is intended.
- Reversing a boundary rule. Under the convention here, the window start is included and the index time is excluded. Check records exactly on either boundary.
- Including information after the prediction. A record after the index time is not historical information for that prediction, even if it is present in the final data extract.
- Treating absent history as a zero count. A zero means no qualifying events in an observed window; missing coverage does not establish that no events occurred.
- Assuming a longer window is always better. Longer and shorter windows capture different time scales. Their merits depend on the intended predictor and task.
Check Your Understanding
For each problem, apply the stated interval convention: include the start and exclude the prediction time.
- A prediction is made at 00:00 on August 1. A 10-day lookback is used. A record occurs at 00:00 on July 22, and another at 00:00 on August 1. Which record is in the window? (Answer: July 22 is included; August 1 is excluded.)
- At 00:00 on May 1, a 30-day window is used. Historical events occur April 1 at 00:00, April 1 at 00:01, and April 30 at 23:00. How many events are included? (Answer: 3.)
- A prediction is made at 00:00 on October 1. A 20-day window starts September 11 at 00:00. Eligible claim amounts are $40 on September 11 at 00:00, $75 on September 20, $25 on September 30 at 23:00, and $90 on October 1 at 00:00. What is the in-window total? (Answer: $140.)
- At 00:00 on January 1, an account has 2 events in the preceding 30 days and 7 in the preceding 180 days, based on complete records. How many events lie in the additional earlier portion of the 180-day window? (Answer: 5.)
- A prediction is made at 00:00 on June 1 using a 60-day window. The data extract begins on May 1 and contains no events from May 1 through May 31. What can be concluded about the 60-day event count? (Answer: The observed May count is zero, but the full 60-day count cannot be determined from this extract because the earlier part of the window is unobserved.)