Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 11 Anomaly Detection

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🤯 Your stomach gets a new lining every 3–4 days.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Cover Image for Anomaly Detection: Identifying Rare and Unusual Patterns in Data

Anomaly Detection: Identifying Rare and Unusual Patterns in Data

Learn how anomaly detection models identify unusual data points using statistical methods such as Gaussian distributions. Understand how to detect fraud, system failures, and rare events in real-world datasets.

Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Fri Feb 27 2026

Share This on

← Previous

K-Means Clustering

Next →

Anomaly Detection Using Gaussian Distribution: Detecting Outliers with Probability Models

👁️‍🗨️ Anomaly Detection

Machine learning technique used to identify unusual data points that do not resemble the majority of the data.

The goal is to detect rare or abnormal events.

It is typically treated as an unsupervised learning problem because:

  • You usually have many examples of normal data.
  • You rarely have labeled examples of anomalies.

Applications (Unsupervised Learning)

  • Fraud detection
  • Manufacturing defects
  • Data center monitoring
  • Unusual user behavior

Example

  • You run a power utility (supplying electricity to customers) and want to monitor your electric plants to see if any one of them might be behaving strangely.
  • A computer vision / security application, where you examine video images to see if anyone in your company’s parking lot is acting in an unusual way.

Note: Even though anomaly detection is mostly unsupervised,
a small labeled dataset is extremely useful for evaluation and tuning.

Core Idea

Anomaly detection identifies unusual data points that do not resemble most of the data.

The idea is simple:

  • Learn what “normal” looks like.
  • Flag anything that looks very unlikely.

The model learns:

  • High probability regions → where most normal data lies
  • Low probability regions → unusual areas

Anomalies naturally fall into low-density regions.

1. 📚 Train a Probability Model

Given unlabeled data:

x(1),x(2),...,x(m)x^{(1)}, x^{(2)}, ..., x^{(m)}x(1),x(2),...,x(m)

Split the data into

  1. Training set: Used to learn the probability model.
  2. Cross-validation : tune ε\varepsilonε, select features
  3. Test sets: Used for final evaluation only.

Model the probability distribution of the data:

p(x)p(x)p(x)

Assume features follow a Gaussian (normal) distribution

2. 🔎 Evaluate New Data (xtest) (x_{test})(xtest​)

Flag a new example xtestx_{test}xtest​ as an anomaly if:

Decision rule:

  • If p(xtest)<εp(x_{test}) < \varepsilonp(xtest​)<ε → Anomaly
  • Else → Normal

Where:

  • p(x)p(x)p(x)= probability of the example under the learned model
  • ε\varepsilonε = small threshold value

If the probability is very low, the example is considered unusual.


Common Applications

1. Fraud Detection

Used to detect:

  • Unusual login behavior
  • Suspicious transactions
  • Compromised accounts

Possible features:

  • Number of logins
  • Number of transactions
  • Pages visited
  • Typing speed
  • User activity patterns

2. Manufacturing

Used to detect defective products such as:

  • Aircraft engines
  • Industrial components
  • Hardware parts

3. Data Center Monitoring

Used to monitor server behavior:

Features may include:

  • CPU usage
  • Memory usage
  • Disk activity
  • Network traffic
  • Derived metrics

If ( p(x) ) becomes very small → the machine may be failing and should be reviewed.


What Comes Next

Typically, anomaly detection uses:

  • The Gaussian (Normal) distribution
  • Probability modeling techniques
  • Threshold selection methods

Next steps usually involve:

  1. Modeling each feature using a Gaussian distribution
  2. Combining them into a joint probability model
  3. Using that model to compute ( p(x) )


Key Idea

We model normal behavior using Gaussian density estimation.
Any example with very low probability under this model is considered anomalous.

AI-Machine-Learning/11-Anomaly-Detection
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2026 All rights reserved.