[关闭]
@hhlf282 2026-03-20T01:03:04.000000Z 字数 14635 阅读 13

AI 选品模型设计文档

目标: 设计 AI 选品决策模型,评估商品潜力
版本: 1.0
创建时间: 2026-03-19


1. 模型架构

1.1 整体架构

  1. ┌─────────────────────────────────────────────────────────────┐
  2. 输入层
  3. 商品特征 + 市场数据 + 供应链数据 + 历史表现
  4. └─────────────────────────────────────────────────────────────┘
  5. ┌─────────────────────────────────────────────────────────────┐
  6. 特征工程层
  7. - 数值特征标准化
  8. - 类别特征编码
  9. - 时间特征提取
  10. - 交叉特征构造
  11. └─────────────────────────────────────────────────────────────┘
  12. ┌─────────────────────────────────────────────────────────────┐
  13. 模型层
  14. ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
  15. 销量预测模型 利润预测模型 风险评估模型
  16. (回归) (回归) (分类)
  17. └─────────────┘ └─────────────┘ └─────────────┘
  18. ┌─────────────┐ ┌─────────────┐
  19. 竞争度模型 综合评分模型
  20. (回归) (排序)
  21. └─────────────┘ └─────────────┘
  22. └─────────────────────────────────────────────────────────────┘
  23. ┌─────────────────────────────────────────────────────────────┐
  24. 输出层
  25. 选品推荐列表 + 评分 + 理由 + 风险提示
  26. └─────────────────────────────────────────────────────────────┘

1.2 技术选型

模型 算法 理由
销量预测 XGBoost / LightGBM 处理表格数据强、可解释性好
利润预测 Linear Regression + XGBoost 简单 + 非线性组合
风险评估 Random Forest / XGBoost 分类问题、鲁棒性好
竞争度评估 Clustering + Rule-based 无监督 + 规则
综合评分 Learning to Rank (LambdaMART) 排序问题最优
决策解释 LLM (Qwen3.5-Plus) 自然语言生成

2. 特征工程

2.1 特征列表

商品基础特征

特征名 类型 说明 来源
price numeric 商品价格 (LKR) Daraz
original_price numeric 原价 Daraz
discount_rate numeric 折扣比例 计算
category_id categorical 类目 ID Daraz
brand categorical 品牌 Daraz
rating numeric 评分 (0-5) Daraz
review_count numeric 评价数量 Daraz
sold_count numeric 销量 Daraz
image_count numeric 图片数量 Daraz
description_length numeric 描述长度 Daraz

市场特征

特征名 类型 说明 来源
category_avg_price numeric 类目平均价格 计算
category_avg_sales numeric 类目平均销量 计算
category_growth_rate numeric 类目增长率 计算
search_volume numeric 搜索量 Google Trends
search_trend numeric 搜索趋势 (7 天) Google Trends
seasonality_score numeric 季节性评分 计算

竞争特征

特征名 类型 说明 来源
seller_count numeric 卖家数量 计算
top3_concentration numeric 头部 3 家集中度 计算
price_variance numeric 价格方差 计算
avg_rating numeric 类目平均评分 计算
entry_barrier numeric 进入门槛 (1-10) 规则计算

供应链特征

特征名 类型 说明 来源
source_price numeric 1688 采购价 (RMB) 1688 API
shipping_cost numeric 物流成本 (LKR) 物流 API
lead_time numeric 供货周期 (天) 1688 API
moq numeric 最小起订量 1688 API
supplier_rating numeric 供应商评分 1688 API

利润特征

特征名 类型 说明 来源
gross_margin numeric 毛利率 计算
roi numeric 投资回报率 计算
break_even_sales numeric 盈亏平衡销量 计算
commission_rate numeric 平台佣金率 Daraz
estimated_profit numeric 预计利润 计算

风险特征

特征名 类型 说明 来源
policy_risk numeric 政策风险 (1-10) 规则计算
quality_risk numeric 质量风险 (1-10) 规则计算
supply_risk numeric 供应风险 (1-10) 规则计算
market_risk numeric 市场风险 (1-10) 规则计算

2.2 特征处理

  1. # 特征处理 pipeline
  2. from sklearn.preprocessing import StandardScaler, LabelEncoder
  3. from sklearn.impute import SimpleImputer
  4. import pandas as pd
  5. class FeatureProcessor:
  6. def __init__(self):
  7. self.scaler = StandardScaler()
  8. self.label_encoders = {}
  9. self.imputer = SimpleImputer(strategy='median')
  10. def fit_transform(self, df):
  11. # 1. 处理缺失值
  12. numeric_cols = df.select_dtypes(include=['float64', 'int64']).columns
  13. df[numeric_cols] = self.imputer.fit_transform(df[numeric_cols])
  14. # 2. 标准化数值特征
  15. df[numeric_cols] = self.scaler.fit_transform(df[numeric_cols])
  16. # 3. 编码类别特征
  17. categorical_cols = ['category_id', 'brand']
  18. for col in categorical_cols:
  19. if col in df.columns:
  20. le = LabelEncoder()
  21. df[col] = le.fit_transform(df[col].astype(str))
  22. self.label_encoders[col] = le
  23. # 4. 构造交叉特征
  24. df['price_to_avg_ratio'] = df['price'] / df['category_avg_price']
  25. df['sales_to_avg_ratio'] = df['sold_count'] / df['category_avg_sales']
  26. df['rating_diff'] = df['rating'] - df['avg_rating']
  27. return df

3. 模型设计

3.1 销量预测模型

  1. # 销量预测模型
  2. import xgboost as xgb
  3. from sklearn.model_selection import train_test_split
  4. from sklearn.metrics import mean_absolute_error, mean_squared_error
  5. class SalesPredictor:
  6. def __init__(self):
  7. self.model = xgb.XGBRegressor(
  8. n_estimators=500,
  9. max_depth=6,
  10. learning_rate=0.05,
  11. subsample=0.8,
  12. colsample_bytree=0.8,
  13. random_state=42
  14. )
  15. def train(self, X, y):
  16. """
  17. X: 特征矩阵
  18. y: 实际销量 (月销量)
  19. """
  20. X_train, X_test, y_train, y_test = train_test_split(
  21. X, y, test_size=0.2, random_state=42
  22. )
  23. self.model.fit(X_train, y_train)
  24. # 评估
  25. y_pred = self.model.predict(X_test)
  26. mae = mean_absolute_error(y_test, y_pred)
  27. rmse = mean_squared_error(y_test, y_pred, squared=False)
  28. print(f"MAE: {mae:.2f}, RMSE: {rmse:.2f}")
  29. # 特征重要性
  30. importance = pd.DataFrame({
  31. 'feature': X.columns,
  32. 'importance': self.model.feature_importances_
  33. }).sort_values('importance', ascending=False)
  34. return importance
  35. def predict(self, X):
  36. """预测销量"""
  37. return self.model.predict(X)
  38. def predict_with_confidence(self, X):
  39. """预测销量 + 置信区间"""
  40. predictions = self.model.predict(X)
  41. # 简单置信区间计算 (实际可用分位数回归)
  42. std = np.std(predictions)
  43. lower = predictions - 1.96 * std
  44. upper = predictions + 1.96 * std
  45. return {
  46. 'prediction': predictions,
  47. 'lower_95': lower,
  48. 'upper_95': upper
  49. }

训练数据要求:
- 样本量:>10,000 个商品
- 时间跨度:>6 个月
- 特征:上述 30+ 个特征
- 标签:实际月销量

评估指标:
- MAE < 30 (平均绝对误差 < 30 单)
- RMSE < 50
- R² > 0.6


3.2 利润预测模型

  1. # 利润预测模型
  2. class ProfitPredictor:
  3. def __init__(self):
  4. self.model = xgb.XGBRegressor(
  5. n_estimators=300,
  6. max_depth=4,
  7. learning_rate=0.1,
  8. random_state=42
  9. )
  10. def calculate_features(self, product_data):
  11. """
  12. 计算利润相关特征
  13. """
  14. # 收入
  15. revenue = product_data['price']
  16. # 成本
  17. source_price_lkr = product_data['source_price'] * 60 # RMB 转 LKR (假设汇率 60)
  18. shipping = product_data['shipping_cost']
  19. commission = revenue * product_data['commission_rate']
  20. # 总成本
  21. total_cost = source_price_lkr + shipping + commission
  22. # 毛利率
  23. gross_margin = (revenue - total_cost) / revenue
  24. # ROI
  25. roi = (revenue - total_cost) / total_cost
  26. return {
  27. 'gross_margin': gross_margin,
  28. 'roi': roi,
  29. 'total_cost': total_cost,
  30. 'profit_per_unit': revenue - total_cost
  31. }
  32. def train(self, X, y):
  33. """
  34. X: 特征矩阵
  35. y: 实际毛利率
  36. """
  37. self.model.fit(X, y)
  38. def predict(self, X):
  39. """预测毛利率"""
  40. return self.model.predict(X)

利润计算公式:

  1. 毛利率 = (售价 - 采购价 - 物流 - 佣金) / 售价
  2. ROI = (售价 - 采购价 - 物流 - 佣金) / (采购价 + 物流)
  3. 盈亏平衡销量 = 固定成本 / (售价 - 变动成本)

3.3 风险评估模型

  1. # 风险评估模型 (二分类:高风险/低风险)
  2. class RiskClassifier:
  3. def __init__(self):
  4. self.model = xgb.XGBClassifier(
  5. n_estimators=300,
  6. max_depth=5,
  7. learning_rate=0.1,
  8. scale_pos_weight=5, # 处理样本不平衡
  9. random_state=42
  10. )
  11. def train(self, X, y):
  12. """
  13. X: 特征矩阵
  14. y: 风险标签 (0=低风险,1=高风险)
  15. """
  16. self.model.fit(X, y)
  17. def predict(self, X):
  18. """预测风险等级"""
  19. return self.model.predict(X)
  20. def predict_proba(self, X):
  21. """预测风险概率"""
  22. return self.model.predict_proba(X)[:, 1] # 高风险概率
  23. def get_risk_factors(self, X):
  24. """
  25. 获取主要风险因素
  26. """
  27. # 基于特征重要性分析
  28. importance = pd.DataFrame({
  29. 'feature': X.columns,
  30. 'importance': self.model.feature_importances_
  31. }).sort_values('importance', ascending=False)
  32. # 返回 TOP 5 风险因素
  33. return importance.head(5)

风险标签定义:

  1. def label_risk(product_data):
  2. """
  3. 标注风险标签
  4. """
  5. risk_score = 0
  6. # 政策风险
  7. if product_data['category'] in ['药品', '食品', '化妆品']:
  8. risk_score += 3 # 需要认证
  9. # 市场风险
  10. if product_data['competition_score'] > 8:
  11. risk_score += 2 # 竞争激烈
  12. # 供应风险
  13. if product_data['lead_time'] > 30:
  14. risk_score += 2 # 供货周期长
  15. # 质量风险
  16. if product_data['supplier_rating'] < 4.0:
  17. risk_score += 2 # 供应商评分低
  18. # 价格风险
  19. if product_data['price_variance'] > 0.5:
  20. risk_score += 1 # 价格波动大
  21. # 高风险阈值
  22. return 1 if risk_score >= 5 else 0

3.4 竞争度评估模型

  1. # 竞争度评估 (无监督 + 规则)
  2. class CompetitionAnalyzer:
  3. def __init__(self):
  4. pass
  5. def calculate_competition_score(self, category_data):
  6. """
  7. 计算竞争度评分 (1-10 分)
  8. """
  9. score = 0
  10. # 1. 卖家数量 (0-3 分)
  11. seller_count = category_data['seller_count']
  12. if seller_count < 50:
  13. score += 1
  14. elif seller_count < 200:
  15. score += 2
  16. else:
  17. score += 3
  18. # 2. 头部集中度 (0-3 分)
  19. top3_concentration = category_data['top3_concentration']
  20. if top3_concentration < 0.3:
  21. score += 1 # 分散,好进入
  22. elif top3_concentration < 0.6:
  23. score += 2
  24. else:
  25. score += 3 # 集中,难进入
  26. # 3. 价格战程度 (0-2 分)
  27. price_variance = category_data['price_variance']
  28. if price_variance < 0.2:
  29. score += 2 # 价格稳定
  30. elif price_variance < 0.4:
  31. score += 1
  32. else:
  33. score += 0 # 价格战激烈
  34. # 4. 进入门槛 (0-2 分)
  35. entry_barrier = category_data['entry_barrier']
  36. score += (10 - entry_barrier) / 5 # 门槛越低分越高
  37. return min(10, max(1, score))
  38. def get_competition_level(self, score):
  39. """
  40. 将分数转换为竞争等级
  41. """
  42. if score <= 3:
  43. return "低竞争 (蓝海)"
  44. elif score <= 6:
  45. return "中等竞争"
  46. else:
  47. return "高竞争 (红海)"

3.5 综合评分模型

  1. # 综合评分模型 (Learning to Rank)
  2. from sklearn.ensemble import GradientBoostingRegressor
  3. class ProductRanker:
  4. def __init__(self):
  5. self.model = GradientBoostingRegressor(
  6. n_estimators=200,
  7. max_depth=5,
  8. learning_rate=0.1,
  9. random_state=42
  10. )
  11. # 权重配置
  12. self.weights = {
  13. 'market_demand': 0.30, # 市场需求 30%
  14. 'profitability': 0.25, # 利润空间 25%
  15. 'competition': 0.20, # 竞争程度 20%
  16. 'supply_chain': 0.15, # 供应链 15%
  17. 'risk': 0.10 # 风险 10%
  18. }
  19. def calculate_subscores(self, product_features):
  20. """
  21. 计算各维度子分数
  22. """
  23. scores = {}
  24. # 市场需求分数 (基于销量预测)
  25. predicted_sales = self.sales_model.predict([product_features])[0]
  26. scores['market_demand'] = min(10, predicted_sales / 100) # 100 单=10 分
  27. # 利润分数 (基于毛利率)
  28. gross_margin = product_features['gross_margin']
  29. scores['profitability'] = min(10, gross_margin * 20) # 50% 毛利=10 分
  30. # 竞争分数 (反向,竞争越低分越高)
  31. competition_score = product_features['competition_score']
  32. scores['competition'] = 10 - competition_score
  33. # 供应链分数
  34. supplier_rating = product_features['supplier_rating']
  35. lead_time = product_features['lead_time']
  36. scores['supply_chain'] = (supplier_rating / 5) * 7 + (30 / lead_time) * 3
  37. # 风险分数 (反向,风险越低分越高)
  38. risk_prob = self.risk_model.predict_proba([product_features])[0][1]
  39. scores['risk'] = 10 * (1 - risk_prob)
  40. return scores
  41. def calculate_total_score(self, product_features):
  42. """
  43. 计算综合评分
  44. """
  45. subscores = self.calculate_subscores(product_features)
  46. total_score = sum(
  47. subscores[k] * self.weights[k]
  48. for k in self.weights
  49. )
  50. return {
  51. 'total_score': total_score,
  52. 'subscores': subscores,
  53. 'recommendation': self.get_recommendation(total_score)
  54. }
  55. def get_recommendation(self, score):
  56. """
  57. 根据分数给出推荐
  58. """
  59. if score >= 8:
  60. return "强烈推荐"
  61. elif score >= 6:
  62. return "推荐"
  63. elif score >= 4:
  64. return "谨慎考虑"
  65. else:
  66. return "不推荐"
  67. def rank_products(self, products):
  68. """
  69. 对多个商品进行排序
  70. """
  71. scored_products = []
  72. for product in products:
  73. result = self.calculate_total_score(product)
  74. result['product'] = product
  75. scored_products.append(result)
  76. # 按综合评分排序
  77. scored_products.sort(key=lambda x: x['total_score'], reverse=True)
  78. return scored_products

4. LLM 决策解释

4.1 解释生成 Prompt

  1. # 使用 LLM 生成选品建议解释
  2. def generate_recommendation_explanation(product_data, scores):
  3. """
  4. 生成自然语言的选品建议
  5. """
  6. prompt = f"""
  7. 你是一位跨境电商选品专家。请根据以下数据,生成选品建议。
  8. 【商品信息】
  9. - 商品:{product_data['title']}
  10. - 类目:{product_data['category_name']}
  11. - 价格:{product_data['price']} LKR
  12. - 采购价:{product_data['source_price']} RMB
  13. 【评估结果】
  14. - 综合评分:{scores['total_score']:.1f}/10
  15. - 市场需求:{scores['subscores']['market_demand']:.1f}/10
  16. - 利润空间:{scores['subscores']['profitability']:.1f}/10
  17. - 竞争程度:{scores['subscores']['competition']:.1f}/10 (分数越低竞争越激烈)
  18. - 供应链:{scores['subscores']['supply_chain']:.1f}/10
  19. - 风险:{scores['subscores']['risk']:.1f}/10 (分数越高风险越低)
  20. 【推荐等级】{scores['recommendation']}
  21. 请生成:
  22. 1. 推荐理由 (2-3 条,基于数据)
  23. 2. 风险提示 (1-2 条)
  24. 3. 运营建议 (1-2 条)
  25. 要求:
  26. - 简洁明了,每条不超过 50 字
  27. - 基于数据,不空洞
  28. - 语气专业但易懂
  29. """
  30. # 调用 LLM
  31. response = llm_client.generate(prompt)
  32. return response

4.2 输出示例

  1. 【选品建议】无线蓝牙耳机
  2. 推荐理由:
  3. 1. 搜索量月增长 25%,市场需求旺盛
  4. 2. 毛利率 35%,高于类目平均 (25%)
  5. 3. 头部集中度低,新卖家有机会
  6. ⚠️ 风险提示:
  7. 1. 竞争度中等 (6.5/10),需注意差异化
  8. 2. 电子产品质量风险,建议先小批量测试
  9. 💡 运营建议:
  10. 1. 建议首单备货 200 件,测试市场反应
  11. 2. 重点突出"长续航"差异化卖点
  12. 3. 11 月旺季前上架,抓住购物季

5. 模型训练流程

5.1 数据准备

  1. # 数据准备 pipeline
  2. def prepare_training_data():
  3. """
  4. 准备训练数据
  5. """
  6. # 1. 从数据库加载数据
  7. query = """
  8. SELECT
  9. p.*,
  10. ph.avg_price as category_avg_price,
  11. ph.avg_sales as category_avg_sales,
  12. ph.seller_count,
  13. s.source_price,
  14. s.shipping_cost,
  15. s.lead_time,
  16. s.supplier_rating
  17. FROM products p
  18. LEFT JOIN category_stats ph ON p.category_id = ph.category_id
  19. LEFT JOIN supplier_data s ON p.source_url = s.url
  20. WHERE p.crawl_time > NOW() - INTERVAL '12 months'
  21. """
  22. df = pd.read_sql(query, db_connection)
  23. # 2. 特征工程
  24. processor = FeatureProcessor()
  25. df_processed = processor.fit_transform(df)
  26. # 3. 标签生成
  27. df_processed['sales_label'] = df_processed['sold_count'] # 销量标签
  28. df_processed['profit_label'] = df_processed['gross_margin'] # 利润标签
  29. df_processed['risk_label'] = df_processed.apply(label_risk, axis=1) # 风险标签
  30. # 4. 划分训练集/测试集
  31. train_df = df_processed[df_processed['crawl_time'] < '2025-12-01']
  32. test_df = df_processed[df_processed['crawl_time'] >= '2025-12-01']
  33. return train_df, test_df

5.2 训练流程

  1. # 完整训练流程
  2. def train_all_models():
  3. """
  4. 训练所有模型
  5. """
  6. # 1. 准备数据
  7. train_df, test_df = prepare_training_data()
  8. # 2. 定义特征列
  9. feature_cols = [
  10. 'price', 'discount_rate', 'rating', 'review_count',
  11. 'category_avg_price', 'category_avg_sales',
  12. 'seller_count', 'top3_concentration',
  13. 'source_price', 'shipping_cost', 'lead_time', 'supplier_rating',
  14. 'gross_margin', 'roi'
  15. ]
  16. X_train = train_df[feature_cols]
  17. X_test = test_df[feature_cols]
  18. # 3. 训练销量预测模型
  19. print("训练销量预测模型...")
  20. sales_model = SalesPredictor()
  21. sales_importance = sales_model.train(X_train, train_df['sales_label'])
  22. # 4. 训练利润预测模型
  23. print("训练利润预测模型...")
  24. profit_model = ProfitPredictor()
  25. profit_model.train(X_train, train_df['profit_label'])
  26. # 5. 训练风险分类模型
  27. print("训练风险分类模型...")
  28. risk_model = RiskClassifier()
  29. risk_model.train(X_train, train_df['risk_label'])
  30. # 6. 评估
  31. print("\n=== 模型评估 ===")
  32. # 销量预测评估
  33. sales_pred = sales_model.predict(X_test)
  34. sales_mae = mean_absolute_error(test_df['sales_label'], sales_pred)
  35. print(f"销量预测 MAE: {sales_mae:.2f}")
  36. # 利润预测评估
  37. profit_pred = profit_model.predict(X_test)
  38. profit_mae = mean_absolute_error(test_df['profit_label'], profit_pred)
  39. print(f"利润预测 MAE: {profit_mae:.2f}")
  40. # 风险评估评估
  41. risk_pred = risk_model.predict(X_test)
  42. risk_accuracy = accuracy_score(test_df['risk_label'], risk_pred)
  43. print(f"风险评估准确率:{risk_accuracy:.2%}")
  44. # 7. 保存模型
  45. print("\n保存模型...")
  46. joblib.dump(sales_model, 'models/sales_model.pkl')
  47. joblib.dump(profit_model, 'models/profit_model.pkl')
  48. joblib.dump(risk_model, 'models/risk_model.pkl')
  49. return {
  50. 'sales_model': sales_model,
  51. 'profit_model': profit_model,
  52. 'risk_model': risk_model,
  53. 'metrics': {
  54. 'sales_mae': sales_mae,
  55. 'profit_mae': profit_mae,
  56. 'risk_accuracy': risk_accuracy
  57. }
  58. }

6. 模型部署

6.1 API 服务

  1. # FastAPI 服务
  2. from fastapi import FastAPI
  3. from pydantic import BaseModel
  4. app = FastAPI()
  5. class ProductInput(BaseModel):
  6. title: str
  7. price: float
  8. category_id: str
  9. source_url: str
  10. # ... 其他字段
  11. class ProductRecommendation(BaseModel):
  12. product_id: str
  13. total_score: float
  14. recommendation: str
  15. reasons: list[str]
  16. risks: list[str]
  17. suggestions: list[str]
  18. @app.post("/api/v1/evaluate")
  19. async def evaluate_product(product: ProductInput) -> ProductRecommendation:
  20. """
  21. 评估单个商品
  22. """
  23. # 1. 获取特征
  24. features = get_product_features(product)
  25. # 2. 计算评分
  26. ranker = ProductRanker()
  27. result = ranker.calculate_total_score(features)
  28. # 3. 生成解释
  29. explanation = generate_recommendation_explanation(features, result)
  30. return ProductRecommendation(
  31. product_id=product.title,
  32. total_score=result['total_score'],
  33. recommendation=result['recommendation'],
  34. reasons=explanation['reasons'],
  35. risks=explanation['risks'],
  36. suggestions=explanation['suggestions']
  37. )
  38. @app.get("/api/v1/recommendations")
  39. async def get_recommendations(
  40. category: str = None,
  41. price_min: float = None,
  42. price_max: float = None,
  43. limit: int = 20
  44. ) -> list[ProductRecommendation]:
  45. """
  46. 获取选品推荐列表
  47. """
  48. # 1. 从数据库获取候选商品
  49. candidates = get_candidate_products(category, price_min, price_max, limit)
  50. # 2. 批量评分
  51. ranker = ProductRanker()
  52. scored = ranker.rank_products(candidates)
  53. # 3. 返回 TOP N
  54. return [
  55. ProductRecommendation(
  56. product_id=s['product']['item_id'],
  57. total_score=s['total_score'],
  58. recommendation=s['recommendation'],
  59. # ...
  60. )
  61. for s in scored[:limit]
  62. ]

6.2 模型更新

  1. # 模型定期更新
  2. from apscheduler.schedulers.background import BackgroundScheduler
  3. scheduler = BackgroundScheduler()
  4. @scheduler.scheduled_job('cron', day_of_week='mon', hour=2)
  5. def weekly_model_update():
  6. """
  7. 每周更新模型
  8. """
  9. print("开始每周模型更新...")
  10. # 1. 获取新数据
  11. new_data = get_new_training_data()
  12. # 2. 增量训练
  13. models = load_models()
  14. models = incremental_train(models, new_data)
  15. # 3. 评估
  16. metrics = evaluate_models(models)
  17. # 4. 如果效果提升,保存新模型
  18. if metrics['improvement'] > 0.05: # 提升 5% 以上
  19. save_models(models)
  20. print("模型更新成功")
  21. else:
  22. print("模型效果未提升,跳过更新")
  23. scheduler.start()

7. 评估与监控

7.1 离线评估

模型 指标 目标值 当前值
销量预测 MAE <30 -
销量预测
0.6
-
利润预测 MAE <15% -
风险评估 Accuracy
85%
-
风险评估 Recall
80%
-

7.2 在线评估

指标 定义 目标值
推荐采纳率 运营采纳 AI 推荐的比例
60%
选品成功率 AI 推荐产品成功 (月销>100) 比例
50%
平均毛利率 AI 推荐产品的平均毛利率
25%
ROI AI 推荐产品的投资回报
2.0

7.3 监控告警

  1. # 模型性能监控
  2. def monitor_model_performance():
  3. """
  4. 监控模型性能
  5. """
  6. # 1. 预测准确率监控
  7. recent_predictions = get_recent_predictions(days=7)
  8. actual_results = get_actual_results(recent_predictions)
  9. mae = calculate_mae(recent_predictions, actual_results)
  10. if mae > 50: # 误差超过阈值
  11. send_alert(f"销量预测 MAE 过高:{mae:.2f}")
  12. # 2. 推荐采纳率监控
  13. adoption_rate = calculate_adoption_rate(days=7)
  14. if adoption_rate < 0.4: # 采纳率低于 40%
  15. send_alert(f"AI 推荐采纳率过低:{adoption_rate:.2%}")
  16. # 3. 选品成功率监控
  17. success_rate = calculate_success_rate(days=30)
  18. if success_rate < 0.3: # 成功率低于 30%
  19. send_alert(f"选品成功率过低:{success_rate:.2%}")

版本: 1.0
创建时间: 2026-03-19
维护者: AI 团队

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注