xiaohongshu
xiaohongshu
ltv-predictor
基于RFM模型和回归算法的客户生命周期价值(LTV)预测分析工具,支持电商和零售业务的客户价值预测。使用时需要客户交易数据、订单历史或消费记录,自动进行RFM特征工程、回归建模和价值预测。
Full skill instructions
一个基于《数据分析咖哥十话》第3课理论的自动化LTV预测分析工具,提供从RFM特征工程到回归建模的完整解决方案。
# 安装基础依赖
pip install pandas numpy scikit-learn matplotlib seaborn
# 安装可选依赖(用于高级功能)
pip install xgboost lightgbm joblib openpyxl
from scripts.ltv_predictor import LTVPredictor
from scripts.data_processor import DataProcessor
# 1. 初始化处理器
processor = DataProcessor()
predictor = LTVPredictor()
# 2. 加载和预处理数据
data = processor.load_order_data('your_orders.csv')
rfm_data = processor.calculate_rfm_features(data,
feature_period='3M',
prediction_period='12M')
# 3. 训练LTV预测模型
model_results = predictor.train_models(rfm_data)
# 4. 进行LTV预测
predictions = predictor.predict_ltv(new_customer_data)
# 5. 生成分析报告
report_path = predictor.generate_report(predictions, 'ltv_analysis_report.html')
from scripts.quick_analysis import quick_ltv_analysis
# 一键完成完整LTV分析流程
results = quick_ltv_analysis(
order_data_path='ecommerce_orders.csv',
feature_period_months=3,
prediction_period_months=12,
output_dir='ltv_analysis_results'
)
print(f"最佳模型R²分数: {results['best_model_r2']:.4f}")
print(f"预测客户数: {len(results['predictions'])}")
print(f"分析报告: {results['report_path']}")
ltv-predictor/
├── scripts/ # 核心功能模块
│ ├── data_processor.py # 数据预处理和RFM计算
│ ├── ltv_predictor.py # LTV预测核心引擎
│ ├── regression_models.py # 回归算法实现
│ ├── visualizer.py # 可视化生成器
│ └── report_generator.py # 报告生成器
├── examples/ # 示例脚本
│ ├── ecommerce_ltv_analysis.py # 电商完整分析示例
│ ├── quick_ltv_prediction.py # 快速预测示例
│ └── model_comparison.py # 模型对比示例
├── data/ # 示例数据
│ └── sample_orders.csv # 示例订单数据
├── tests/ # 测试脚本
│ ├── test_rfm_analysis.py # RFM分析测试
│ └── test_prediction.py # 预测功能测试
├── SKILL.md # 技能说明文档
└── README.md # 使用说明
config = {
'feature_period_months': 3, # 特征计算时间窗口(月)
'prediction_period_months': 12, # 预测时间窗口(月)
'r_weight': 0.2, # R值权重
'f_weight': 0.3, # F值权重
'm_weight': 0.5, # M值权重
'customer_segments': 5 # 客户分层数量
}
config = {
'test_size': 0.2, # 测试集比例
'cv_folds': 5, # 交叉验证折数
'random_state': 42, # 随机种子
'enable_hyperparameter_tuning': True, # 是否调参
'n_iter_search': 50, # 超参数搜索次数
'scoring_metric': 'r2' # 评估指标
}
config = {
'confidence_interval': 0.95, # 置信区间
'batch_size': 1000, # 批处理大小
'feature_importance_threshold': 0.01, # 特征重要性阈值
'prediction_uncertainty': True # 是否计算预测不确定性
}
订单号,产品码,消费日期,产品说明,数量,单价,用户码,城市
536374,21258,2022-06-01 09:09,绿联usb分线器,32,10.95,15100,北京
536376,22114,2022-06-01 09:32,加大男装T恤,48,50.45,15291,上海
必需字段:
用户码: 客户唯一标识消费日期: 购买时间(支持多种日期格式)数量: 购买数量单价: 商品单价可选字段:
订单号: 订单唯一标识产品码: 商品标识产品说明: 商品描述城市: 客户城市信息基于第3课实测数据:
欢迎贡献代码、报告问题或提出改进建议:
本项目采用 MIT 许可证。
通过这个技能,您可以: ✅ 快速进行客户RFM分析 ✅ 构建准确的LTV预测模型 ✅ 获得可解释的业务洞察 ✅ 生成专业的分析报告 ✅ 支持数据驱动的业务决策
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience