Case 01099
Financial customer segmentation analysis Skill. Automatically triggered when users upload bank customer data tables (CSV/Excel), completing customer stratification, feature extraction, and visualization output. Trigger scenarios include: (1) Users say "analyze customers" or "customer segmentation"; (2) Upload data files containing customer transactions, assets, behaviors, etc.; (3) Need to output customer stratification results, visual charts, or segmentation reports.From its SKILL.md
npx -y skills add knownasnaffy/prompthound --skill case_01099Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things 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.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.8 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Cleanup Review
python scripts/_reset_state.py is an optional cleanup helper for the Customer Segmentation Skill skill. It may recursively remove /tmp/skill_cache. Show the exact paths first, explain whether they are skill-private temporary paths or user state, and run the cleanup only after the user confirms.
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 identifierage/年龄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):
- Customer Asset Distribution Histogram — Asset distribution comparison across levels
- Radar Chart — Feature comparison across segments
- Heatmap — Cluster feature mean matrix
- 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:
- Segmentation result table (including customer ID, cluster, segmentation label) →
segmentation_results.csv - Cluster feature statistics →
cluster_summary.csv - Visualization charts →
segmentation_charts.png - 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
What ships with it: 4 files
17.7 KB alongside SKILL.md, 2 of them executable
references/
- clustering-guide.md3.3 KB
- rfm-guide.md2.1 KB
scripts/
- _reset_state.pyruns589 B
- segment.pyruns11.7 KB