Predictions
MemMesh isn’t only a memory store — it’s a general prediction engine. You declare what you want predicted and the engine predicts it from the subject’s observation history. You never pick a model; the target type selects one for you.
const p = await tf.lattice.predictTarget(
{ kind: "customer", externalId: "acct-42" },
{ kind: "event_occurrence", eventType: "subscription_cancelled" },
{ horizonDays: 90 },
);Declare a target
A prediction target is a small, typed spec — not a hard-coded endpoint. The
kind drives model selection:
| Target kind | Answers | Example |
|---|---|---|
event_occurrence | Will it happen within the horizon? | churn, reorder, pay-late |
numeric | How much? | next order amount, next lab value |
event_time | When next? | next visit, replenishment date |
anomaly | Is the latest reading an outlier? | fraud, sensor drift |
event_occurrence / event_time use eventType; numeric / anomaly use
attributeKey.
The result is calibrated
Every prediction carries an interval, not just a point estimate — and a stated 80% means roughly 80% in reality (conformal coverage, not vibes).
Calibration is queryable: GET /api/v1/projects/{projectId}/lattice/calibration
returns confidence buckets mapped to the realized hit-rate of past predictions in
each band — the honest answer to “of the things we rate ~0.8, do ~80% actually
happen?”. See Outcomes & Calibration.
if (!p.abstained) {
console.log(
`churn risk ${(p.probability * 100).toFixed(0)}% ` +
`[${(p.probabilityLower * 100).toFixed(0)}–${(p.probabilityUpper * 100).toFixed(0)}%]`,
);
}It abstains — a first-class answer
When there isn’t enough signal — too little history, out-of-distribution input, an interval too wide to be useful — MemMesh returns an abstention instead of a confident guess.
An abstention means unknown, never “no” or “low risk”. Always check
abstained before reading a value. This honesty is what makes the engine safe
for regulated use.
if (p.abstained) {
console.log("not enough signal —", p.abstentionReason);
}Every prediction is explainable
A prediction carries its provenance: the ids of the observations it was derived from and a human-readable derivation, so any single prediction can be explained or audited.
console.log(p.explanation); // "12 purchases, every ~21 days"
console.log(p.evidenceMemoryIds); // the observations behind itHow it relates to patterns
Mined behavior patterns become features and priors for these predictions — they give a brand-new subject a useful, calibrated, low-confidence answer immediately, sharpening as real history accrues.
See the TypeScript SDK for the
full predictTarget surface, and Behaviors for
discovering the patterns that feed predictions.