CURRENT_STATUS.md 5.33 KB

当前状态说明

✅ 已完成并可用的功能

1. i2i 行为相似算法(100%可用)

  • Swing算法 - 已适配实际数据库字段
  • Session W2V - 已适配实际数据库字段
  • DeepWalk - 已适配实际数据库字段

使用的字段(已验证存在):

  • sensors_events.anonymous_id
  • sensors_events.item_id
  • sensors_events.event
  • sensors_events.create_time
  • prd_goods_sku.id
  • prd_goods_sku.name

输出格式

item_id \t item_name \t similar_item_id1:score1,similar_item_id2:score2,...

运行命令

# 单独运行
python3 scripts/i2i_swing.py --lookback_days 730 --top_n 50
python3 scripts/i2i_session_w2v.py --lookback_days 730 --top_n 50
python3 scripts/i2i_deepwalk.py --lookback_days 730 --top_n 50

2. 兴趣点聚合(部分可用)

已适配的维度:

business_platform - 业务平台维度

platform:pc → item_id1:score1,item_id2:score2,...
platform:mobile → ...

client_platform - 客户端平台维度

client_platform:web → item_id1:score1,item_id2:score2,...
client_platform:app → ...

platform_client - 组合维度

platform_client:pc_web → item_id1:score1,item_id2:score2,...

已适配的列表类型:

hot - 热门商品(基于最近180天) ✅ cart - 加购商品 ✅ new - 新品(基于create_time)

运行命令

python3 scripts/interest_aggregation.py --lookback_days 730 --top_n 1000

⚠️ 原计划但未实现的功能(因字段不存在)

sensors_events 表缺失字段:

  • country - 国家/销售区域
  • customer_type - 客户类型

prd_goods_sku 表缺失字段:

  • category_level2_id - 二级分类
  • category_level3_id - 三级分类

影响的索引:

  • ❌ country:{country}
  • ❌ customer_type:{type}
  • ❌ category_level2:{cat_id}
  • ❌ category_level3:{cat_id}
  • ❌ 相关的组合维度索引

📊 业务场景映射(更新后)

场景1: 首页猜你喜欢

可用索引

# 按平台推荐
interest:hot:platform:pc
interest:hot:platform:mobile

# 按客户端平台推荐
interest:hot:client_platform:web
interest:hot:client_platform:app

# 组合维度
interest:hot:platform_client:pc_web

场景2: 详情页大家都在看

可用索引

# i2i相似度(完全可用)
i2i:swing:{item_id}
i2i:session_w2v:{item_id}
i2i:deepwalk:{item_id}

场景3: 搜索结果页推荐

可用索引

# 按平台的全局推荐
interest:global:platform:pc
interest:global:client_platform:web

# 或使用 page_type(需要扩展)
interest:global:page_type:search

🎯 当前可用的完整索引列表

i2i索引(完全可用)

i2i:swing:{item_id}
i2i:session_w2v:{item_id}
i2i:deepwalk:{item_id}

兴趣点聚合索引(部分可用)

单维度

platform:{business_platform}           # 如:platform:pc
client_platform:{client_platform}      # 如:client_platform:web

组合维度

platform_client:{platform}_{client}    # 如:platform_client:pc_web

列表类型前缀

interest:hot:...
interest:cart:...
interest:new:...
interest:global:...

完整示例

interest:hot:platform:pc
interest:hot:client_platform:web
interest:hot:platform_client:pc_web
interest:cart:platform:mobile
interest:new:client_platform:app
interest:global:platform:pc

🚀 快速运行

测试i2i功能(完全可用)

cd /home/tw/recommendation/offline_tasks

# 运行Swing算法(小数据量测试)
python3 scripts/i2i_swing.py --lookback_days 30 --top_n 10

# 查看输出
head -n 5 output/i2i_swing_*.txt

测试兴趣点聚合(部分可用)

# 运行兴趣点聚合(小数据量测试)
python3 scripts/interest_aggregation.py --lookback_days 30 --top_n 100

# 查看输出
head -n 10 output/interest_aggregation_hot_*.txt
grep "^platform:" output/interest_aggregation_hot_*.txt | head -5

运行所有可用任务

# 运行全部
python3 run_all.py --lookback_days 730 --top_n 50

# 查看日志
tail -f logs/run_all_*.log

💡 建议

短期建议(立即可用)

  1. 优先使用 i2i 功能 - 这部分功能完整且经过验证
  2. 使用现有平台维度 - platform 和 client_platform 可以满足基本需求
  3. 测试小数据量 - 先用30天数据测试,确认无误后再用完整数据

中期建议(需要扩展)

  1. 添加更多维度 - 可以考虑使用 page_typeitem_type 等现有字段
  2. 关联其他表 - 如果其他表有分类信息,可以通过 JOIN 获取
  3. 解析JSON字段 - __properties 可能包含额外信息

长期建议(需要数据支持)

  1. 补充用户特征字段 - 在 sensors_events 表中添加 country、customer_type 字段
  2. 补充商品分类字段 - 在 prd_goods_sku 表或关联表中添加分类信息
  3. 建立用户画像表 - 单独维护用户属性信息

📞 文档索引

  • FIELD_MAPPING.md - 字段映射详细说明
  • DATABASE_SETUP.md - 数据库配置指南
  • TROUBLESHOOTING.md - 故障排除
  • CHANGELOG.md - 更新日志
  • README.md - 完整文档

更新时间: 2025-10-16
状态: i2i功能完全可用,兴趣点聚合部分可用