Blame view

offline_tasks/CURRENT_STATUS.md 5.33 KB
5ab1c29c   tangwang   first commit
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  # 当前状态说明
  
  ## ✅ 已完成并可用的功能
  
  ### 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,...
  ```
  
  **运行命令**
  ```bash
  # 单独运行
  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)
  
  **运行命令**
  ```bash
  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: 首页猜你喜欢
  **可用索引**
  ```python
  # 按平台推荐
  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: 详情页大家都在看
  **可用索引**
  ```python
  # i2i相似度(完全可用)
  i2i:swing:{item_id}
  i2i:session_w2v:{item_id}
  i2i:deepwalk:{item_id}
  ```
  
  ### 场景3: 搜索结果页推荐
  **可用索引**
  ```python
  # 按平台的全局推荐
  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功能(完全可用)
  ```bash
  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
  ```
  
  ### 测试兴趣点聚合(部分可用)
  ```bash
  # 运行兴趣点聚合(小数据量测试)
  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
  ```
  
  ### 运行所有可用任务
  ```bash
  # 运行全部
  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_type`、`item_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功能完全可用,兴趣点聚合部分可用