<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jon Paino on Medium]]></title>
        <description><![CDATA[Stories by Jon Paino on Medium]]></description>
        <link>https://medium.com/@jonpaino?source=rss-2babce7129b0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OxgCdCOYo2ZqQu4i4mzSLg.jpeg</url>
            <title>Stories by Jon Paino on Medium</title>
            <link>https://medium.com/@jonpaino?source=rss-2babce7129b0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:02:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonpaino/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[TranAD Multivariate Anomaly Detection]]></title>
            <link>https://medium.com/striim-labs/tranad-multivariate-anomaly-detection-022c353c0e07?source=rss-2babce7129b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/022c353c0e07</guid>
            <dc:creator><![CDATA[Jon Paino]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 21:10:44 GMT</pubDate>
            <atom:updated>2026-06-01T21:11:40.740Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is the second AI Prototype in our anomaly detection series from Striim Labs. We move from one metric to many with TranAD, a transformer-based model that monitors dozens of features at once and tells you which ones are causing trouble.</em></p><p><em>Return to the first prototype: </em><a href="https://www.striim.com/blog/lstm-autoencoder-anomaly-detection/"><em>LTSM Autoencoder</em></a><em>.</em></p><p>Ready to dive in with TranAD? <a href="https://github.com/striim-labs/multivariate-anomaly-detection">Click here.</a> to jump into the Github repo and test the prototype for yourself! <br> Got questions? Reach out to us at <a href="/service/mailto:striimlabs@striim.com">striimlabs@striim.com</a></p><h3>Striim Labs and AI Prototypes</h3><p>In case you missed it, the team at Striim has launched <a href="https://www.striim.com/blog/introducing-striim-labs/">Striim Labs</a>: an applied research group focused on delivering AI Prototypes at the intersection of AI/ML and real-time data streaming. In this post, we’ll focus on TranAD: the second prototype in our series on real-time anomaly detection.</p><p>This prototype is based on “TranAD: Deep Transformer Networks for Time Series Anomaly Detection” by Tuli et al., published at VLDB 2022. TranAD is one of the most cited recent anomaly detection papers. It introduced several ideas that have since become common in the field, including self conditioning, adversarial training objectives, and transformer-based sequence reconstruction. This represents a significant step forward from the <a href="https://www.striim.com/press/striim-enables-a-new-wave-of-enterprise-ai-innovation-on-google-cloud-with-validata-cloud-ai-agents-and-mcp-agentlink/">LSTM baseline</a>.</p><p>The first prototype identified three limitations of the LSTM autoencoder. It only handles one feature at a time. It can’t tell you <em>how</em> unusual something is. And the threshold doesn’t adapt. This prototype addresses the first gap head on, extending detection from a single time series to 38 features simultaneously. It also adds something the LSTM couldn’t do at all: Root cause attribution tells you not just <em>that</em> something is wrong but <em>which features</em> are causing it.</p><h3>Why One Feature Isn’t Enough</h3><p>The first prototype monitored a single metric of NYC taxi demand and did it well. But real systems don’t have just one metric. A server has CPU utilization, memory consumption, disk I/O throughput, network traffic, page faults, and dozens more, all moving together in patterns shaped by the workload.</p><p>Think of it like a medical checkup. If a doctor only checks your heart rate and sees 95 beats per minute, that’s probably fine. You might have just walked up the stairs. But if your heart rate is 95, your blood pressure is dropping, your temperature is rising, and your oxygen saturation is falling, those four numbers together tell a story that no single number tells on its own. The danger isn’t in any one reading. It’s in the combination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KZaaHCbbHJlRWbKm.png" /></figure><p>Server telemetry works the same way. CPU at 90% during a heavy workload is normal. Memory and disk I/O will be high too, and all the numbers make sense together. CPU at 90% when memory is idle, disk is quiet, and network traffic is flat is suspicious. Something is chewing through compute cycles without doing any real work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VaD4n6v6M-6w_59m.png" /></figure><p>This is why you can’t just run 38 separate univariate detectors and call it a day. The relationships between features carry signal. An anomaly might show up as a subtle shift in how features relate to each other, not as a spike in any single one. A model that looks at each feature in isolation would miss these cross feature patterns entirely.</p><h3>How TranAD Works</h3><p>At its core, TranAD is still a reconstruction model. It learns what normal multivariate patterns look like during training and flags deviations at inference time. If the model can reconstruct the input well, the data looks normal. If the reconstruction falls apart, something unusual is happening. This is the same fundamental approach as the <a href="https://www.striim.com/blog/lstm-autoencoder-anomaly-detection/">LSTM autoencoder from Prototype </a>#1, just applied across all features at once.</p><p>But TranAD introduces two innovations that make it far more effective on complex, high dimensional data.</p><p><strong>Transformers instead of LSTMs.</strong> The LSTM reads a time series step by step, building up context as it goes. A transformer takes a different approach. It looks at all timesteps in the window simultaneously and learns which combinations of features and timesteps matter most for reconstruction.</p><p>This is the mechanism known as “attention”. Instead of treating every measurement as equally important, the model learns to focus on the relationships that actually carry signal. For 38 features with complex interactions, this matters. The transformer can learn that a spike in disk writes is only meaningful when paired with specific patterns in memory and network traffic, and weight its reconstruction accordingly.</p><p><strong>Two phase self conditioning.</strong> This is the clever part of the architecture. The model runs its reconstruction twice. Phase 1 produces an initial reconstruction with no prior knowledge of where errors might appear. The model then computes the reconstruction error from Phase 1 and feeds it back as a “focus signal” into Phase 2.</p><p>Think of it like proofreading an essay. Your first read catches the obvious issues. Your second read, now that you know where the rough spots are, catches subtler problems because you know exactly where to look. The Phase 2 reconstruction is sharper and produces cleaner separation between normal and anomalous scores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vVJp3Ge-qD7-zgPF.png" /></figure><p>The original paper also describes an adversarial training objective where the two decoders compete against each other. We explored this during development but found it produced unstable score distributions that broke downstream threshold calibration.</p><p>The exponential decay loss weighting from the paper proved far more effective for producing stable, well-separated scores in practice. The idea of this is that early in training, the model is nudged strongly toward accurate reconstruction, and as it stabilizes that pressure gradually fades, letting the model refine the structure of the learned representations without overcorrecting.</p><h3>The Prototype</h3><h3>Server Machine Dataset</h3><p>We validated this approach on the Server Machine Dataset (SMD) from the OmniAnomaly project. SMD contains real telemetry from 28 server machines at a large internet company, each recording 38 sensor features (CPU load, memory usage, disk I/O, network metrics) at regular intervals. We trained and evaluated on 4 representative machines.</p><p>SMD is the standard benchmark for multivariate anomaly detection. Every major paper in this space, OmniAnomaly, USAD, and TranAD itself, evaluates it. It plays the same role here that the NYC taxi dataset played for the univariate prototype.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WGfUxrD4oLIiNDL6.png" /></figure><p>Each machine provides 28,479 timesteps of training data containing normal operations only, and 28,479 timesteps of test data containing both normal and anomalous periods with ground truth labels. The test data also includes interpretation labels identifying which specific features caused each anomaly. This lets us evaluate root cause attribution, not just detection accuracy.</p><h3>Training</h3><p>The model processes data in sliding windows of 10 timesteps. Each window captures a short sequence of all 38 features, giving the transformer enough temporal context to learn normal patterns and cross feature relationships.</p><p>We used exponential decay loss weighting to control how the training signal shifts between the two reconstruction phases over time. This turned out to be one of the most impactful choices in the entire project. Switching from the paper’s proposed simpler weighting schedule to exponential decay alone improved F1 from 0.795 to 0.921 on our first test machine. The exponential schedule keeps the Phase 1 reconstruction signal strong throughout training, which gives Phase 2 a reliable foundation to build on rather than conditioning on noisy error signals from a first pass that hasn’t converged yet.</p><p>Training runs for 20 epochs with a learning rate of 0.0001 using AdamW with gradient clipping. The model has 127,538 parameters, small enough to train on CPU in a few minutes per machine.</p><h3>Training Data Quality</h3><p>The first blog <a href="https://www.striim.com/blog/lstm-autoencoder-anomaly-detection/">post</a> covered the importance of keeping training data clean, since the model learns “normal” from whatever data you give it. TranAD’s two phase architecture provides some natural resilience here. The self conditioning mechanism tends to amplify anomalous patterns rather than absorb them. If a few anomalies slip into the training set, the second pass will see them as high error regions and focus on them.</p><p>This actually makes anomalies <em>more</em> likely to be flagged as unusual rather than being quietly learned as normal. It doesn’t eliminate the need for data curation, but it provides an extra layer of safety compared to a standard autoencoder.</p><h3>Results</h3><p>Across the 4 reference machines, TranAD achieved an average F1 of 0.924 with strong performance across the board.</p><p>&lt;</p><p><strong>Machine</strong> <strong>F1</strong> <strong>Precision</strong> <strong>Recall</strong> <strong>AUC</strong> machine-1–1 0.926 0.862 1.000 0.992 machine-2–1 0.968 0.946 0.991 0.995 machine-3–2 0.965 0.936 0.996 0.996 machine-3–7 0.835 0.718 1.000 0.981 <strong>Average</strong> <strong>0.924</strong> <strong>0.866</strong> <strong>0.997</strong> <strong>0.991</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EBg8M_KYURHk6hWu.png" /></figure><ul><li>Machine-2–1 was the standout performer at F1 0.968, with near perfect precision and recall.</li><li>Machine-3–7 was the challenge case at F1 0.835. This machine has an extreme score distribution where test anomaly scores reach 144 times the training average, which makes threshold calibration particularly difficult.</li><li>Two of its five anomaly segments produce scores nearly indistinguishable from normal data, creating a practical ceiling that no amount of threshold tuning could overcome.</li></ul><p>For context, the LSTM autoencoder in Prototype #1 achieved perfect detection on its univariate taxi dataset, identifying all 5 known anomalies with zero false positives. That’s impressive, but also a simpler problem. One feature, five clearly distinct anomalies in a strongly periodic signal. TranAD tackles a fundamentally harder problem with 38 features, subtle correlated anomalies across different machines, and still delivers F1 above 0.92 on average.</p><h3>Root Cause Attribution</h3><p>This is where TranAD outshines the LSTM prototype. The LSTM could tell you <em>when</em> an anomaly happened, narrowing it down to a 6 hour window within a week. TranAD can tell you <em>when</em> and <em>which features</em> are responsible.</p><p>The mechanism is straightforward. The model reconstructs all 38 features independently. When an anomaly is detected, you look at which features have the highest reconstruction error relative to their normal baseline. We call this the elevation ratio. A feature with an elevation ratio of 100 means its reconstruction error is 100 times higher than what the model typically sees during normal operation. Features with high elevation are the ones behaving abnormally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pbszCvEblGE5DtQh.png" /></figure><p>If the model flags a server anomaly and the attribution shows that disk write throughput, network packet rate, and memory page faults have the highest elevation ratios, an operator immediately knows this looks like a disk I/O bottleneck cascading into memory pressure. It’s not a CPU issue. It’s not a network saturation problem. The attribution narrows the investigation from 38 possible dimensions to 2 or 3 and gives the operator a concrete hypothesis to start from.</p><p>Attribution quality averaged a HitRate@100% of 0.351 and NDCG@100% of 0.381 across the 4 machines. These metrics measure how well the model’s feature rankings align with the ground truth labels that identify which dimensions actually caused each anomaly. The numbers aren’t perfect, but attribution on multivariate time series is genuinely hard. Even an imperfect ranking that puts the right features in the top 5 out of 38 gives operators a meaningful head start compared to no attribution at all.</p><h3>Adaptive Thresholding with POT</h3><p>The first prototype flagged the threshold problem directly. A fixed percentile threshold calibrated on one dataset doesn’t transfer to another. What counts as “unusual” reconstruction error for taxi demand is meaningless for server metrics. Each deployment needs its own calibration.</p><p>This prototype addresses that with Peaks Over Threshold (POT), a method from extreme value theory. Instead of picking an arbitrary percentile, POT fits a statistical distribution called the Generalized Pareto Distribution to the tail of the anomaly score distribution. It answers a specific question. Given the pattern of normal scores, how extreme does a new score need to be before it’s statistically implausible? This makes the threshold data driven rather than hand tuned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0MrCv3ZWrZVLPuH4.png" /></figure><p>POT worked well on 3 of our 4 machines. Machine-3–7 was the exception. Its extreme score distribution, with a training mean of 0.075 versus a test mean of 10.845, caused POT to set a threshold so low that it flagged nearly all test data as anomalous. We addressed this with a validation step. After computing the POT threshold, the system checks what fraction of data would be flagged. If more than 20% would be classified as anomalous, the system falls back to a conservative percentile threshold instead.</p><p>This fallback was essential. It fixed machine-3–7 without regressing the other machines. But it’s worth being honest about the broader picture. Per machine tuning of the POT parameters, specifically the quantile level and scale factor, was still necessary. POT doesn’t eliminate the need for calibration. It makes the calibration more principled and less arbitrary.</p><h3>From Prototype to Production</h3><p>The prototype runs as a FastAPI REST API containerized in Docker. Send a batch of raw telemetry data and receive anomaly detection results with per feature root cause attribution. The API handles normalization, windowing, inference, thresholding, and attribution internally. Callers just send raw sensor readings and get structured JSON results back. Inference takes under 20 milliseconds per request on CPU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qsl7NVbmmOrc4HUm.png" /></figure><p>For a production deployment at scale, the architecture extends to handle thousands of devices. Picture 15,000 devices across 300 stores, each pushing one telemetry record per minute. That’s 250 messages per second flowing into a partitioned Kafka topic. Consumer workers maintain per device sliding window buffers of the last 10 records. Every time a new record arrives, the worker scores the full 10 row window against the device’s trained model via the stateless scoring containers. Only anomaly events flow downstream to TimescaleDB for dashboards and to a tiered alerting system that routes based on severity.</p><p>The estimated cloud cost for this full deployment is roughly $825 per month, about $0.055 per device per month for real time anomaly detection with sub minute latency and per feature root cause attribution. The key cost insight is that transformer models don’t require GPUs at moderate scale. At 127,000 parameters, CPU inference handles the throughput comfortably.</p><h3>Beyond the Demo</h3><p>The model was validated on server telemetry, but the architecture applies to any system where multiple correlated features need simultaneous monitoring. The value proposition goes beyond just detecting anomalies. It’s knowing which features are responsible.</p><p><strong>Financial transaction monitoring.</strong> Payment processors track dozens of metrics per transaction stream, including volume, average ticket size, decline rates, geographic distribution, and velocity patterns. A fraud ring doesn’t just increase volume. It creates a specific combination of high velocity, unusual geography, and abnormal ticket size that looks very different from a legitimate sales spike. Attribution turns “something is wrong with the East Coast payment stream” into “decline rates and geographic concentration are both abnormal, consistent with card testing.”</p><p><strong>Infrastructure and cloud operations.</strong> Modern infrastructure generates hundreds of metrics per service, covering latency percentiles, error rates, queue depths, and connection pool utilization. A cascading failure creates a specific fingerprint across these metrics that differs from a simple traffic spike. Root cause attribution can distinguish “the database connection pool is saturated, causing upstream latency” from “traffic increased and everything scaled proportionally.”</p><p><strong>Manufacturing and IoT.</strong> Industrial equipment with vibration sensors, temperature probes, pressure gauges, and power monitors produces exactly the kind of correlated multivariate data TranAD was designed for. A failing bearing doesn’t just increase vibration. It creates a pattern of rising vibration, rising temperature, and shifting power consumption that the model can detect before any single metric crosses an alarm threshold. Attribution identifies the specific sensor combination, pointing maintenance teams to the right component.</p><h3>What We Learned</h3><p>While building this prototype, we learned several practical insights.</p><ul><li><strong>The two phase architecture genuinely helps.</strong> This isn’t just a paper trick. The self conditioning mechanism empirically improved score separation between normal and anomalous data. Phase 2 consistently produces sharper, more discriminative scores than Phase 1 alone, because it knows where to focus.</li><li><strong>Loss weighting matters more than you’d expect.</strong> The difference between exponential decay and epoch inverse weighting was the single largest factor in our F1 improvement, bigger than learning rate tuning, architecture variants, or scoring mode selection. The weighting controls how quickly training shifts emphasis to the self conditioned phase, and getting this wrong degrades everything downstream.</li><li><strong>Root cause attribution is valuable even when imperfect.</strong> Operators don’t need a perfect feature ranking. They need a starting point. Going from “something is wrong with server 7” to “disk writes and memory page faults are abnormal” saves real investigation time, even if the model occasionally misranks the third or fourth most important feature.</li><li><strong>POT thresholding is powerful but not magic.</strong> Extreme value theory gives you a principled framework for setting thresholds, and that’s a real improvement over arbitrary percentiles. But per machine calibration was still necessary, and extreme score distributions can break the method entirely. The fallback mechanism is not optional.</li><li><strong>Transformers on CPU are viable at scale.</strong> The model runs inference in under 20 milliseconds on CPU. At 127,000 parameters, there’s no need for GPU infrastructure at moderate device counts. This keeps deployment costs low and infrastructure simple.</li></ul><h3>Where This Model Hits Its Limits</h3><p>After spending real time with this model, here’s where I think it actually breaks down.</p><ul><li><strong>The 10 timestep window is more restrictive than it sounds</strong>. It works well for anomalies that manifest within minutes to tens of minutes, which covers a lot of real workloads. But anything with slow onset (gradual memory leaks over days, seasonal drift over weeks) just won’t land in that window. The model sees each window independently and has no mechanism for tracking gradual change across successive windows. You could widen the window, but you pay for it in compute and in dilution of the cross feature signal that makes TranAD work in the first place.</li><li><strong>Attribution is the feature I’m most excited about…and also the one that gives me pause.</strong> When it works, it’s genuinely useful. Going from “machine-2–1 is anomalous” to “disk I/O and memory paging are abnormal” is a real win for an operator. But the quality varies a lot. Machine-3–2 hit detection F1 of 0.965 and near zero on attribution, because the dimensions actually driving the anomaly didn’t align with where the model placed its reconstruction error. You get the detection but the explanation collapses. Attribution lands best when a small number of features drive the anomaly. When the anomaly is spread across many dimensions, the feature ranking starts to look like noise.</li><li><strong>The stationarity assumption is the elephant in the room.</strong> The model assumes “normal” doesn’t move. In any production system worth monitoring, “normal” moves constantly: new deployments, capacity upgrades, workload mix changes, all of it shifts the baseline. There’s nothing in this architecture that detects when the model’s definition of normal has gone stale, and nothing that retrains it when that happens. That’s the gap I find most important, and it’s exactly the one I’m targeting next.</li></ul><p>Overall, my impression is that TranAD is a strong fit when you have a high dimensional system, short horizon anomalies, and a small number of features tend to drive each anomaly. Server telemetry is basically the canonical example, which is why the SMD numbers look as good as they do. It’s a weaker fit when anomalies are slow, distributed across many dimensions, or when the underlying system is non-stationary in ways that move faster than your retraining cadence.</p><p>The transformer plus self conditioning is a real architectural step forward, but it’s not a free lunch, and I’d rather be upfront about where the cracks are than oversell it.</p><h3>What’s Next</h3><p>The first prototype handled one feature at a time. This second prototype handles 38 features at once and tells you which ones are responsible. But one limitation from the original LSTM blog remains unaddressed. Neither model can tell you <em>how</em> unusual something is. They produce anomaly scores that cross a threshold, but those scores aren’t calibrated probabilities. The model can’t distinguish a 1 in 10,000 event from a 1 in 1,000,000 event.</p><p>The next prototype will tackle that gap with probabilistic approaches that produce calibrated uncertainty estimates, giving you not just “is this anomalous” but “how anomalous” with a meaningful confidence level.</p><p>Each prototype in this series builds on the last, working toward a comprehensive anomaly detection toolkit that matches the right technique to the right problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=022c353c0e07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/striim-labs/tranad-multivariate-anomaly-detection-022c353c0e07">TranAD Multivariate Anomaly Detection</a> was originally published in <a href="https://medium.com/striim-labs">Striim Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LSTM Autoencoder: An AI Prototype for Anomaly Detection]]></title>
            <link>https://medium.com/striim-labs/lstm-autoencoder-an-ai-prototype-for-anomaly-detection-962eb7b0d3cb?source=rss-2babce7129b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/962eb7b0d3cb</guid>
            <dc:creator><![CDATA[Jon Paino]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 20:30:56 GMT</pubDate>
            <atom:updated>2026-04-21T20:30:56.025Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is the first AI Prototype in our anomaly detection series from Striim Labs. We start with the LSTM autoencoder, a model that learns the rhythm of your data and flags anything that doesn’t fit.</em></p><p>Ready to dive in with LSTM? Click here to jump into the Github repo and test the prototype for yourself!<br> Got questions? Reach out to us at <a href="/service/mailto:striimlabs@striim.com">striimlabs@striim.com</a></p><h3>Detecting Anomalies in Streaming Time Series Data</h3><p>As<a href="https://www.striim.com/blog/introducing-striim-labs/"> we announced recently</a>, we’re excited to introduce Striim Labs: an applied research group focused on delivering working “AI Prototypes” at the intersection of AI/ML and real-time data streaming. To kick things off, we’ll be sharing a prototype model LSTM autoencoder, the first in our series on anomaly detection.</p><p>The prototype is based on the EncDec-AD architecture from<a href="https://arxiv.org/abs/1607.00148"> Malhotra et al. (2016)</a>, “LSTM-based Encoder-Decoder for Multi-Sensor Anomaly Detection.” This paper was one of the first to show that an LSTM encoder-decoder trained only on normal data could reliably detect anomalies through reconstruction error alone. To this day it remains the baseline that nearly every new anomaly detection paper benchmarks against.</p><p>We chose it as our starting point for the same reason, it’s the most intuitive approach, it performs well on data with strong periodic patterns, and it gives us a clear foundation to build on as the series progresses into more sophisticated techniques.</p><p>Let’s dig into the model, the problem it solves, and the<a href="https://github.com/striim-labs/lstm-autoencoder-spark-kafka"> AI Prototype</a> you can deploy in your own environment.</p><h3>The Problem: Finding Needles in a Haystack of Data</h3><p>Every business generates streams of data such as transaction volumes, server metrics, customer activity, sensor readings. Most of the time, the data follows predictable patterns, such as when retail spend spikes during the holidays and taxi demand surges at rush hour.</p><p>But occasionally, something unexpected happens, whether an unexpected weather event or an unforeseen incident. These events are rare, unpredictable, and often costly.</p><p>Traditional rule based systems require you to define what “abnormal” means upfront, such as “flag any transaction over $10,000” or “alert if CPU exceeds 90% usage”. But the most dangerous anomalies are the ones you haven’t thought of yet.</p><p>What if, instead of defining every possible anomaly, we could teach a model what “normal” looks like, and simply let it flag anything else?</p><p>That’s exactly what an LSTM autoencoder does.</p><h3>Why LSTM?</h3><p>The “LSTM” in the name stands for <strong>Long Short-Term Memory</strong>, a type of neural network that can remember context over long sequences. This matters because a single data point means very different things depending on <em>when</em> it occurs.</p><ul><li><strong>At 3 AM</strong>, 5,000 passengers is high. Something unusual might be happening.</li><li><strong>At 5 PM</strong>, 5,000 passengers is low. Rush hour should be much busier.</li></ul><p>A simple model that looks at each data point in isolation would miss this context. The LSTM reads the entire sequence and understands the <em>position</em> of each value within the broader pattern. It knows what Monday morning looks like versus Saturday night, and it knows when a value is normal for its time slot versus when it’s an outlier.</p><h3>The Copycat Test</h3><p>The core idea behind an autoencoder is surprisingly intuitive. Think of it like a game of telephone.</p><ol><li><strong>You play a song for someone</strong> (feed data into the model)</li><li><strong>They listen and try to memorize it</strong> (the model compresses the data)</li><li><strong>They hum it back to you</strong> (the model reconstructs the data)</li></ol><p>If the song is one they’ve heard hundreds of times, they’ll hum it back almost perfectly. But if you play something completely unfamiliar, their attempt to hum it back will sound off. The gap between the original and their reproduction tells you how “unusual” the input was. That gap is called the <strong>reconstruction error</strong>, and it’s the heart of anomaly detection with autoencoders. High error means the model is struggling to reproduce the input, which means the input doesn’t match the patterns it learned during training.</p><p>The key insight is that <strong>we only train the model on normal data</strong>. It never sees anomalies during training. So when an anomaly appears, the model has no idea how to reproduce it, and the reconstruction error spikes. This is what makes the approach powerful as we don’t need labeled examples of every possible anomaly. We just need enough normal data to teach the model what “normal” looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1dGBGulHxUfMlgzf.jpg" /></figure><p>That gap is called the <strong>reconstruction error</strong>, and it’s the heart of anomaly detection with autoencoders. High error means the model is struggling to reproduce the input, which means the input doesn’t match the patterns it learned during training.</p><p>The key insight is that <strong>we only train the model on normal data</strong>. It never sees anomalies during training. So when an anomaly appears, the model has no idea how to reproduce it, and the reconstruction error spikes. This is what makes the approach powerful as we don’t need labeled examples of every possible anomaly. We just need enough normal data to teach the model what “normal” looks like.</p><h3>Architecture designed for sequential data</h3><p>The model we built is called a <strong>Long Short-Term Memory Autoencoder (LSTM-AE)</strong>, a neural network architecture specifically designed for sequential data like time series. Here’s how the pieces fit together.</p><h3>The Bottleneck</h3><p>The architecture has an hourglass shape. Data flows in wide, gets squeezed through a narrow bottleneck, and then gets expanded back out.</p><ul><li><strong>Input</strong> is one full week of data, 336 measurements taken every 30 minutes (48 per day x 7 days)</li><li><strong>Bottleneck</strong> is where the model compresses that entire week down to just 64 numbers</li><li><strong>Output</strong> is the model’s reconstruction of the full 336 measurement week from those 64 numbers</li></ul><p>That’s a <strong>5x compression ratio</strong>. The model can’t memorize every data point, it’s forced to learn the <em>underlying pattern</em> instead. This is also key as learning every data point is both impracticable and leads to poor generalization.</p><p>We found that compression is what makes the model useful for anomaly detection. When the input follows the normal pattern the model has learned (daily rush hour peaks, nightly lulls, weekend dips), it can compress and reconstruct it faithfully. But when the input contains something the model hasn’t seen, like a sudden spike or an unusual drop, the bottleneck can’t capture it and the reconstruction falls apart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4i5KnPK56EMSgn0O.jpg" /></figure><h3>The Prototype: Testing on NYC Taxi Passenger Data</h3><p>To validate this approach, we built a working prototype using a well known benchmark dataset, <strong>NYC taxi passenger demand</strong> from July 2014 through January 2015. The dataset contains roughly 10,000 measurements taken every 30 minutes, or about 29 complete weeks of data.</p><h3>Why Taxi Data?</h3><p>NYC taxi demand is ideal for prototyping because it has strong, repeating patterns that are easy to understand.</p><ul><li><strong>Daily cycles</strong> where demand peaks during morning and evening rush hours, then drops overnight</li><li><strong>Weekly cycles</strong> where weekdays are busier than weekends</li><li><strong>Predictable rhythms</strong> where the pattern repeats week after week with minor variations</li></ul><p>More importantly, the dataset contains <strong>5 known real world anomalies</strong> that disrupted the normal pattern in ways that are easy to verify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-L4Lj178XP-mkweFx0hmoQ.png" /></figure><h3>Training on Normal Weeks Only</h3><p><strong>We split the 29 weeks of data carefully.</strong></p><ul><li>8 normal weeks<strong> for training so the model only sees regular patterns</strong></li><li>6 normal weeks<strong> for validation and threshold calibration</strong></li><li>15 weeks<strong> for testing containing a mix of normal weeks and all 5 anomaly weeks</strong></li></ul><p>The model trains by trying to reconstruct each normal week as accurately as possible. Over about 100 training cycles (epochs), it gradually learns the daily and weekly rhythms of NYC taxi demand. Training stops automatically when the model’s accuracy plateaus, a technique called early stopping.</p><p>After training, we measure how well the model reconstructs the validation data and set a detection threshold at the 99.99th percentile of reconstruction errors on normal data. Anything above that threshold is flagged as anomalous.</p><h3>How to Keep Training Data Clean</h3><p>Since the model learns “normal” from its training data, the quality of that training data matters. In our taxi dataset the anomalies are well documented, so we know exactly which weeks to exclude. But in a real world deployment, how do you guarantee your training data doesn’t contain unlabeled anomalies that could silently corrupt what the model learns as “normal”?</p><p>The most practical approach is to work with subject matter experts to curate a training window. Select a time period that domain experts are confident represents normal operations. For most operational data this is straightforward, just pick two months where nothing unusual happened. A smaller, vetted dataset is far more valuable than a large one that might be contaminated.</p><p>The LSTM autoencoder itself doesn’t have built in resilience to training data contamination, which is one reason it works best as a starting point with carefully curated data. Later prototypes in this series incorporate modified training objectives that automatically down weight suspicious points during training, so even if a few anomalies slip into the training set, they don’t corrupt the learned model. We’ll cover those techniques in detail when we get to them.</p><h3>Results:</h3><p>On the test set, the model correctly identified all 5 anomaly weeks without a single false positive.</p><p>But raw detection isn’t the whole story. The system also <strong>localizes</strong> anomalies within each week, narrowing down the alert from “this week is unusual” to “the anomaly is in this specific 6 hour window.” This is critical for operational use because an operator investigating an alert needs to know <em>when</em> to look, not just that something happened somewhere in a 7 day span.</p><p><strong>Christmas Day (demand drop).</strong> The model expected typical weekday demand patterns. When Christmas demand plummeted, the model’s reconstruction showed what a normal day <em>should</em> look like, making the gap enormous. It’s also worth noting that the entire Christmas week shows slightly lower demand overall, but the model didn’t flag every point in the window. It was able to distinguish between “a little quieter than usual” and “something is genuinely wrong,” zeroing in on the actual collapse in demand rather than the surrounding dip. A simple rule based approach that just checks whether values fall below a fixed threshold would have either missed the real anomaly or flagged the entire week indiscriminately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TEEiYjLsmFiCnug1.jpg" /></figure><p>In every case, the detection logic is the same. The model tries to “copy” the week, fails at the unusual parts, and the gap between original and copy reveals exactly where and how the anomaly occurred.</p><h3>From Prototype to Production</h3><p>During the course of this research, we discovered that a model that works on historical data is useful for research, but a model that works in real time is useful for operations. With that in mind, we built a full streaming pipeline to prove the approach works end to end.</p><h3>The Architecture</h3><p>The system runs as a set of containerized services orchestrated with Docker.</p><ol><li><strong>Data Producer</strong> streams records into Apache Kafka, simulating a live data feed</li><li><strong>Apache Kafka</strong> acts as the message queue, buffering incoming data</li><li><strong>Apache Spark</strong> (Structured Streaming) consumes data from Kafka in micro batches</li><li><strong>LSTM Detector</strong> processes each complete week of data through the trained model</li><li><strong>Dash Dashboard</strong> displays results in real time, showing incoming data, detected anomalies, and the localized 6 hour windows where anomalies occurred</li></ol><p>The entire pipeline runs with docker compose up, streaming from the first data point to anomaly alert on a live dashboard. When the model detects an anomaly, the dashboard highlights the specific time window in red, showing operators exactly when and where the disruption occurred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iEoWXuBu3BzZCku5.jpg" /></figure><h3>Beyond the Demo</h3><p>NYC taxi data makes a great demo, but the model doesn’t know anything about taxis. It learned a <em>pattern</em> in the repeating weekly rhythm with daily subcycles. That same pattern exists in virtually any operational data.</p><p><strong>Financial transaction monitoring.</strong> Payment processors see predictable daily and weekly volume patterns, higher during business hours, lower overnight, minimal on weekends. A flash crash, fraud ring activation, or system outage disrupts that rhythm in exactly the same way a marathon or blizzard disrupts taxi demand.</p><p><strong>Infrastructure monitoring.</strong> Server CPU, memory, and network traffic follow daily usage patterns. An outage, DDoS attack, or misconfigured deployment creates the same kind of spike or drop that the model is designed to catch.</p><p><strong>IoT and manufacturing.</strong> Sensor readings from industrial equipment follow operating cycles. A failing bearing, overheating motor, or process deviation breaks the expected pattern.</p><p>The model doesn’t need to be retrained from scratch for each domain. The architecture itself is domain agnostic. You feed it normal data from your domain, it learns your patterns, and it flags deviations from your normal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pLEtkPrdYFEiI37L.jpg" /></figure><h3>What We Learned</h3><p>Building this prototype surfaced several practical insights.</p><ul><li><strong>Training on normal data only is powerful and practical.</strong> In most real world scenarios, labeled anomaly data is scarce or nonexistent. This approach only requires a representative sample of normal behavior, which is almost always available.</li><li><strong>The bottleneck is doing the heavy lifting.</strong> The 5x compression ratio (336 values to 64 numbers) is what forces the model to learn patterns rather than memorize data. Too much capacity and the model memorizes everything, including anomalies. Too little and it can’t reconstruct normal data accurately enough. The 64 unit hidden dimension hit the sweet spot for this dataset.</li><li><strong>Localization matters as much as detection.</strong> Knowing that “this week is anomalous” is a starting point. Knowing that “the anomaly is concentrated in this 6 hour window on Tuesday afternoon” is actionable. The sliding window localization technique adds significant operational value with minimal additional computation.</li><li><strong>Streaming is where the value lives.</strong> The model achieves sub second inference per weekly window. Combined with the Kafka and Spark pipeline, this means anomalies can be surfaced within seconds of the data arriving, fast enough for real time operational response.</li></ul><h3>Failure to Adapt: Where This Model Hits Its Limits</h3><p>The LSTM autoencoder performed flawlessly on our taxi dataset, but the approach has inherent tradeoffs worth understanding. These limitations also motivate the alternative prototypes we explore later in this series.</p><p><strong>It needs data with a strong repeating cycle.</strong> The model learns a dominant periodic pattern (in our case, a weekly rhythm with daily subcycles) and flags deviations from it. If your data has no clear periodicity, or the dominant cycle is shorter than about 50 time steps, reconstruction based detection adds complexity without much benefit. Simpler methods like Isolation Forest tend to outperform in those scenarios.</p><p><strong>It can tell you something is unusual, but not <em>how</em> unusual.</strong> Reconstruction error measures whether data “looks different” from normal, but it doesn’t model a probability distribution. The model can’t distinguish a 1 in 10,000 event from a 1 in 1,000,000 event. For use cases like financial risk scoring that need calibrated anomaly likelihoods, probabilistic models like variational autoencoders are better suited.</p><p><strong>The threshold doesn’t adapt over time.</strong> Our detection threshold is a fixed percentile set from a single validation set. That threshold won’t transfer to a new domain because what’s “normal” reconstruction error for taxi demand is meaningless for financial transactions or server metrics. Each deployment requires its own calibration and testing to avoid being too sensitive (false alarms) or too lenient (missed anomalies). Adaptive approaches like Peaks Over Threshold (POT) can reduce this burden, and later prototypes in this series incorporate that flexibility.</p><h3>What’s Next</h3><p>This LSTM autoencoder is the first AI Prototype in our anomaly detection series. It excels at learning normal behavior from unlabeled data with strong temporal patterns, but as the limitations above reveal, no single model covers every scenario. In upcoming prototypes, we’ll tackle those gaps head on.</p><ul><li><strong>Probabilistic scoring</strong> with variational autoencoders that can quantify <em>how</em> unlikely an observation is, not just flag that it’s different</li><li><strong>Multivariate modeling</strong> where the relationships <em>between</em> features matter as much as temporal patterns</li><li><strong>Adaptive thresholding</strong> with approaches that adjust to non stationary data, so detection stays calibrated even as “normal” evolves</li></ul><p>Each AI Prototype in the series builds on the lessons of the previous one, working toward a comprehensive anomaly detection toolkit that matches the right approach to the right data.</p><h3>Try It Yourself</h3><p>The full prototype is open source and ready to deploy, try it yourself <a href="https://github.com/striim-labs/lstm-autoencoder-spark-kafka">here</a>.</p><p>We built this prototype to start a conversation, not end one. If you’re working on anomaly detection in your own domain, we’d love to hear what’s working, what isn’t, and what you’d like to see from a real-time detection prototype.</p><p>Drop us a line at striimlabs@striim.com or connect with us on <a href="https://www.linkedin.com/company/striim/">LinkedIn</a>.</p><p>This is just the first prototype in the series. Follow us on Medium to get notified when we publish the next one: TranAD, a transformer-based model that monitors dozens of features at once and tells you which ones are causing trouble..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=962eb7b0d3cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/striim-labs/lstm-autoencoder-an-ai-prototype-for-anomaly-detection-962eb7b0d3cb">LSTM Autoencoder: An AI Prototype for Anomaly Detection</a> was originally published in <a href="https://medium.com/striim-labs">Striim Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>