← Back to Skills Marketplace
yukirang

customer-segment

by yukirang · GitHub ↗ · v1.0.2 · MIT-0
cross-platform ✓ Security Clean
170
Downloads
1
Stars
0
Active Installs
3
Versions
Install in OpenClaw
/install customer-segment
Description
金融客户分群分析 Skill。当用户上传银行客户数据表格(CSV/Excel)时自动触发,完成客户分层、特征提取和可视化输出。触发场景包括:(1)用户说"分析客户"或"客户分群";(2)上传了包含客户交易、资产、行为等字段的数据文件;(3)需要输出客户分层结果、可视化图表或分群报告。
README (SKILL.md)

Customer Segmentation Skill

金融客户分群分析:将客户按资产、交易行为、活跃度等维度进行分层,输出可操作的分群结果与可视化。

工作流程

Step 1 — 数据加载与清洗

读取用户上传的 CSV 或 Excel 文件,自动识别列名。

优先保留字段:

  • customer_id / 客户ID — 客户唯一标识
  • age / 年龄
  • gender / 性别
  • balance / 资产余额
  • txn_amount / 交易金额
  • txn_count / 交易次数
  • last_date / 最近交易日期
  • product_count / 持有产品数
  • branch / 网点

缺失值处理:

  • 数值型:用中位数填充
  • 类别型:用众数填充
  • 超过 30% 缺失的列:删除该列并提示用户
import pandas as pd

df = pd.read_csv(file_path)
df.columns = df.columns.str.strip().str.lower()

Step 2 — 特征工程

构建 RFM + 扩展特征:

特征 说明
Recency 距今天数(越小越活跃)
Frequency 交易频率(指定周期内交易次数)
Monetary 交易金额(指定周期内总金额)
Tenure 客户持有时长(月)
Product_Depth 持有产品数量
Age 客户年龄

数据标准化:使用 StandardScaler(Z-score)归一化所有数值型特征。

Step 3 — 聚类分析

使用 K-Means 算法,自动确定 K 值(肘部法则 Elbow Method,SSE 拐点)。

from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
X_scaled = scaler.fit_transform(features)

# 肘部法则找最优K
sse = {}
for k in range(2, 10):
    km = KMeans(n_clusters=k, random_state=42, n_init=10)
    km.fit(X_scaled)
    sse[k] = km.inertia_
optimal_k = min(sse, key=sse.get)  # 简单取SSE最小的k

也可根据业务需求固定 K=5(高/中高/中/中低/低价值客户)。

Step 4 — 分群画像

输出每个簇的核心统计量:

簇 0(高价值客户):平均资产 85万,平均交易频次 28次/月,性别分布男62%
簇 1(潜力客户):平均资产 32万,年轻化趋势明显
...

推荐标签体系(五类):

  • 🌟 高价值客户(VIP)
  • ⬆️ 潜力客户
  • 🟢 稳定客户
  • 🔄 活跃交易客户
  • ⚠️ 沉睡/流失预警客户

Step 5 — 可视化

生成以下图表(保存为 PNG):

  1. 客户资产分布直方图 — 各层级资产分布对比
  2. 雷达图 — 各分群特征对比
  3. 热力图 — 分群特征均值矩阵
  4. 散点图 — 以资产×交易频次为坐标的客户分布
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')
plt.rcParams['font.sans-serif'] = ['WenQuanYi Micro Hei', 'SimHei']

fig, axes = plt.subplots(1, 2, figsize=(14, 5))
# 资产分布
axes[0].hist([g['balance'] for _, g in df.groupby('cluster')], bins=30, label=[f'C{i}' for i in range(k)])
axes[0].set_title('Customer Balance Distribution by Cluster')
# 热力图
import seaborn as sns
sns.heatmap(cluster_means.T, annot=True, fmt='.1f', ax=axes[1])
axes[1].set_title('Cluster Feature Heatmap')
plt.tight_layout()
plt.savefig(output_path, dpi=150)

Step 6 — 输出结果

输出内容:

  1. 分群结果表(含客户ID、所属簇、分群标签)→ segmentation_results.csv
  2. 分群特征统计 → cluster_summary.csv
  3. 可视化图表 → segmentation_charts.png
  4. 分析摘要(Markdown格式)→ segmentation_report.md

详细聚类和参数文档见:

  • RFM 模型说明:参考 references/rfm-guide.md
  • 聚类参数说明:参考 references/clustering-guide.md
Usage Guidance
This skill appears to do what it claims: local customer segmentation and charts. Before installing/running it: (1) review the script (scripts/segment.py) yourself — it will read and write files including customer IDs; (2) ensure the runtime has required Python packages (pandas, numpy, scikit-learn, matplotlib, seaborn); (3) confirm Excel support if you expect .xlsx inputs (script currently uses read_csv); (4) enforce privacy/compliance: consider removing or hashing PII (customer_id) or running in a controlled environment, and secure the output directory; (5) if you want to avoid automatic execution on uploads, adjust agent trigger rules or require explicit user confirmation. If you want, I can list the exact python package versions to install or point out the exact lines that write PII to outputs.
Capability Analysis
Type: OpenClaw Skill Name: customer-segment Version: 1.0.2 The skill bundle is a legitimate tool for financial customer segmentation using K-Means clustering. The Python script (scripts/segment.py) and instructions (SKILL.md) focus entirely on data processing, feature engineering, and visualization of user-provided datasets. No evidence of data exfiltration, unauthorized execution, or malicious intent was found.
Capability Assessment
Purpose & Capability
Name/description (customer segmentation) match the included SKILL.md, references, and the Python script which implements RFM feature engineering, K-Means clustering, labeling and chart/report output. There are no environment variables, binaries, or network endpoints requested that are unrelated to the stated purpose.
Instruction Scope
Instructions and script operate on uploaded CSV/Excel customer data and produce CSV/PNG/MD outputs (expected). Two points to note: (1) the script primarily reads CSV (pd.read_csv) while SKILL.md promises CSV/Excel support — Excel (.xlsx) handling is not implemented unless the agent wraps read_excel separately; (2) the skill processes sensitive banking data and does not enforce or automate de-identification or access controls — output files include customer IDs and raw metrics, so users should ensure privacy/compliance and secure storage/retention.
Install Mechanism
No install spec (instruction-only skill) — lowest install risk. However, the included Python script requires common data-science packages (pandas, numpy, scikit-learn, matplotlib, seaborn). The skill does not declare or install these dependencies; the runtime environment must provide them. No network downloads or unusual install actions are present.
Credentials
The skill requests no environment variables, credentials, or config paths — appropriate for an offline data-processing task. There are no apparent attempts to access unrelated secrets or systems.
Persistence & Privilege
always is false and the skill is user-invocable (normal). The SKILL.md describes automatic triggering when a user uploads a customer data file — combined with the agent's ability to autonomously invoke skills, this can cause automatic execution on user-provided sensitive data. This is expected behavior for a file-processing skill but worth confirming in your deployment policy.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install customer-segment
  3. After installation, invoke the skill by name or use /customer-segment
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.2
- 修正英文描述细节,使 Skill 简介更为简明,聚焦于“金融客户分群分析”。 - 其余功能、流程、输出内容均保持一致,无实际功能更新或文件变更。
v1.0.1
- Skill描述由“银行客户分群分析”更新为更广义的“金融客户分群分析”。 - 其余流程与功能无变化,仅文档描述中“银行客户”调整为“金融客户”以覆盖更广泛的应用场景。
v1.0.0
- Initial release of the customer segmentation skill for banking customers. - Automatically analyzes uploaded customer data (CSV/Excel): clustering, feature extraction, and visualization. - Supports triggers: user requests for customer analysis, or relevant file uploads. - Performs data cleaning, feature engineering (RFM +扩展特征), and K-Means clustering with automatic or fixed K. - Outputs: segmented customer table, cluster statistics, visualization charts, and summary report.
Metadata
Slug customer-segment
Version 1.0.2
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 3
Frequently Asked Questions

What is customer-segment?

金融客户分群分析 Skill。当用户上传银行客户数据表格(CSV/Excel)时自动触发,完成客户分层、特征提取和可视化输出。触发场景包括:(1)用户说"分析客户"或"客户分群";(2)上传了包含客户交易、资产、行为等字段的数据文件;(3)需要输出客户分层结果、可视化图表或分群报告。 It is an AI Agent Skill for Claude Code / OpenClaw, with 170 downloads so far.

How do I install customer-segment?

Run "/install customer-segment" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is customer-segment free?

Yes, customer-segment is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does customer-segment support?

customer-segment is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created customer-segment?

It is built and maintained by yukirang (@yukirang); the current version is v1.0.2.

💬 Comments