OpenParable
Skip to content
← Back to skills

Systematic Sampler

Documents
systematic_sampler

Systematic Sampler is an Agent Skill for documents published in the cas-bigdatalab/piflow repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

系统采样算子。按照固定间隔从数据中进行系统采样,适用于时间序列数据或需要均匀分布样本的场景。 当用户提到系统采样、等距抽样、按间隔取样、均匀抽样等需求时使用此skill。 即使用户没有明确说出"系统采样",只要任务涉及从有序数据中按固定步长抽取样本,就应该使用此skill。 不负责分层采样或随机采样。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/systematic_sampler/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/systematic-sampler, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

SystematicSampler - 系统采样算子

功能概述

按照固定间隔从数据中进行系统采样,适用于时间序列数据或需要均匀分布样本的场景。支持指定间隔或根据目标数量自动计算间隔。

触发条件

当用户提到以下任务时,应使用此skill:

  • 系统采样
  • 等距抽样
  • 按间隔取样
  • 均匀抽样

核心参数说明

必需参数

  • --input:输入JSONL文件路径
  • --output:输出JSONL文件路径
  • --method:采样方式,interval 或 count

可选参数

  • --interval:采样间隔,method=interval 时使用
  • --count:目标采样数量,method=count 时使用
  • --start_offset:起始偏移量,默认 0
  • --log_file:日志文件路径

输入文件格式

支持 JSONL,每行一个 JSON 对象。

使用方法

按间隔采样

python scripts/run_systematic_sampler.py \
  --input data.jsonl \
  --output sampled.jsonl \
  --method interval \
  --interval 10 \
  --start_offset 0

按目标数量采样

python scripts/run_systematic_sampler.py \
  --input data.jsonl \
  --output sampled.jsonl \
  --method count \
  --count 1000 \
  --start_offset 5

输出示例

[OK] Systematic sampling completed
   Input: data.jsonl
   Output: sampled.jsonl
   Total records: 12
   Sampling interval: 3
   Start offset: 1
   Sampled records: 4
   Sampling rate: 33.33%

环境要求

  • Python 3.x
  • 标准库即可运行

注意事项

  1. 输入必须是 JSONL 格式。
  2. method=count 会基于目标数量估算间隔,并在需要时截断到目标数量。
  3. start_offset 不能大于数据长度。
  4. 输出记录会追加 _sample_index 和 _sample_interval 标记。