anomaly_detect
Detect anomalies in time-series data using STL, IQR, or rolling z-score methods. Identifies outliers in date/value columns from CSV, TSV, XLSX, or JSON files.
Instructions
anomaly_detect —— 时序组 · 时序异常检测(工具 20,简化实现)。
docstring = agent 使用说明书,与 statlab_mcp/docs/design/06_timeseries.md 同步维护。
参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) date_col / value_col (str): 日期列与数值列 method (str, "stl"): stl / iqr / rolling_zscore stl: statsmodels STL(robust=True) 残差 |resid| > threshold残差标准差 (std(ddof=1) 判据;MAD_std=1.4826median|resid-median| 对"主体集中+ 稀疏厚尾"残差低估尺度,实现期修订弃用,见 statlab_mcp/docs/design/06) iqr: 一阶差分上 IQR 规则(Q1-1.5IQR / Q3+1.5IQR,同探查组口径), threshold 参数不参与 iqr 判据,索引映射回原行 rolling_zscore: 窗口 7 滚动 mean/std(min_periods=3),|z| > threshold threshold (float, 3.0): >0;仅 stl 与 rolling_zscore 使用
保证: 异常点仅报告不剔除;常数序列(尺度 0)无异常并注明。
示例: anomaly_detect("samples/timeseries.csv", date_col="date", value_col="value") inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | stl | |
| date_col | No | ||
| file_path | No | ||
| threshold | No | ||
| value_col | No | ||
| inline_data | No |