---
title: "Predictive CEP Is a Forgetting Problem"
date: 2026-10-24
slug: predictive-cep-is-a-forgetting-problem
summary: "Adaptive XGBoost is a paper about stream classification, not complex events. Its real lesson for predictive CEP is that the hard part is not the model but the memory policy: what to keep, what to replace, and when to admit that the world has changed."
tags: complex-event-processing, cep, predictive-cep, concept-drift, stream-learning, xgboost, adaptive-ensembles, event-forecasting, machine-learning, streaming
---

A press tool does not fail all at once. It develops a signature: a slow rise in vibration amplitude, a new harmonic, a cluster of parts that miss tolerance. A CEP rule can catch the sequence after it completes — three vibration alerts and two quality rejects within twenty minutes, emit `tool_failure`. By then the tool has already stamped the next batch.

Predictive CEP asks the earlier question. Given the partial match, what is the probability that the pattern completes in the next thirty minutes? Is that probability high enough to stop the line now, or should the next shift run? The answer is not a pattern match. It is a forecast, made before the outcome exists, under a clock.

The paper at the center of this post is not a CEP paper. It is [*Adaptive XGBoost for Evolving Data Streams*](https://arxiv.org/abs/2005.07353), by Jacob Montiel, Rory Mitchell, Eibe Frank, Bernhard Pfahringer, Talel Abdessalem, and Albert Bifet (IJCNN 2020). It is a careful study of how to keep a boosted ensemble useful when the relationship between features and labels changes. That is the layer underneath predictive CEP: the learner that turns an event history into a probability.

Its most useful lesson is not "use XGBoost on streams." It is that a streaming learner is defined by its **memory policy** — which models it keeps, which it replaces, how much history each model sees, and when it decides that the old world is no longer the current one. Predictive CEP inherits that problem and makes it harder. The forecast must forget at the right rate, keep enough history to recognize a rare pattern, and prove it was right only after the horizon has passed.

That is the argument of this post: predictive CEP is a forgetting problem, and the paper is a good map of the first layer of it.

## Detection Is a Postmortem

Complex event processing has a precise job. It takes a stream of simple events and a pattern — a temporal query over event types, attributes, and windows — and emits a complex event when the pattern is satisfied. Engines such as [Esper](https://www.espertech.com/esper/), [Flink CEP](https://nightlies.apache.org/flink/flink-docs-release-1.20/docs/libs/cep/), [Drools Fusion](https://docs.drools.org/), and [SASE](https://doi.org/10.1145/1142473.1142520) compile those patterns into automata or match networks and evaluate them incrementally. The [formal foundations](https://arxiv.org/abs/1709.05369) are well understood, and the operational contract is attractive: deterministic, fast, and explainable.

A pattern match is a certificate about the past. The sequence happened; the window closed; the complex event is now true. Predictive CEP wants a statement about the future while the match is still partial. Formally, given the event history available at decision time, `H_t`, a pattern `P`, and a horizon `h`, it estimates:

```text
Pr(P completes within (t, t + h] | H_t)
```

The forecast is made before the accepting state is reached. The outcome is only known later. That gap between forecast and label is where most of the engineering lives.

The phrase "predictive CEP" is used for at least three different problems, and it is worth keeping them apart:

| Question | What is predicted | Example |
|---|---|---|
| Will the pattern complete? | probability and timing of a complex event | tool failure within 30 minutes |
| What is the likely label of this case? | an attribute or decision over a partial match | fraud risk, severity, root cause |
| Will the engine need more resources? | load, latency, or operator demand | scale CEP operators before a burst |

All three appear in the literature. The first is event forecasting in the strict sense. The second is predictive enrichment: a model scores a case or a pattern instance. The third is operational forecasting: predicting the CEP system's own behavior, as in [Zacheilas et al.](https://doi.org/10.1109/bigdata.2015.7363758), who predict load and latency to scale a Storm/Esper deployment. They are related, but they use different labels and different evaluation.

This post is about the first two. The paper is relevant to both because both contain a base learner, and that learner has to survive drift.

The broader split between a stateful historian and a decision layer was the subject of [AI-driven CEP](https://blog.hackspree.com/#ai-driven-cep). That post put the historian on one side and a decision model on the other. Predictive CEP adds a third thing between the historian and the decision layer: a model of what happens next. It needs the historian's timeline, the pattern engine's partial-match state, and a forecaster that knows when to stop trusting its own past.

## The Paper: Boosting on a Moving Stream

XGBoost is a boosted ensemble of regression trees. Each new tree is fitted to the error left by the trees already in the ensemble — more precisely, to the gradient of the loss — and a regularization term penalizes complexity. In batch learning, the algorithm can make multiple passes over the data and grow the ensemble until the objective stops improving. That is why it is strong on tabular problems and why it is a poor fit for a stream.

A stream gives one pass, potentially infinite data, and a target relationship that can change. The paper lists the standard constraints: models must process data on the way through, must be ready to predict at any moment, and must cope with concept drift. A batch model trained on last quarter's world does not become correct again when the world moves; it becomes a model of a different problem.

### The batch assumption

The naive adaptation is to retrain XGBoost on a sliding window. That works, but it is expensive and it throws away the ensemble's accumulated structure on every retrain. The opposite extreme is to update one tree at a time. That is difficult in boosting because each tree is defined relative to the residuals of the trees before it. A new tree is not an independent vote; it is a correction to a specific ensemble. If the ensemble has learned an old concept, the correction is being computed against the wrong baseline.

AXGB's contribution is a middle path. It keeps a **fixed-size ensemble** and creates one new tree from each full mini-batch of data. The new tree is fitted to the residuals of the current ensemble. Learning does not stop when the ensemble is full: the ensemble is updated on new data so that it stays consistent with the current concept.

### Four design choices

The paper's method is easiest to remember as four decisions.

**1. A buffer, not a row.** Incoming samples are stored in a buffer of size `W`. When the buffer is full, AXGB trains one new base function. The first member is trained directly on the buffer; later members are trained on the residuals of the existing ensemble. This is batch-incremental learning: a small batch at a time, not one instance at a time.

**2. A growing window.** A fixed window of maximum size `W_max` means the ensemble needs `K * W_max` samples before it is full, and the model is weak at the start of the stream. AXGB doubles the window from `W_min` until it reaches `W_max`:

```text
W(i) = min(W_min * 2^i, W_max)
```

With `W_min = 1` and `W_max = 1,000`, the window doubles for about ten batches before it caps. Each new tree sees more history than the last, and the ensemble fills much sooner than it would with a fixed maximum window. The inequality is the point: the samples needed to create `K` models are the sum of the growing windows, which is much smaller than `K * W_max`.

**3. Push or replace.** Once the ensemble is full, there are two ways to make room:

- **Push** (`AXGB[p]`): append the new tree and remove the oldest. The ensemble behaves like a queue. The authors describe older members as retaining more influence.
- **Replace** (`AXGB[r]`): replace the oldest member in place with the new tree. Newer members have more influence on the prediction.

Both eventually replace the whole ensemble, but the order matters. Push preserves a long tail of old models; replace gives the current concept a shorter path to the prediction.

**4. Detect drift or let the update rule handle it.** AXGB's incremental update already adapts indirectly, because new trees are trained on newer data. The paper also tests drift-aware variants (`AXGBA[p]`, `AXGBA[r]`) that run [ADWIN](https://doi.org/10.1137/1.9781611972771.42) on the model's accuracy. When ADWIN detects a change, the window resets to `W_min` and the ensemble update is triggered: push flushes old members quickly, while replace resets its replacement index and trains new members without the residuals of the old concept.

The design is compact enough to state as pseudocode:

```text
on a full buffer B:
    if drift detected:
        window = W_MIN
    f = fit_residuals(B, ensemble)
    if |ensemble| < K:
        ensemble.add(f)
    else if strategy == replace:
        ensemble.replace_oldest(f)
    else:  # push
        ensemble.add(f)
        ensemble.remove_oldest()
```

The interesting part is not the tree. It is the policy around the tree.

## What the Experiments Actually Show

The paper evaluates four AXGB variants against batch-incremental methods (BXGB, an ensemble of XGBoost ensembles, and AWE-J48) and instance-incremental methods (Adaptive Random Forest, Hoeffding Adaptive Tree, Leveraging Bagging, Oza Bagging, SAMkNN, and Restricted Hoeffding Trees). It uses eight datasets: five synthetic streams with known abrupt, gradual, or fast-incremental drift, and three real streams with unknown drift. Evaluation is prequential: predict each sample before using it to train.

The headline result is a trade-off, not a clean win. Among batch-incremental methods, the average ranks (lower is better) were:

| Variant | No drift detector | With ADWIN |
|---|---|---|
| Push | 4.19 | 3.06 |
| Replace | **1.44** | 2.31 |

`AXGB[r]` — replacement without explicit drift detection — was the best batch-incremental method. The drift-aware push variant improved substantially over plain push, but the drift-aware replacement variant was worse than plain replacement. The result makes sense as a trade-off: replacement already refreshes the oldest members, so the detector's monitoring overhead buys less; push depends on the detector to flush the old ensemble.

Against instance-incremental methods, the picture is more sobering. Adaptive Random Forest was the top performer with an average rank of 1.63, followed by Restricted Hoeffding Trees at 2.75. `AXGB[r]` ranked 4.75 and `AXGBA[r]` ranked 5.69. The post-hoc test did not separate the top group at 95% confidence, so the honest summary is "competitive with the top tier on these datasets," not "state of the art."

The rest of the results matter as much as the ranks:

- **Tuning can flip the ranking.** In the hyperparameter study, tuned BXGB reached an average accuracy of 0.835, slightly ahead of tuned `AXGBA[p]` at 0.828. The untuned BXGB was at 0.736. Architecture is not destiny; the search space and the tuning budget are part of the result.
- **Memory is bounded.** The stream ensembles plateau in the low thousands of nodes, while a batch XGBoost model trained on all the data has 12.7K nodes. The model does not grow without bound.
- **Training time is flat for the non-drift-aware variants.** `AXGB[p]` and `AXGB[r]` show little change in training time as the stream grows. The ADWIN variants track XGBoost and are slightly slower; the paper attributes `AXGBA[p]` being the slowest to its ensemble filling quickly, so every prediction touches more members.
- **The best compromise is not the best accuracy.** The authors conclude that `AXGB[r]` is the best compromise across performance, training time, and memory. That is a different objective from "win the benchmark," and it is the right one for a stream.

This is a useful paper precisely because it reports the awkward result. Drift detection is not a free improvement. Replacement is a strong, cheap policy. The update geometry can matter more than the detector.

## The Memory Policy

A streaming model is a memory system with a prediction attached. It decides what to retain, what to discard, and how quickly to discount the past. The paper makes that decision explicit for an ensemble of trees. Predictive CEP has to make the same decision at three layers, and most systems only think about the first.

### Model memory

This is the layer AXGB addresses. How many trees, how much data per tree, which tree to replace, when to reset the window. The policy encodes a half-life: replacement gives recent data more weight; push gives old data a longer tail; a growing window lets each new tree see more history; ADWIN cuts the window when the error distribution changes.

The same problem appears in different clothes elsewhere. [Pi-CEP](https://doi.org/10.1109/icdmw.2017.167) stores historical matched sequences and answers range queries over that space to predict how a partial match is likely to continue. Its index grows with the number of matches, so the authors summarize older matches, keeping the top-k most infrequent range queries to avoid catastrophic forgetting. That is a memory policy too: keep the rare evidence, compress the routine evidence.

Prediction suffix trees make the same trade-off in the sequence model. A full-order Markov model remembers every suffix of length `k`; a PST remembers only the suffixes that are informative. The [Wayeb/PST work](https://doi.org/10.1007/s00778-021-00698-x) uses that variable-order structure to forecast whether a symbolic automaton will reach an accepting state within a horizon. The PST is literally a representation of what is worth remembering about the past.

### Pattern memory

Predictive CEP has a second memory that AXGB does not: the pattern itself. A CEP rule is a model of the world, and it can go stale. A fraud pattern written for card-present transactions may not describe card-not-present fraud. A threshold tuned for last year's traffic may be wrong after a pricing change. The event types may stay the same while the semantics shift.

[autoCEP](https://doi.org/10.1145/2933267.2933430) attacks the authoring side by mining predictive CEP rules from historical traces instead of asking a domain expert to write them. [RL4CEP](https://doi.org/10.1007/s40747-024-01742-3) goes further and uses reinforcement learning to update the threshold values used by CEP rules at runtime, with Flink as the engine and Kafka as the transport. Those are pattern-memory policies: they decide when a rule's parameters should change.

Most teams version the forecaster and forget the pattern. That is backwards. A forecast conditioned on a stale pattern is a precise answer to the wrong question.

### Evaluation memory

The third memory is the one that predictive CEP papers rarely discuss: the memory of which outcomes have actually matured. AXGB can update after every sample because the label arrives with the sample. A predictive CEP forecast does not have that luxury. If the horizon is thirty minutes, the outcome for a forecast made at 10:00 does not exist until 10:30. At 10:30, non-completion is a negative for that forecast; the case may complete later, but that is a different horizon. The genuinely missing labels are the censored ones: the entity disappears, the data has a gap, or the observation window ends before the deadline.

A system that treats censored cases as negatives, or scores forecasts before their deadline, will bias the base rate or leak the future into the past. It will look better than it is. The fix is a ledger of forecasts whose horizons have matured, with explicit handling for censored cases. That ledger is part of the model's memory, and it determines whether the evaluation means anything.

The three layers are not independent. A model that forgets quickly needs a pattern layer that is stable enough to define the target. A pattern layer that changes constantly needs an evaluation ledger that can segment the before and after. And a ledger that only keeps the last day cannot tell you whether the model is drifting over a month.

## What Predictive CEP Adds

AXGB is a row classifier: one feature vector in, one label out, one update. Predictive CEP is a sequence forecasting problem conditioned on a partial match. The differences are not cosmetic.

| AXGB assumption | Predictive CEP reality | Consequence |
|---|---|---|
| The label arrives with the sample | the outcome is known only after the horizon | updates and drift monitors need matured outcomes, not immediate accuracy |
| One row is one example | one example is a partial match plus automaton state | features must serialize pattern state, age, and path |
| Accuracy is the metric | positives are rare and costs are asymmetric | use PR-AUC, Brier score, recall at an alert budget, and lead time |
| Drift is a change in `P(y \| x)` | input, pattern, base rate, and label policy can all drift | monitor each source separately |
| The pattern is implicit in the features | the pattern is a query with semantics | learn the continuation of the pattern, not a generic row classifier |

The first row is the hardest. A predictive CEP system cannot run ADWIN on per-event accuracy because the per-event label is not available yet. It can run a detector on a matured cohort's forecast loss, on the distribution of forecast probabilities, on the event rate, or on the agreement between the forecast and the eventual pattern match. Those are different signals, and they fail in different ways. A drop in forecast loss can mean the model improved or the pattern became easier; a change in the event rate can be a real change in the world or a change in the logging pipeline.

The second row is where most feature engineering goes wrong. A partial match is not a bag of events. It has a position in the pattern, an age, a set of satisfied and unsatisfied predicates, and possibly multiple live match threads per entity. Flattening that into a feature vector loses exactly the information that makes the forecast possible. This is the strongest argument for keeping the pattern engine and the forecaster separate: the engine owns the match state, and the forecaster receives it as a structured case.

The third row changes the objective. A model on a stream with 1% positives can reach 99% accuracy by always predicting "no." A predictive CEP system needs a probability, a threshold, and a cost model. It also needs an abstention path: when the distribution is flat or the case is out of distribution, route to a human or wait for more evidence. The [calibration literature](https://arxiv.org/abs/1706.04599) is clear that neural confidence is not automatically trustworthy; the same caution applies to boosted trees and Bayesian networks after drift.

The fourth row is an evaluation requirement. Report metrics per drift segment, per entity, and per horizon bucket. A model that is stable on average can be excellent before a deploy and useless after it.

The fifth row is the conceptual one. A generic classifier learns `P(y | features)`. A predictive CEP forecaster should learn `P(pattern completes within h | partial match state)`. The second problem has more structure, and using it is not cheating. It is the whole point of putting the forecaster next to a pattern engine.

## Three Ways to Forecast a Pattern

The predictive CEP literature has developed three broad strategies. They are complementary, and the choice depends on what you have more of: pattern structure, labels, or historical matches.

### Model the automaton's future

The most direct approach keeps the pattern as an automaton and learns a stochastic model of the stream that drives it. [Wayeb](https://arxiv.org/abs/1901.01826) uses symbolic automata to encode patterns and Markov chains to derive a probabilistic description of the automaton. The [prediction suffix tree extension](https://arxiv.org/abs/2109.00287) replaces the full-order Markov chain with a variable-order model that keeps only informative suffixes, and computes waiting-time distributions for reaching an accepting state.

The intuition is clean. If the pattern is `A then B within 10 minutes`, the automaton state tells you whether you have seen `A` and are waiting for `B`. The stochastic model tells you how likely the next events are to move you toward the accepting state. The forecast is a probability over the remaining horizon, not a label attached to a row.

This lineage is attractive when the pattern specification is stable and the sequence structure carries most of the signal. It is data-efficient because it does not need to learn the pattern from scratch. Its weaknesses are the Markov assumption, state explosion for complex patterns, and the need for enough sequence data to estimate the transition model. The [CEF optimizer](https://doi.org/10.1145/3524860.3539810) addresses the tuning side of this: CEF has its own hyperparameters, and tuning them by hand is a bad use of an engineer's time.

The closest work to AXGB's drift concern is [RTCEF](https://doi.org/10.1145/3701717.3730539), a runtime adaptation framework for complex event forecasting. It starts from the observation that CEF models are trained on historical data and are therefore vulnerable to data evolutions that invalidate them, and it adapts the forecasting service at runtime. The vocabulary is different from AXGB's ensemble replacement, but the problem is the same: the world moved, and the model needs a policy for catching up.

### Learn a predictive model from history

The second strategy treats prediction as a supervised learning problem. [Fülöp et al.](https://doi.org/10.1145/2371316.2371323) laid out a conceptual framework for combining CEP with predictive analytics and demonstrated it with a proof-of-concept experiment, motivated by events such as credit card fraud that should be prevented before they occur. [Tóth et al.](https://doi.org/10.1145/1827418.1827436) made the earlier case for CEP and predictive analytics as complementary technologies.

Within that frame, the models vary widely:

- [Christ, Krumeich, and Kempa-Liehr](https://doi.org/10.1109/edocw.2016.7584363) introduce conditional event occurrence density estimation, which gives both an estimate and an uncertainty for the next occurrence of an event. That is a more useful primitive for CEP than a bare classifier because the pattern engine needs a distribution over timing.
- [Wang, Gao, and Chen](https://doi.org/10.1016/j.patrec.2017.05.008) use an evolving Bayesian network with approximate inference, and their predictive event-processing agent sends predictive complex events to decision support. The network is a probabilistic model of the event space, not a bag of independent classifiers.
- [PERCEPTUS](https://doi.org/10.1016/j.knosys.2019.05.024) combines semantic annotation of heterogeneous event streams, complex event processing, and logical plus probabilistic reasoning to predict disruption events under incomplete or uncertain information. The semantic layer is doing real work: it reconciles event vocabularies before the prediction.
- [Cepair](https://doi.org/10.1007/s10586-024-04434-2) is a fog-based predictive CEP system for air quality that uses RNN, LSTM, CNN, and SVR models to forecast future pollutant concentrations and pass the results to decision-makers.

AXGB belongs here, but it is a deliberately narrow member of the family: a binary classifier with no notion of a pattern, a horizon, or an event schema. Its contribution is the update policy, not the forecast semantics. The broader lineage supplies what AXGB leaves out: uncertainty, semantics, and domain structure.

The weakness of this lineage is also familiar. It needs labels, it inherits the base rate, and it can drift silently. A Bayesian network can represent uncertainty, but it still has to be re-estimated when the event distribution changes. A semantic layer can reconcile vocabularies, but it cannot tell you whether the pattern's threshold is still the right one.

### Remember the matches

The third strategy is nonparametric. Instead of fitting a model, keep a history of matched sequences and use the nearest or most relevant past matches to predict how the current partial match will continue. [Pi-CEP](https://doi.org/10.1109/icdmw.2017.167) does this explicitly: it models predictive detection over an N-dimensional historical matched-sequence space, maps the space to one dimension with a z-order curve, and answers range queries with a compressed index. Its summarization of older matches is a direct answer to catastrophic forgetting.

This is appealing when rare sequences matter and a parametric model would smooth them away. It is also the easiest strategy to explain to an operator: "the last time we saw this prefix, it ended like this." The costs are memory, the choice of similarity metric, and staleness. A historical match from a different regime can be a confident wrong answer. The summarization policy is doing the same job as AXGB's replacement policy: deciding which past is still relevant.

### They are complementary

A production predictive CEP system can use more than one. A PST can model the sequence structure around the pattern; a gradient-boosted or Bayesian model can use the rich attributes of the case; a match index can retrieve rare precedents; a rule layer can enforce hard constraints. The mistake is to treat any one of them as the whole system.

The comparison is roughly this:

| Strategy | What it learns | What it stores | Strength | Failure mode |
|---|---|---|---|---|
| Automaton + stochastic model | continuation of the pattern | transition model and automaton state | uses pattern structure; interpretable | Markov assumptions, state explosion |
| Predictive model from history | mapping from case features to outcome | model parameters | rich features, uncertainty, semantics | labels, drift, calibration |
| Historical matches | local continuation of similar prefixes | index of past matches | rare sequences, nonparametric | memory, similarity, stale precedents |

AXGB is a component for the second row. It is a good component, but it is not a predictive CEP system.

## A Reference Architecture

The architecture that follows from these constraints is a pipeline, not a model. It separates the timeline, the pattern state, the forecast, the decision, and the evidence.

```text
simple events
     |
     v
pattern engine  ---> complex events (after completion)
     |
     v
partial-match state
     |
     v
case packer  ---> forecaster ---> calibration ---> policy ---> action
     |                                                    |
     +---------------------- event log -------------------+
                              |
                              v
                     forecast ledger (matured outcomes)
                              |
                              v
                     drift monitors and replay
```

The **pattern engine** owns event time, windows, watermarks, and the partial-match state. It is the part of the system that should be deterministic and replayable. It emits both completed complex events and, for predictive use, a structured view of the live partial matches.

The **case packer** turns a partial match into a bounded, versioned case: the pattern id, the automaton state, the age of the match, the satisfied predicates, the relevant attributes, and a summary of recent events for the entity. The case is the unit of context, just as it was in the historian/judge split. It has a serializer version because a change in packing changes the forecast.

The **forecaster** is replaceable. It can be a PST, a Bayesian network, a gradient-boosted ensemble, or a small sequence model. It receives the case and returns a probability for each horizon of interest. It does not generate text, choose actions, or write to the stream.

The **calibration** layer maps raw scores to probabilities using outcomes from the ledger. It is fitted on matured cases, separate from the training set, and re-fitted when the calibration curve drifts. A forecast that is not calibrated cannot be thresholded by cost in any principled way.

The **policy** layer turns probabilities into actions. It knows the cost of a false alarm, the cost of a missed event, the alert budget, and the human review capacity. It can abstain. It writes the action and the forecast to the log so the decision can be replayed.

The **ledger** records every forecast with its horizon, model hash, case hash, and eventual outcome. It is the source of truth for evaluation and the only defense against label leakage.

AXGB maps onto this architecture more cleanly than it first appears:

- The mini-batch window is the **history policy** for each tree.
- The fixed ensemble size is the **memory budget**.
- Push versus replace is the **recency policy**.
- ADWIN is a **trigger**, not the policy itself.
- Prequential evaluation is the ancestor of the **matured ledger**.

That mapping is the paper's practical value. It gives names to decisions that most stream-learning systems make implicitly.

A small implementation of the ledger makes the delayed-label problem concrete:

```python
from collections import deque
from dataclasses import dataclass

@dataclass
class Forecast:
    entity: str
    pattern: str
    made_at: int
    deadline: int
    probability: float

class Ledger:
    def __init__(self):
        # Use a heap keyed by deadline if horizons vary.
        self.pending = deque()
        self.scored = []

    def record(self, f: Forecast):
        self.pending.append(f)

    def mature(self, now: int, outcome_for):
        while self.pending and self.pending[0].deadline <= now:
            f = self.pending.popleft()
            # 1 if the pattern completed, 0 if it did not,
            # None if the case was censored (entity disappeared, data gap).
            y = outcome_for(f)
            if y is not None:
                self.scored.append((f.probability, y))
```

The policy layer can then use a simple cost rule. If `C_miss` is the cost of missing a completion and `C_false` is the cost of a false alarm, the expected-cost threshold is:

```text
act if p * C_miss > (1 - p) * C_false
=> p > C_false / (C_false + C_miss)
```

The threshold is a business decision, but it is only meaningful if `p` is calibrated. That is why calibration belongs in the architecture, not in a notebook.

## Evaluation Is the Product

Many predictive CEP papers report accuracy, precision, recall, and F1. Those metrics are not enough for a forecast. A forecast has a horizon, a lead time, and a cost. The evaluation has to match the decision.

Start with the unit. A forecast is a tuple: entity, pattern instance, checkpoint time, horizon, probability, model version, and case version. A single pattern instance can generate many forecasts as it evolves, and those forecasts are correlated. Treating them as independent samples inflates significance and hides per-entity failure.

Score only matured forecasts. For a forecast made at `t` with horizon `h`, the label is 1 if the pattern completes by `t + h` and 0 otherwise. If the entity disappears or the data has a gap before the deadline, censor the case; do not count it as a negative. This is the same distinction a survival analysis makes, and it matters when events are rare.

Then measure different things:

| Question | Metric |
|---|---|
| Is the probability honest? | Brier score, log loss, reliability curve |
| Does it find rare events? | PR-AUC, recall at a fixed alert budget |
| Is it early enough? | median and lower-quantile lead time |
| Is it operationally usable? | alerts per entity-day, precision at budget, abstention rate |
| Is it stable? | metrics by drift segment, horizon bucket, and entity cohort |

Use baselines that an operator would recognize:

- Always predict the base rate. If a complex model cannot beat this, it is not adding value.
- Use the pattern engine's own detection as a lead-time-zero baseline. It has zero lead time by construction, and its precision is the precision of the pattern definition. The forecaster must earn its place by moving the decision earlier without drowning the team in false alarms.
- Use a static model trained on the first segment. It shows how much of the performance comes from adaptation.
- Use a PST or a Bayesian network if the pattern structure is stable. It is a strong, interpretable comparator.
- Use an AXGB-style adaptive ensemble if the case has rich features and labels. It is a strong comparator for the tabular part of the problem.

Backtest with replay and time-based splits. Never split randomly across time: the future is not exchangeable with the past. Report per-segment results, especially around deploys, schema changes, and known drift events. If you compare methods across datasets, use a non-parametric test as the AXGB paper does, but bootstrap by entity or time block rather than by forecast, because forecasts from the same entity are not independent.

Finally, separate forecast quality from decision quality. A well-calibrated forecast can still produce a bad policy if the costs are wrong or the alert budget is unrealistic. Measure the policy's outcomes too: how many false alarms per day, how many misses, how much lead time the operators actually got, and whether the action changed the outcome.

## What the Paper Leaves Out

The paper is honest about its scope, and it is worth being explicit about the gaps.

- **Binary classification only.** The experiments are binary. The later [SGBT](https://doi.org/10.1007/s10994-024-06517-y) work notes that AXGB and the related AdIter method are binary-class gradient-boosting implementations, and it proposes a multi-class alternative. SGBT also argues that AXGB and AdIter failed to beat bagging-based ensembles such as Adaptive Random Forest, and reports that its own tree-internal replacement strategy does better. That is how the line of work progresses: the first streaming booster is a baseline, not the final answer.
- **Immediate labels.** Prequential evaluation assumes `y_t` is available with `x_t`. Predictive CEP does not have that. The paper's drift detector is therefore not directly transferable; it has to be moved to a matured cohort or a proxy signal.
- **Accuracy as the metric.** Accuracy hides calibration, rare-event performance, and cost. A predictive CEP system needs probabilities and a threshold, not just a label.
- **No pattern state.** The features are rows. A CEP forecaster needs the automaton state, the match age, and the relationships among events.
- **No recurring concepts.** The ensemble can re-learn a concept after it returns, but it does not explicitly keep a library of past concepts. That is a deliberate simplification, and it matters in domains with seasonal or adversarial drift.
- **Standard stream benchmarks.** The datasets are the usual synthetic and real streams, not event-pattern forecasting tasks. The mapping from AXGB to predictive CEP is an argument by analogy, not an experimental result in the paper.

None of these gaps makes the paper less useful. They define the boundary between "a streaming classifier" and "a predictive CEP system." The paper is a strong treatment of the first; the second is the work that remains.

## The Takeaway

The classifier is the replaceable part. The memory policy and the evaluation harness are the system.

A predictive CEP system has to decide what to remember at three levels: which model members to keep, which pattern definitions and thresholds still apply, and which outcomes have matured enough to judge the forecast. AXGB is valuable because it makes the first decision explicit and measures the trade-offs. The predictive CEP literature supplies the other two: automata and PSTs for the pattern's future, Bayesian networks and semantic reasoning for uncertain cases, historical matches for rare precedents, and runtime adaptation for models that go stale.

The design that survives contact with operations is not a single model bolted onto a rule engine. It is a historian that owns the timeline, a pattern engine that owns the partial match, a forecaster that owns the probability, a ledger that owns the evidence, and a policy that owns the action. Each is replaceable. Each is versioned. Each can be replayed.

I started this post looking for a predictive CEP method in the paper. There isn't one. What changed my view was the combination of the replacement result, the bounded memory, and the flat training time: a model that is slightly less accurate but has a predictable cost and a clear forgetting rule is easier to operate than a benchmark winner that drifts. The same trade-off applies to predictive CEP. The best forecast is the one whose memory policy and evaluation you can defend.

The question is not "which model predicts the future?" It is "what does the model forget, how fast, and how would we know?" That is a harder question, and a more useful one.

---

**References and related reading:**

**The paper and its line**

- Jacob Montiel, Rory Mitchell, Eibe Frank, Bernhard Pfahringer, Talel Abdessalem, and Albert Bifet, ["Adaptive XGBoost for Evolving Data Streams,"](https://arxiv.org/abs/2005.07353) IJCNN 2020. [DOI](https://doi.org/10.1109/IJCNN48605.2020.9207555). The [reference implementation](https://github.com/jacobmontiel/AdaptiveXGBoostClassifier) is public.
- Tianqi Chen and Carlos Guestrin, ["XGBoost: A Scalable Tree Boosting System,"](https://doi.org/10.1145/2939672.2939785) KDD 2016.
- Albert Bifet and Ricard Gavaldà, ["Learning from Time-Changing Data with Adaptive Windowing,"](https://doi.org/10.1137/1.9781611972771.42) SDM 2007.
- João Gama, Indrė Žliobaitė, Albert Bifet, Mykola Pechenizkiy, and Abdelhamid Bouchachia, ["A Survey on Concept Drift Adaptation,"](https://doi.org/10.1145/2523813) *ACM Computing Surveys* 46(4), 2014.
- Jesse Read, Albert Bifet, Bernhard Pfahringer, and Geoffrey Holmes, ["Batch-Incremental versus Instance-Incremental Learning in Dynamic and Evolving Data,"](https://doi.org/10.1007/978-3-642-34156-4_29) IDA 2012.
- Albert Bifet, Geoffrey Holmes, and Bernhard Pfahringer, ["Leveraging Bagging for Evolving Data Streams,"](https://doi.org/10.1007/978-3-642-15880-3_15) ECML PKDD 2010.
- Heitor M. Gomes et al., ["Adaptive Random Forests for Evolving Data Stream Classification,"](https://doi.org/10.1007/s10994-017-5642-8) *Machine Learning* 106, 2017.
- Nuwan Gunasekara, Bernhard Pfahringer, Heitor Gomes, and Albert Bifet, ["Gradient Boosted Trees for Evolving Data Streams,"](https://doi.org/10.1007/s10994-024-06517-y) *Machine Learning* 113, 2024.
- Ke Wang et al., ["Elastic Gradient Boosting Decision Tree with Adaptive Iterations for Concept Drift Adaptation,"](https://doi.org/10.1016/j.neucom.2022.03.038) *Neurocomputing* 491, 2022.
- Jacob Montiel et al., ["River: Machine Learning for Streaming Data in Python,"](https://arxiv.org/abs/2012.04740) 2020.

**Predictive CEP and event forecasting**

- Lajos Jenő Fülöp, Árpád Beszédes, Gabriella Tóth, Hunor Demeter, László Vidács, and Lóránt Farkas, ["Predictive Complex Event Processing: A Conceptual Framework for Combining Complex Event Processing and Predictive Analytics,"](https://doi.org/10.1145/2371316.2371323) BCI 2012.
- Gabriella Tóth, Lajos Jenő Fülöp, László Vidács, Árpád Beszédes, Hunor Demeter, and Lóránt Farkas, ["Complex Event Processing Synergies with Predictive Analytics,"](https://doi.org/10.1145/1827418.1827436) DEBS 2010.
- Maximilian Christ, Julian Krumeich, and Andreas W. Kempa-Liehr, ["Integrating Predictive Analytics into Complex Event Processing by Using Conditional Density Estimations,"](https://doi.org/10.1109/edocw.2016.7584363) EDOCW 2016.
- Raef Mousheimish, Yéhia Taher, and Karine Zeitouni, ["Automatic Learning of Predictive Rules for Complex Event Processing,"](https://doi.org/10.1145/2933267.2933430) DEBS 2016.
- Yongheng Wang, Hui Gao, and Guidan Chen, ["Predictive Complex Event Processing Based on Evolving Bayesian Networks,"](https://doi.org/10.1016/j.patrec.2017.05.008) *Pattern Recognition Letters* 105, 2018.
- Falak Nawaz, Naeem Khalid Janjua, and Omar Khadeer Hussain, ["PERCEPTUS: Predictive Complex Event Processing and Reasoning for IoT-Enabled Supply Chain,"](https://doi.org/10.1016/j.knosys.2019.05.024) *Knowledge-Based Systems* 180, 2019.
- Syed Gillani et al., ["Pi-CEP: Predictive Complex Event Processing Using Range Queries over Historical Pattern Space,"](https://doi.org/10.1109/icdmw.2017.167) ICDMW 2017. [Open PDF](https://hal.science/hal-01613798).
- Elias Alevizos, Alexander Artikis, and Georgios Paliouras, ["Wayeb: A Tool for Complex Event Forecasting,"](https://arxiv.org/abs/1901.01826) LPAR-22, 2018.
- Elias Alevizos, Alexander Artikis, and Georgios Paliouras, ["Complex Event Forecasting with Prediction Suffix Trees,"](https://doi.org/10.1007/s00778-021-00698-x) *The VLDB Journal* 31(1), 2022. [Extended technical report](https://arxiv.org/abs/2109.00287).
- Vasileios Stavropoulos, Elias Alevizos, Nikos Giatrakos, and Alexander Artikis, ["Optimizing Complex Event Forecasting,"](https://doi.org/10.1145/3524860.3539810) DEBS 2022.
- Manolis Pitsikalis, Elias Alevizos, Nikos Giatrakos, and Alexander Artikis, ["Run-Time Adaptation of Complex Event Forecasting,"](https://doi.org/10.1145/3701717.3730539) DEBS 2025.
- Nikos Zacheilas et al., ["Elastic Complex Event Processing Exploiting Prediction,"](https://doi.org/10.1109/bigdata.2015.7363758) IEEE BigData 2015.
- ["Cepair: An AI-Powered and Fog-Based Predictive CEP System for Air Quality Monitoring,"](https://doi.org/10.1007/s10586-024-04434-2) *Cluster Computing* 27(7), 2024.
- ["RL4CEP: Reinforcement Learning for Updating CEP Rules,"](https://doi.org/10.1007/s40747-024-01742-3) *Complex & Intelligent Systems* 11(2), 2025.

**CEP foundations**

- David Luckham, [*The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems*](https://www.informit.com/store/power-of-events-an-introduction-to-complex-events-and-9780201727890) (Addison-Wesley, 2002).
- Gianpaolo Cugola and Alessandro Margara, ["Processing Flows of Information: From Data Stream to Complex Event Processing,"](https://doi.org/10.1145/2187671.2187677) *ACM Computing Surveys* 44(3), 2012.
- Eugene Wu, Yanlei Diao, and Shariq Rizvi, ["High-Performance Complex Event Processing over Streams,"](https://doi.org/10.1145/1142473.1142520) SIGMOD 2006.
- Marco Bucchi, Alejandro Grez, and Cristian Riveros, ["Foundations of Complex Event Processing,"](https://arxiv.org/abs/1709.05369) arXiv:1709.05369.
- [AI-driven CEP](https://blog.hackspree.com/#ai-driven-cep) — the historian/judge split that this post's forecaster sits on top of.

**Evaluation and calibration**

- A. Philip Dawid, ["Present Position and Potential Developments: Some Personal Views: Statistical Theory: The Prequential Approach,"](https://doi.org/10.2307/2981683) *Journal of the Royal Statistical Society, Series A* 147(2), 1984.
- Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger, ["On Calibration of Modern Neural Networks,"](https://arxiv.org/abs/1706.04599) ICML 2017.
- [LLM at Runtime Is an Antipattern](https://blog.hackspree.com/#llm-at-runtime-is-an-antipattern) — the cost and replayability argument that any runtime forecaster has to answer.
