声明类型推断验证状态待复核
每月平摊$5000优惠券给2000用户其中80%用户根本不会因券而改变购买决策——强化学习联合优化促销时机折扣力度和目标人群,增量GMV提升20-35%退订率降低30%年化ROI提升20-60万元
Skill-RL-Dynamic-Promotion-Optimization
每月平摊$5000优惠券给2000用户其中80%用户根本不会因券而改变购买决策——强化学习联合优化促销时机折扣力度和目标人群,增量GMV提升20-35%退订率降低30%年化ROI提升20-60万元
¥20-60 万
待企业数据验证 · 缺失:样本、基线、时间窗、币种、计算方法、证据来源
每月平摊$5000优惠券给2000用户其中80%用户根本不会因券而改变购买决策——强化学习联合优化促销时机折扣力度和目标人群,增量GMV提升20-35%退订率降低30%年化ROI提升20-60万元
静态促销 vs RL 动态促销:
静态规则:
每月15号 → 给所有用户发10%优惠券
问题:高意图用户不需要券也会买;低意图用户10%不够触发购买
RL 动态优化:
状态: 用户购买意图分 + 距上次购买天数 + SKU 库存状态 + 季节
动作: {发10%券, 发20%券, 发30%券, 不发送, 等待}
奖励: 实际 GMV 增量 - 优惠券成本 - 骚扰成本(退订惩罚)
学到的策略:
"高意图用户:10%触发即可"
"中意图用户(距购买 21 天):15% + 限时 48 小时"
"低意图用户:等到 45 天后再试,或不触达"三维联合优化:
\pi^* = \arg\max_\pi \mathbb{E}\left[\sum_t \gamma^t r(s_t, a_t)\right]其中动作 $a_t = (\text{timing}, \text{discount}, \text{target\_segment})$ 是三维联合动作。
因果奖励函数(关键):奖励不是直接的促销后 GMV,而是增量 GMV(因果效应,去掉本来就会买的用户):
r_t = \underbrace{\text{GMV}_{promo}(t) - \text{GMV}_{counterfactual}(t)}_{\text{增量GMV}} - \text{Coupon Cost} - \lambda \cdot \text{Unsubscribe Prob}
业务问题:每月 $5,000 的优惠券预算,平均分给 2,000 名用户,人均 $2.5 的优惠。实际上只有 20% 的用户对优惠券敏感,其他 80% 的用户根本不会因为收到优惠券而改变购买决策。RL 将预算集中给最有可能被说服的用户,同时调整折扣力度。
数据要求: - 历史促销实验数据(发/未发券的 A/B 对照) - 用户行为特征(购买意图/距上次购买天数/CLV) - SKU 利润率(决定最大折扣空间)
预期产出: - 个性化促销策略:每个用户段的最优折扣和时机 - 预算分配优化:从"平摊"到"精准集中" - 增量 ROI:相比静态规则的真实增量收益对比
代码块数量:2
"""
RL Dynamic Promotion Optimization
强化学习动态促销:时机×力度×目标三维联合优化
"""
import numpy as np
from dataclasses import dataclass
from collections import defaultdict
@dataclass
class UserPromotionState:
"""用户促销状态"""
user_id: str
purchase_intent: float # 0-1,购买意图
days_since_purchase: int
clv_score: float # 0-1,客户生命周期价值
emails_sent_30d: int
last_promo_response: str # 'purchased'/'clicked'/'ignored'/'unsubscribed'
# 促销动作空间
PROMOTION_ACTIONS = {
0: {'label': '不发促销', 'discount': 0.0, 'message': None},
1: {'label': '等待观察', 'discount': 0.0, 'message': None},
2: {'label': '10%折扣', 'discount': 0.10, 'message': '专属折扣10%'},
3: {'label': '15%折扣', 'discount': 0.15, 'message': '限时48h折扣15%'},
4: {'label': '20%折扣', 'discount': 0.20, 'message': '会员专属折扣20%'},
}
# 奖励参数
REWARD_PARAMS = {
'avg_order_value': 149.99,
'margin_rate': 0.40, # 40% 毛利率
'unsubscribe_penalty': -5.0,
'discount_cost_multiplier': 1.0,
}
def simulate_user_response(state: UserPromotionState, action_id: int) -> tuple:
"""
模拟用户对促销动作的响应
返回 (response_type, causal_incremental_purchase)
"""
action = PROMOTION_ACTIONS[action_id]
if action['discount'] == 0:
# 不发促销,自然购买概率
natural_prob = 0.05 + 0.15 * state.purchase_intent
purchased = np.random.random() < natural_prob
return ('natural_purchase' if purchased else 'no_action', int(purchased))
# 发促销时
# 骚扰效应(发太多会减弱效果)
frequency_penalty = max(0, state.emails_sent_30d - 3) * 0.05
# 折扣效应(折扣越大触发越容易,但递减)
discount_boost = action['discount'] * 2.5 * (1 - action['discount'])
# 意图×折扣联合触发
purchase_prob = (state.purchase_intent * 0.6 + discount_boost * 0.4) * (1 - frequency_penalty)
unsubscribe_prob = 0.02 * (1 - state.purchase_intent) * (state.emails_sent_30d / 5)
r = np.random.random()
if r < unsubscribe_prob:
return ('unsubscribed', 0)
elif r < unsubscribe_prob + purchase_prob:
# 计算增量购买(因果效应):去掉本来就会购买的用户
natural_prob = 0.05 + 0.10 * state.purchase_intent
counterfactual_purchase = np.random.random() < natural_prob
incremental = 1 - int(counterfactual_purchase) # 1=真正被促销说服
return ('purchased', incremental)
elif r < 0.5:
return ('clicked', 0)
else:
return ('ignored', 0)
def compute_reward(response: str, incremental: int, action_id: int) -> float:
"""计算促销奖励(基于增量 GMV - 成本)"""
p = REWARD_PARAMS
action = PROMOTION_ACTIONS[action_id]
if response == 'unsubscribed':
return p['unsubscribe_penalty']
elif response == 'purchased' and incremental == 1:
# 真实增量:促销才购买的用户
gross_margin = p['avg_order_value'] * p['margin_rate']
coupon_cost = p['avg_order_value'] * action['discount'] * p['discount_cost_multiplier']
return gross_margin - coupon_cost
elif response == 'purchased' and incremental == 0:
# 本来就会买,送券白亏了
coupon_cost = p['avg_order_value'] * action['discount']
return -coupon_cost
else:
return 0.0
class QLearningPromotionAgent:
"""Q-Learning 促销策略 Agent"""
def __init__(self, n_actions: int = 5):
self.q_table = defaultdict(lambda: np.zeros(n_actions))
self.epsilon = 0.3
self.alpha = 0.1
self.gamma = 0.85
def _state_key(self, state: UserPromotionState) -> tuple:
intent_bin = min(4, int(state.purchase_intent * 5))
days_bin = min(4, state.days_since_purchase // 15)
freq_bin = min(3, state.emails_sent_30d)
return (intent_bin, days_bin, freq_bin)
def select_action(self, state: UserPromotionState) -> int:
s = self._state_key(state)
if np.random.random() < self.epsilon:
return np.random.randint(len(PROMOTION_ACTIONS))
return int(np.argmax(self.q_table[s]))
def update(self, state: UserPromotionState, action: int, reward: float,
next_state: UserPromotionState):
s = self._state_key(state)
s_next = self._state_key(next_state)
q_old = self.q_table[s][action]
q_next = np.max(self.q_table[s_next])
self.q_table[s][action] = q_old + self.alpha * (reward + self.gamma * q_next - q_old)
def run_rl_promotion_demo():
print('=' * 65)
print('RL Dynamic Promotion Optimization — 动态促销强化学习')
print('=' * 65)
np.random.seed(42)
agent = QLearningPromotionAgent()
agent.epsilon = 0.4 # 训练阶段高探索
# 训练模拟(100个用户×30天)
n_users, n_days = 100, 30
rl_total_reward = 0
static_total_reward = 0
for u in range(n_users):
state = UserPromotionState(
f'U{u}', np.random.beta(2, 5),
np.random.randint(1, 60), np.random.random(),
0, 'no_action'
)
for day in range(n_days):
# RL 策略
action = agent.select_action(state)
response, incremental = simulate_user_response(state, action)
reward = compute_reward(response, incremental, action)
rl_total_reward += reward
# 静态策略(每5天发15%券)
static_action = 3 if day % 5 == 0 else 0
static_response, static_inc = simulate_user_response(state, static_action)
static_reward = compute_reward(static_response, static_inc, static_action)
static_total_reward += static_reward
# 更新状态
next_state = UserPromotionState(
state.user_id,
min(1, state.purchase_intent + 0.05 * (response == 'purchased')),
state.days_since_purchase + 1,
state.clv_score,
min(10, state.emails_sent_30d + (1 if action > 0 else 0)),
response,
)
agent.update(state, action, reward, next_state)
state = next_state
if state.last_promo_response == 'unsubscribed': break
print(f'\n📊 RL vs 静态促销对比 ({n_users}用户,{n_days}天):')
print(f' RL 动态促销总奖励: ${rl_total_reward:.2f}')
print(f' 静态规则总奖励: ${static_total_reward:.2f}')
improvement = (rl_total_reward - static_total_reward) / abs(static_total_reward + 1e-8) * 100
print(f' RL 提升: {improvement:+.1f}%')
# 展示学到的策略
agent.epsilon = 0.0
print(f'\n🤖 RL 学到的策略(不同用户状态→推荐动作):')
test_cases = [
(0.85, 5, 0, '高意图新用户(5天未购买)'),
(0.30, 45, 2, '低意图老用户(45天未购买,已发2封)'),
(0.65, 20, 1, '中意图用户(20天)'),
(0.10, 80, 5, '低意图低频用户(80天,已发5封)'),
]
for intent, days, sent, label in test_cases:
state = UserPromotionState('test', intent, days, 0.5, sent, 'no_action')
action = agent.select_action(state)
print(f' {label:<35} → {PROMOTION_ACTIONS[action]["label"]}')
print('\n[✓] RL Dynamic Promotion Optimization 测试通过')
if __name__ == '__main__':
run_rl_promotion_demo()论文链接用于核验方法来源,不自动证明本页商业结果。