New to Claude Skills? Learn how to install them →

jeremylongshore on GitHub

Detecting Data Anomalies

Free

Identify unusual patterns in datasets with machine learning.

Get this skill

Free · Opens the source repo

What Detecting Data Anomalies does

Detecting Data Anomalies is a skill designed for data scientists and analysts who need to identify outliers and anomalies in their datasets using advanced statistical and machine learning techniques. This skill encompasses the entire anomaly detection pipeline, from data ingestion to result interpretation. It supports various algorithms such as Isolation Forest, One-Class SVM, Local Outlier Factor, and autoencoders, allowing users to choose the most appropriate method based on the characteristics of their data.

To use this skill effectively, users must have a dataset in formats like CSV, JSON, or Parquet, with a minimum of 500 data points for reliable results. The skill guides users through essential preprocessing steps, including feature scaling and handling missing values, before applying the selected anomaly detection algorithm. Once the model is trained, it generates anomaly scores for each data point, classifying them as normal or anomalous based on a user-defined threshold.

The output includes a comprehensive summary report detailing the total number of data points, counts of detected anomalies, and visualizations to help users understand the results. This skill is particularly beneficial for professionals in fields such as cybersecurity, manufacturing, and finance, where identifying anomalies can prevent significant issues like fraud or equipment failure.

Overall, Detecting Data Anomalies is a robust tool for anyone looking to leverage machine learning for anomaly detection, providing clear instructions and detailed output to facilitate effective data analysis.

When to use it

Use this skill when you have a sizable dataset and need to uncover unexpected deviations from normal behavior, especially in fields like finance, manufacturing, or network security.

When not to use it

This skill may not be suitable for very small datasets (less than 500 points) or when real-time anomaly detection is required, as it focuses on batch processing.

What you can build with it

Network Intrusion Detection

Apply Isolation Forest to 50K network flow records to flag port-scan and DDoS patterns with high precision.

Manufacturing Quality Control

Run Local Outlier Factor on sensor readings from 10K production cycles to detect equipment degradation anomalies.

Financial Transaction Monitoring

Train an autoencoder on 100K legitimate transactions to flag those with high reconstruction errors, aiding in fraud detection.

How to install Detecting Data Anomalies

View source

1. Install with the skills CLI

npx skills add jeremylongshore/claude-code-plugins-plus-skills/detecting-data-anomalies --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by jeremylongshore

Detecting Data Anomalies

Overview

Identify anomalies and outliers in datasets using statistical and machine learning algorithms including Isolation Forest, One-Class SVM, Local Outlier Factor, and autoencoders. This skill handles the full detection pipeline from data ingestion and feature scaling through algorithm selection, threshold tuning, and result interpretation with anomaly scoring.

Prerequisites

  • Python 3.9+ with scikit-learn >= 1.3 (pip install scikit-learn)
  • pandas and NumPy for data manipulation (pip install pandas numpy)
  • matplotlib or seaborn for anomaly visualizations (pip install matplotlib seaborn)
  • Dataset in CSV, JSON, Parquet, or database-queryable format
  • Minimum 500 data points for statistical significance (1000+ recommended)
  • Optional: PyTorch or TensorFlow for autoencoder-based detection on complex patterns

Instructions

  1. Load the dataset using the Read tool and verify schema, column types, and row count
  2. Profile feature distributions using descriptive statistics to understand baseline behavior
  3. Handle missing values via imputation (median for numeric, mode for categorical) or row exclusion
  4. Apply StandardScaler or MinMaxScaler to numeric features to normalize magnitude differences
  5. Select the detection algorithm based on data characteristics:
    • Isolation Forest: high-dimensional data, no assumptions on distribution
    • One-Class SVM: well-defined normal class with clear decision boundary
    • Local Outlier Factor: density-varying data with local anomaly patterns
    • Autoencoder: complex temporal or image data with non-linear relationships
  6. Set the contamination parameter to the expected anomaly proportion (start with 0.01-0.05)
  7. Fit the model on the training partition and generate anomaly scores for each data point
  8. Apply the decision threshold to classify points as normal (-1) or anomalous (1)
  9. Analyze flagged anomalies for common characteristics, temporal clusters, or feature correlations
  10. Generate a summary report with detection counts, score distributions, and visualization plots

See ${CLAUDE_SKILL_DIR}/references/implementation.md for the detailed implementation guide.

Output

  • Anomaly detection summary: total points, anomaly count, contamination rate
  • Per-record anomaly scores with classification labels
  • Algorithm configuration: model type, contamination, distance metric, threshold
  • Feature importance ranking showing which dimensions drive anomaly flags
  • Visualization: scatter plot of anomaly scores, distribution histogram, t-SNE cluster plot
  • CSV export of flagged records with anomaly scores and contributing features

Error Handling

ErrorCauseSolution
Insufficient data volumeFewer than 100 data points for model fittingCollect additional data or switch to simple statistical methods (z-score, IQR)
High false positive rateContamination parameter set too high or features not scaledLower contamination to 0.01; verify StandardScaler applied; refine feature selection
Algorithm OOM on large datasetIsolation Forest or LOF exceeds available memorySubsample data for training; use max_samples parameter; switch to streaming approach
Feature scaling mismatchMixed numeric and categorical features without proper encodingOne-hot encode categoricals separately; scale numeric features independently
No ground truth for validationUnlabeled dataset prevents accuracy measurementUse domain expert review on top-N anomalies; implement feedback loop to refine threshold

See ${CLAUDE_SKILL_DIR}/references/errors.md for the full error reference.

Examples

Scenario 1: Network Intrusion Detection -- Apply Isolation Forest to 50K network flow records with features: packet count, byte volume, duration, protocol type. Expected contamination: 2%. Target: flag port-scan and DDoS patterns with precision above 0.85.

Scenario 2: Manufacturing Quality Control -- Run LOF on sensor readings (temperature, vibration, pressure) from 10K production cycles. Detect equipment degradation anomalies. Visualize flagged cycles on a time-series plot with normal operating bands.

Scenario 3: Financial Transaction Monitoring -- Train an autoencoder on 100K legitimate transactions. Reconstruct test transactions and flag those with reconstruction error above the 99th percentile. Report flagged transactions with amount, merchant category, and time-of-day features.

Resources

  • scikit-learn Anomaly Detection -- Isolation Forest, LOF, One-Class SVM
  • PyOD Library -- 40+ outlier detection algorithms with unified API
  • Autoencoder anomaly detection: Keras/PyTorch reconstruction-error approach
  • Feature scaling: StandardScaler, RobustScaler, MinMaxScaler selection guide
  • Evaluation without labels: silhouette analysis, domain expert review protocols

Frequently asked questions about Detecting Data Anomalies

Similar skills