← Back to Skills Marketplace
yukirang

customer-segment-eng

by yukirang · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
93
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install customer-segment-eng
Description
Analyze uploaded bank customer data to segment and profile customers by assets, transactions, and behavior, outputting clusters, statistics, and visual charts.
README (SKILL.md)

Customer Segmentation Skill

Financial customer segmentation analysis: Stratify customers based on assets, transaction behaviors, activity levels, and other dimensions, outputting actionable segmentation results and visualizations.

Workflow

Step 1 — Data Loading and Cleaning

Read user-uploaded CSV or Excel files, automatically identifying column names.

Priority fields to retain:

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

Missing value handling:

  • Numeric: Fill with median
  • Categorical: Fill with mode
  • Columns with >30% missing: Delete and notify user
import pandas as pd

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

Step 2 — Feature Engineering

Build RFM + extended features:

Feature Description
Recency Days since last transaction (smaller = more active)
Frequency Transaction frequency (number of transactions in specified period)
Monetary Transaction amount (total amount in specified period)
Tenure Customer duration (months)
Product_Depth Number of products held
Age Customer age

Data standardization: Use StandardScaler (Z-score) to normalize all numeric features.

Step 3 — Clustering Analysis

Use K-Means algorithm, automatically determine K value (Elbow Method, SSE inflection point).

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

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

# Elbow method to find optimal 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)  # Simply take k with minimum SSE

K=5 can also be fixed based on business needs (high/medium-high/medium/medium-low/low value customers).

Step 4 — Segment Profiling

Output core statistics for each cluster:

Cluster 0 (High-Value Customers): Avg. assets 850k, Avg. transaction frequency 28/month, Gender distribution 62% male
Cluster 1 (Potential Customers): Avg. assets 320k,明显 younger trend
...

Recommended label system (five categories):

  • 🌟 High-Value Customers (VIP)
  • ⬆️ Potential Customers
  • 🟢 Stable Customers
  • 🔄 Active Transaction Customers
  • ⚠️ Dormant/Churn Warning Customers

Step 5 — Visualization

Generate the following charts (saved as PNG):

  1. Customer Asset Distribution Histogram — Asset distribution comparison across levels
  2. Radar Chart — Feature comparison across segments
  3. Heatmap — Cluster feature mean matrix
  4. Scatter Plot — Customer distribution with assets × transaction frequency as coordinates
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))
# Asset distribution
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')
# Heatmap
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 — Output Results

Output content:

  1. Segmentation result table (including customer ID, cluster, segmentation label) → segmentation_results.csv
  2. Cluster feature statistics → cluster_summary.csv
  3. Visualization charts → segmentation_charts.png
  4. Analysis summary (Markdown format) → segmentation_report.md

For detailed clustering and parameter documentation:

  • RFM model explanation: Refer to references/rfm-guide.md
  • Clustering parameter explanation: Refer to references/clustering-guide.md
Usage Guidance
This skill appears coherent and implements customer segmentation as advertised, but it processes sensitive financial and personally identifiable data. Before installing/running: (1) Verify where outputs are written and ensure they stay on trusted storage; (2) Confirm the runtime environment has no network egress or is monitored if data must remain private; (3) Review and test the script on synthetic or anonymized data first (there are minor logic issues such as a simplistic 'optimal_k' selection in the SKILL.md example); (4) Ensure compliance with data protection rules (masking/desensitization, retention policies, and non-discriminatory use); (5) Pin or vet Python package versions you install to avoid dependency supply-chain risks. If those controls are acceptable, the skill is internally consistent with its stated purpose.
Capability Analysis
Type: OpenClaw Skill Name: customer-segment-eng Version: 1.0.0 The skill bundle provides a legitimate customer segmentation tool using K-Means clustering for financial data analysis. The Python script (scripts/segment.py) and instructions (SKILL.md) focus entirely on data processing, feature engineering, and visualization using standard libraries like pandas and scikit-learn, with no evidence of data exfiltration, unauthorized execution, or malicious prompt injection.
Capability Assessment
Purpose & Capability
Name/description match the provided SKILL.md and the included scripts. The Python script implements feature engineering, K-Means clustering, profiling, and chart generation — exactly what the skill says it will do. There are no unrelated environment variables, binaries, or config paths requested.
Instruction Scope
Instructions and code focus on reading user-uploaded CSV/Excel files, cleaning, feature engineering, clustering, and producing CSV/PNG/MD outputs. The skill will therefore handle sensitive bank/customer data (PII/financial). There are no instructions to read other system files, environment variables, or to transmit data externally, but the operator should confirm the runtime environment prevents unintended exfiltration.
Install Mechanism
No install spec is provided (instruction-only plus included script). Nothing is downloaded or extracted; the skill relies on standard Python libraries (pandas, scikit-learn, matplotlib, seaborn) which are expected for this task.
Credentials
The skill requests no credentials, env vars, or config paths. Its resource needs (CPU/memory when clustering large datasets) are proportional to the task. No broad or unrelated secrets are requested.
Persistence & Privilege
always is false and the skill does not request permanent system presence or attempt to modify other skills. It writes output files to a provided output directory (normal for this use case).
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install customer-segment-eng
  3. After installation, invoke the skill by name or use /customer-segment-eng
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Customer Segmentation Skill v1.0.0 - Automatically analyzes financial customer data upon CSV/Excel upload or user request (“analyze customers”, “customer segmentation”). - Performs data cleaning, missing value handling, and feature engineering (RFM model + extended attributes). - Applies K-Means clustering (auto K detection or fixed K=5) to generate customer segments. - Outputs segmentation labels, statistical summaries, and assigns five intuitive customer categories. - Produces key visualizations (histogram, radar chart, heatmap, scatter plot) and exports all results (tables, charts, Markdown reports) for easy sharing. - All major processing steps (cleaning, clustering, profiling, visualization, output) are automated for streamlined analysis.
Metadata
Slug customer-segment-eng
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is customer-segment-eng?

Analyze uploaded bank customer data to segment and profile customers by assets, transactions, and behavior, outputting clusters, statistics, and visual charts. It is an AI Agent Skill for Claude Code / OpenClaw, with 93 downloads so far.

How do I install customer-segment-eng?

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

Is customer-segment-eng free?

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

Which platforms does customer-segment-eng support?

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

Who created customer-segment-eng?

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

💬 Comments