Data Anomaly Detectionのロゴ

Data Anomaly Detection

コミュニティ
wentorai
data-anomaly-detection

Detect anomalies and outliers in research data using statistical methods

概要

公開者wentorai
リポジトリresearch-plugins
スキル名data-anomaly-detection
スター
294
フォーク
42
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    wentoraiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Data Anomaly Detection」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/wentorai/research-plugins/tree/main/skills/analysis/statistics/data-anomaly-detection
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wentorai/research-plugins.git /tmp/research-plugins
mkdir -p .claude/skills
cp -r /tmp/research-plugins/skills/analysis/statistics/data-anomaly-detection .claude/skills/data-anomaly-detection
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでData Anomaly Detectionを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にData Anomaly Detectionを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Data Anomaly Detectionは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Data Anomaly Detection

A skill for identifying anomalies, outliers, and suspicious patterns in research datasets. Combines classical statistical methods with modern machine learning approaches to flag data points that deviate significantly from expected distributions, helping researchers maintain data integrity and uncover genuine scientific findings.

Overview

Anomalous data points in research datasets can arise from measurement errors, instrument malfunction, data entry mistakes, or genuine rare phenomena. Distinguishing between these sources is critical: blindly removing outliers can bias results, while ignoring measurement errors introduces noise. This skill provides a structured framework for detecting, classifying, and handling anomalies in univariate, multivariate, and time-series research data.

The approach follows a three-stage pipeline: detection (flagging candidate anomalies), diagnosis (determining likely cause), and decision (remove, transform, or retain with justification). Every decision is logged for reproducibility and transparent reporting.

Statistical Detection Methods

Univariate Outlier Detection

python
import numpy as np
from scipy import stats

def detect_univariate_outliers(data: np.ndarray, method: str = 'iqr') -> dict:
    """
    Detect outliers using classical univariate methods.

    Methods:
        'iqr': Interquartile range (1.5x IQR rule)
        'zscore': Z-score threshold (|z| > 3)
        'mad': Median absolute deviation (robust)
        'grubbs': Grubbs' test for single outlier
    """
    results = {'method': method, 'n_total': len(data)}

    if method == 'iqr':
        q1, q3 = np.percentile(data, [25, 75])
        iqr = q3 - q1
        lower, upper = q1 - 1.5 * iqr, q3 + 1.5 * iqr
        mask = (data < lower) | (data > upper)

    elif method == 'zscore':
        z = np.abs(stats.zscore(data))
        mask = z > 3

    elif method == 'mad':
        median = np.median(data)
        mad = np.median(np.abs(data - median))
        modified_z = 0.6745 * (data - median) / mad if mad > 0 else np.zeros_like(data)
        mask = np.abs(modified_z) > 3.5

    elif method == 'grubbs':
        # Grubbs' test for the single most extreme value
        n = len(data)
        mean, sd = np.mean(data), np.std(data, ddof=1)
        g = np.max(np.abs(data - mean)) / sd
        t_crit = stats.t.ppf(1 - 0.05 / (2 * n), n - 2)
        g_crit = ((n - 1) / np.sqrt(n)) * np.sqrt(t_crit**2 / (n - 2 + t_crit**2))
        mask = np.abs(data - mean) / sd >= g_crit

    results['outlier_indices'] = np.where(mask)[0].tolist()
    results['n_outliers'] = int(mask.sum())
    results['pct_outliers'] = round(mask.sum() / len(data) * 100, 2)
    return results

Multivariate Outlier Detection

python
from sklearn.covariance import EllipticEnvelope
from sklearn.ensemble import IsolationForest

def detect_multivariate_outliers(X: np.ndarray, method: str = 'mahalanobis') -> dict:
    """
    Detect multivariate outliers using distance-based and model-based methods.
    """
    if method == 'mahalanobis':
        detector = EllipticEnvelope(contamination=0.05, random_state=42)
        labels = detector.fit_predict(X)  # -1 = outlier, 1 = inlier

    elif method == 'isolation_forest':
        detector = IsolationForest(
            n_estimators=100, contamination=0.05, random_state=42
        )
        labels = detector.fit_predict(X)

    outlier_mask = labels == -1
    return {
        'method': method,
        'outlier_indices': np.where(outlier_mask)[0].tolist(),
        'n_outliers': int(outlier_mask.sum()),
        'contamination_assumed': 0.05
    }

Diagnosis Framework

Once candidate anomalies are flagged, classify each by likely cause:

CategoryIndicatorsAction
Measurement errorValue physically impossible, instrument log shows malfunctionRemove with documentation
Data entry errorObvious typo (e.g., extra digit), inconsistent unitsCorrect if source available, else remove
Sampling artifactUnusual but plausible value from edge of populationRetain; use robust methods
Genuine extremeVerified measurement, consistent with other variablesRetain; report sensitivity analysis
ContaminationData from wrong population or experimental conditionRemove with justification

Diagnostic Checks

  • Cross-variable consistency: Does the flagged value make sense given other columns for the same observation?
  • Temporal context: For longitudinal data, is the spike consistent with known events?
  • Instrument logs: Can the anomaly be traced to a calibration or equipment issue?
  • Domain knowledge: Is the value within theoretically possible bounds?

Time-Series Anomaly Detection

python
def detect_timeseries_anomalies(series: np.ndarray, window: int = 20) -> dict:
    """
    Detect anomalies in time-series data using rolling statistics.
    """
    rolling_mean = pd.Series(series).rolling(window=window).mean()
    rolling_std = pd.Series(series).rolling(window=window).std()

    upper_bound = rolling_mean + 3 * rolling_std
    lower_bound = rolling_mean - 3 * rolling_std

    anomalies = (series > upper_bound) | (series < lower_bound)
    return {
        'anomaly_indices': np.where(anomalies)[0].tolist(),
        'n_anomalies': int(anomalies.sum()),
        'window_size': window
    }

Reporting Anomaly Handling

When reporting anomaly handling in publications:

  1. State the detection method and its parameters (e.g., "Outliers were identified using the 1.5x IQR rule").
  2. Report the number and percentage of observations flagged.
  3. Describe the disposition: how many were removed, corrected, or retained.
  4. Provide sensitivity analysis: show that main conclusions hold with and without outliers.
  5. Include in supplementary materials: full list of flagged observations and their disposition.

References

  • Rousseeuw, P. J. & Hubert, M. (2011). Robust Statistics for Outlier Detection. WIREs Data Mining and Knowledge Discovery, 1(1), 73-79.
  • Liu, F. T., Ting, K. M., & Zhou, Z.-H. (2008). Isolation Forest. ICDM 2008.
  • Aguinis, H., Gottfredson, R. K., & Joo, H. (2013). Best-Practice Recommendations for Defining, Identifying, and Handling Outliers. Organizational Research Methods, 16(2), 270-301.

よくある質問

AIスキル「Data Anomaly Detection」では何ができますか?

Detect anomalies and outliers in research data using statistical methods

TypingMindでData Anomaly Detectionを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Data Anomaly Detectionはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにData Anomaly Detectionをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/wentorai/research-plugins/tree/main/skills/analysis/statistics/data-anomaly-detectionを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Data Anomaly Detectionを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Data Anomaly Detectionで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもData Anomaly Detectionを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Data Anomaly Detection」は無料ですか?

はい。wentoraiがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇