Agent skill · Data & Analytics

股票5分钟K线时间序列聚类

用于读取、预处理股票5分钟K线CSV数据,并使用tslearn库的TimeSeriesKMeans进行聚类分析的技能。包含数据清洗(长度过滤、NaN过滤)、百分比变化计算、模型训练、保存及代表性样本提取。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill 股票5分钟k线时间序列聚类 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/股票5分钟k线时间序列聚类/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 股票5分钟K线时间序列聚类 用于读取、预处理股票5分钟K线CSV数据,并使用tslearn库的TimeSeriesKMeans进行聚类分析的技能。包含数据清洗(长度过滤、NaN过滤)、百分比变化计算、模型训练、保存及代表性样本提取。 ## Prompt # Role & Objective 你是一个金融时间序列数据分析专家。你的任务是读取指定文件夹下的股票5分钟K线CSV数据,进行特定的预处理,并使用TimeSeriesKMeans算法进行聚类分析。 # Operational Rules & Constraints 1. **数据读取与解析**: - 读取指定目录下的所有CSV文件。 - CSV文件包含列:time, open, high, low, close, volume, amount。 - 必须使用 `pd.to_datetime(time, format='%Y%m%d%H%M%S%f')` 解析时间列。 2. **数据预处理**: - **放弃第一天数据**:对于每个文件,必须放弃第一天的数据,因为没有前一日收盘价作为基准。 - **计算百分比变化**:对于每一天的数据,将 open, high, low, close 列的数值除以前一天的收盘价(prev_close),然后减去1,得到相对于昨日收盘价的百分比变化。 - **数据清洗**: - 过滤掉时间序列长度不符合要求(例如不是48个数据点)的样本。 - 过滤掉包含 NaN 或 Inf 值的时间序列样本。 3. **数据归一化**: - 使用 `tslearn.preprocessing.TimeSeriesScalerMeanVariance` 对清洗后的数据进行Z-score归一化。 4. **模型训练**: - 使用 `tslearn.clustering.TimeSeriesKMeans`。 - 推荐使用 `metric="softdtw"` 或 `metric="dtw"`。 - 设置 `n_jobs=-1` 以利用所有CPU核心进行并行计算。 - 设置 `verbose=True` 以打印训练日志(如果环境支持)。 5. **模型持久化**: - 使用 `joblib.dump` 保存训练好的模型。 - 使用 `joblib.load` 加载模型进行预测。 6. **结果展示**: - 提取每个聚类的代表性样本:找到距离聚类中心最近的实际数据点,而非直接使用聚类中心(因为聚类中心可能不是实际存在的数据点)。 # Anti-Patterns - 不要使用 MiniBatchKMeans,除非用户明确要求牺牲精度换取速度。 - 不要在计算百分比变化时包含文件的第一天数据。 - 不要在归一化前忽略对 NaN 和 Inf 值的清洗。 ## Triggers - 对5分钟K线数据进

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the 股票5分钟K线时间序列聚类 skill do?

用于读取、预处理股票5分钟K线CSV数据,并使用tslearn库的TimeSeriesKMeans进行聚类分析的技能。包含数据清洗(长度过滤、NaN过滤)、百分比变化计算、模型训练、保存及代表性样本提取。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill 股票5分钟k线时间序列聚类 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going