You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: LSTM Autoencoder for Anomaly Detection on Damped Oscillator Dataset - MSE
8
8
# LSTM Autoencoder for Anomaly Detection on Damped Oscillator Dataset - MSE loss vs Physics-Informed loss
9
9
10
10
## Abstract
11
-
Anomalies are data points that deviate, subtly or evidently, from normal behaviour. They can occur in a variety of contexts: economics, cybersecurity, manifacturing, robotics and many others. Detecting anomalies is a fundamental task to prevent potential financial consequences, information loss and damage to systems or people. In this project, I study **reconstruction-based Anomaly Detection** on simulated **damped harmonic oscillator** data training an **LSTM Autoencoder**, comparing traditional **mean squared error (MSE) loss** to a **Physics-informed loss** that embeds the system's dynamics equation. Normal data is simulated from a noisy underdamped harmonic oscillator. Anomalies (spikes, level shifts, frequency shifts and variance bursts) are inserted and labelled at window level after overlapping segmentation (128-size window, stride 32) and standardization. The baseline LSTM Autoencoder is first trained with MSE loss. Afterwards it is trained with a total loss that sums MSE and an ODE residual embedding the damped oscillator equation, encouraging reconstructions with physical knowledge. The two models are evaluated via **F1-maximizing reconstruction-error thresholding** on validation data. On test data, both models present strong performance with **97.3% AUROC and 97.7% AUPRC**. **Physics-informed loss slightly improves F1 score, compared to MSE loss, from 89% to 89.4%**, demonstrating better sensitivity to anomalies thanks to it's dynamics knowledge.
11
+
Anomalies are data points that deviate, subtly or evidently, from normal behaviour. They can occur in a variety of contexts: economics, cybersecurity, manifacturing, robotics and many others. Detecting anomalies is a fundamental task to prevent potential financial consequences, information loss and damage to systems or people. In this project, I study **reconstruction-based Anomaly Detection** on simulated **damped harmonic oscillator** data training an **LSTM Autoencoder**, comparing traditional **mean squared error (MSE) loss** to a **Physics-informed loss** that embeds the system's dynamics equation. Normal data is simulated from a noisy underdamped harmonic oscillator. Anomalies (spikes, level shifts, frequency shifts and variance bursts) are inserted and labelled at window level after overlapping segmentation (128-size window, stride 32) and standardization. The baseline LSTM Autoencoder is first trained with MSE loss. Afterwards it is trained with a total loss that sums MSE and an ODE residual embedding the damped oscillator equation, encouraging reconstructions with physical knowledge. The two models are evaluated via **F1-maximizing reconstruction-error thresholding** and **Youden J. criterion** on validation data. On test data, both models present strong performance with **97.6% AUROC and 98.0% AUPRC**. **Physics-informed loss slightly improves F1 score, compared to MSE loss, from 90.2% to 91.3%**, demonstrating better sensitivity to anomalies thanks to it's dynamics knowledge.
12
12
13
13
## Introduction
14
14
When studying the behaviour of **dynamical systems**, it's fundamental to be able to robustly analyze **time series data** and understand temporal dependencies and constraints imposed by dynamical equations. With the right tools it is possible to detect anomalies in time series data and potential prevent failures, flag sensor faults and regime shifts. In this project, thanks to it's capability of understanding time-sequantial data, I use LSTM Autoencoder to learn the **manifold** of normal dynamics and flag as anomalous temporal windows with high reconstruction error. I then compare coventional training with **MSE loss** to a **Physics informed loss** that augments MSE with the **damped oscillator differential equation**.
@@ -108,7 +108,45 @@ For an **LSTM Autoencoder**:
108
108
During training on normal data, LSTM learns to reconstruct normal dynamics and anomalies deviate from normal learned patterns, therefore yielding higher reconstruction error $\left\| X - \hat{X}\right\|^2$.
109
109
110
110
## MSE loss vs. Physics-Informed loss
111
-
....
111
+
The LSTM Autoencoder is trained to minimize mean squared error (MSE) between each input window $X$ and it's reconstruction $\hat{X}$. For a $B$-sized batch, the objective function is
This loss encourages reproduction of observed patterns with no physical knowledge of the normal data learned. To solve this problem I introduce a physics-informed training function where the loss is augmented with a penalty derived from the damped harmonic oscillatror equation
0 commit comments