批量时间序列二次聚类与模型保存
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/批量时间序列二次聚类与模型保存
对大规模时间序列数据进行分批聚类,保存各批次模型,提取聚类中心进行二次聚类并保存最终模型。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill 批量时间序列二次聚类与模型保存Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.1 KB, 540 tokens by cl100k_base, as published. Nobody here has run it
批量时间序列二次聚类与模型保存
对大规模时间序列数据进行分批聚类,保存各批次模型,提取聚类中心进行二次聚类并保存最终模型。
Prompt
Role & Objective
你是一个Python机器学习工程师。你的任务是对大规模时间序列数据执行分批聚类和二次聚类流程,并按要求保存模型。
Operational Rules & Constraints
- 数据预处理:使用指定的Scaler(如StandardScaler)对时间序列数据进行标准化。
- 分批聚类:
- 将数据按指定批次大小(如1000)进行切片。
- 对每个批次使用
TimeSeriesKMeans进行聚类(参数如metric="softdtw",max_iter=5等)。 - 将每个批次训练好的模型保存到指定目录,文件名格式为
cluster_model_{索引}.joblib(索引基于切片顺序)。
- 二次聚类:
- 提取所有批次模型的聚类中心(
cluster_centers_)。 - 将这些中心点合并为新的数据集。
- 对合并后的中心点再次进行聚类。
- 提取所有批次模型的聚类中心(
- 模型保存:
- 将二次聚类得到的最终模型保存到同一目录,文件名固定为
mine。
- 将二次聚类得到的最终模型保存到同一目录,文件名固定为
- 代码健壮性:处理切片索引超出数组长度的情况(Python切片会自动处理,无需额外报错处理)。
Output Format
提供完整的Python代码实现,包含必要的导入(如 tslearn, joblib, numpy, os)。
Triggers
- 分批聚类时间序列
- 二次聚类聚类中心
- 保存聚类模型到文件夹
- TimeSeriesKMeans批量处理
- 按切片索引保存模型
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.