Skip to content
cccskills
FreePublished on GitHub

bi-adaptive-threshold

通过量化历史数据的自然波动幅度,自适应计算判定阈值。当需要从数据本身确定阈值(如波动阈值、影响度阈值等)、而非使用固定值时调用。仅适用于日/周粒度阈值确定。

The English summary is being prepared. Showing the original description.

See how to install

Files included (2)

  • SKILL.md4.6 KB
  • scripts/adaptive_threshold.py12.8 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

bi-adaptive-threshold

基于标准差衡量数据的自然波动幅度,从数值序列中自适应计算阈值,常见场景:

  • 异常检测:确定指标波动率的异常阈值
  • 影响度判定:确定事件影响度的显著性阈值
  • 其他需要从数据分布中推导合理边界的场景

适用范围:仅适用于日粒度和周粒度的阈值计算。

执行步骤

1:数据准备

包含时间序列数据的 CSV 文件,至少包含以下两列:

列说明示例
日期列时间标识日期
数值列需要计算阈值的目标数值序列访问用户数

示例:

日期,访问用户数
2025-01-01,10000
2025-01-02,10500
2025-01-03,9800

若上游步骤已产出可用数据文件则直接使用,否则自行取数。默认取近 90 天数据,若可用数据不足 90 天则取全部。

2:执行阈值计算

按以下优先级选择计算方式,命中即停:

方式一:使用脚本

路径: scripts/adaptive_threshold.py

原理:

  1. 检查数据量是否充足(即:数据行数 < 最少数据行数),不足则直接返回 默认阈值
  2. 计算变化率序列,用 IQR 围栏法(四分位距 × IQR 倍数)剔除极端异常值
  3. 通过 ruptures 库检测结构性变化点,将数据划分为若干分段
  4. 取最后一段平稳区间:
    • 若最后一段不足 最少数据行数,说明稳定数据不够,可能处于业务初期,返回 默认阈值;
    • 计算该段数据标准差,若标准差 ≥ 阈值上限,说明当前仍处于剧烈波动期,返回 默认阈值
  5. 最终阈值 = 标准差 × 标准差倍数,并限制在 [阈值下限, 阈值上限] 范围内,避免阈值过于敏感或过于迟钝

若脚本适用于当前场景,按以下方式调用:

参数:

参数说明默认值
--input-file输入数据文件路径(必填)
--date-col日期列名(必填)
--metric-col数值列名(必填)
--default-threshold默认阈值,按指标类型区分,详见下方说明(必填)
--min-periods最少数据行数30
--iqr-multiplierIQR 倍数1.5
--std-multiplier标准差倍数3.0
--threshold-min阈值下限0.05
--threshold-max阈值上限0.20
--ruptures-methodruptures 库的变化点检测算法(pelt/binseg/window)pelt
--ruptures-penaltyruptures 库的变化点检测的惩罚系数,值越大分段越少None (自动计算)

--default-threshold 是数据不足或波动剧烈时的兜底值,调用时应根据指标类型传入不同的值:

  • 量值指标:默认 10%(即 --default-threshold 0.10)
  • 率值指标:根据率值所在区间差异化设置:
    • 率值在 [40%, 60%]:±5%(即 --default-threshold 0.05)
    • 率值在 [20%, 40%) 或 (60%, 80%]:±3%(即 --default-threshold 0.03)
    • 率值在 [0%, 20%) 或 (80%, 100%]:±2%(即 --default-threshold 0.02)

调用示例:

python scripts/adaptive_threshold.py \
  --input-file data.csv \
  --date-col "日期" \
  --metric-col "访问用户数"

输出格式:

# 正常
threshold: 0.14

# 数据不足
threshold: 0.10 (数据不足,使用默认阈值)

# 波动剧烈
threshold: 0.10 (波动剧烈,使用默认阈值)

方式二:自行实现

若脚本不适用于当前场景(如数据结构不匹配、场景特殊、用户有自定义需求等),基于上述核心思想自行实现阈值计算。

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

将用户的数据分析需求转化为结构化的分析计划并与用户确认。用户提出 BI 业务分析、数据探索、统计建模等需要规划的分析任务时使用。简单数据查询、公式明确的定量计算等流程简单、无需规划的任务不使用。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

基于阈值检测时间序列中的显著异常波动点。当需要找出指标异常波动日期、识别数据异动时调用。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

计算各维度(组)值对指标变动的贡献度,支持可加型量值指标和加权平均型/率值指标。当需要计算贡献度、解释指标"为什么涨/跌"时调用。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

从运营周报、活动文档、对话输入或文档工具 API 中提取业务事件,与指标异常时间窗口对齐,生成有证据支撑的因果归因假设并排序。当已知指标存在异常波动、需要从外部文档证据中解释"为什么"时调用。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

对用户、产品等业务对象做分群:用波士顿矩阵法做象限分群,或用分层聚类、K-means、DBSCAN 等聚类技术分群。当需要做客群/产品分群、象限策略、画像或密度型子结构发现时调用。触发条件:当对话中出现“分群”、“分类”、“聚类”、“不同类型”、“不同场景”等体现分群分析词语时触发。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

把用户按同一批/同一类分组,比较各群体后续表现。触发条件:对话涉及同期群分析、分群后表现对比、用户生命周期分群跟踪等任务时触发,如出现「同期群」「cohort」「按起始特征分群后表现如何」「不同客群后续转化/留存对比」「注册周/获客渠道分群跟踪」等相似问题时触发。

The English summary is being prepared. Showing the original description.

agentscope-ai/QwenPaw-Data166Updated Oct 20, 2026

See all skills by agentscope-ai

Report a problem with this skill