P paper2skillsPlaybook
开始业务诊断
访客模式
05-推荐系统

Price-Sensitive Recommendation — 价格感知推荐:弹性感知的个性化定价与排序融合

Skill-Price-Sensitive-Recommendation

声明类型推断验证状态待复核

业务背景:Prime Day / Black Friday 母婴类目促销期间,某品牌对婴儿消毒器打折30%($59.99→$41.99)

来源
paper2skills-vault/05-推荐系统/Skill-Price-Sensitive-Recommendation.md
适用边界
论文方法到业务问题的项目侧映射,不自动证明客户根因。
声明类型示例验证状态待企业数据验证

老客连带购买率提升 20-35%,客单价提升,品类交叉销售做起来

来源
paper2skills-vault/05-推荐系统/Skill-Price-Sensitive-Recommendation.md#business-value
适用边界
方法估算或场景示例,不等于客户结果或收益承诺。

待企业数据验证 · 缺失:样本、基线、时间窗、币种、计算方法、证据来源

业务视角
适用角色运营负责人 / 选品负责人 · 产品经理 · 广告优化师
适用平台Amazon · DTC 独立站 · 邮件/SMS 个性化
什么情况下用老客来了只买一件就走,相关产品没被推出去;Bundle 商品连带销售做不起来;站内推荐位点击率低
示例目标(需企业数据验证)老客连带购买率提升 20-35%,客单价提升,品类交叉销售做起来
业务痛点
老客复购率上不去相关产品没有被看到Bundle 凑单没人用新品没有曝光机会

1. 解决的问题

业务背景:Prime Day / Black Friday 母婴类目促销期间,某品牌对婴儿消毒器打折30%($59.99→$41.99)

2. 核心算法逻辑

核心思想

传统推荐系统只关注用户与商品的"相关性",完全忽视价格因素;而传统定价系统只优化利润或销量,不考虑用户个性化偏好。Price-Sensitive Recommendation 的核心思想是将个体价格弹性注入推荐排序决策:

  1. 用户级价格弹性:不同用户对同一商品的价格变化反应不同——高消费力用户弹性小(降价对购买决策影响小),价格敏感用户弹性大(小幅降价即可促成转化)
  2. 商品-用户价格效用:推荐的目标不是"最贵的"也不是"最便宜的",而是对特定用户"价格-效用比最优的"
  3. 双向融合:推荐系统感知价格信号(提升转化),定价系统感知推荐信号(精准定价到不同弹性用户群)

与纯动态定价的区别:动态定价面向所有用户统一调价;价格感知推荐面向每个用户,展示"对他们而言价格最合适"的商品组合。

数学模型

用户个体价格弹性估计:

设用户 $u$ 对商品 $i$ 的购买概率为 $p_{ui}(v)$($v$ 为价格),弹性定义为:

\epsilon_{ui} = -\frac{\partial \ln p_{ui}}{\partial \ln v} = -\frac{v}{p_{ui}} \cdot \frac{\partial p_{ui}}{\partial v}

使用 Logistic 模型近似:

p_{ui}(v) = \sigma(\hat{r}_{ui} - \beta_{ui} \cdot \ln v)

其中 $\hat{r}_{ui}$ 是 MF 给出的个性化相关分,$\beta_{ui}$ 是用户-商品价格敏感系数。

\epsilon_{ui} \approx \beta_{ui} \cdot (1 - p_{ui}(v))

价格效用函数:

U_{ui}(v) = \hat{r}_{ui} - \beta_{ui} \cdot \ln\left(\frac{v}{v_{ref}}\right)

其中 $v_{ref}$ 是该品类参考价(历史均价),$\beta_{ui}$ 从用户历史购买-放弃行为中学习。

价格感知排序分:

\hat{s}_{ui} = \underbrace{U_{ui}(v_i)}_{\text{价格效用}} + \mu \cdot \underbrace{\hat{r}_{ui}^{MF}}_{\text{协同过滤相关性}}

考虑价格促销的增益:

若商品 $i$ 当前打折($v_i < v_i^{original}$),对价格敏感用户有额外增益:

\Delta_{ui} = \beta_{ui} \cdot \ln\left(\frac{v_i^{original}}{v_i}\right) \cdot \mathbf{1}[\text{is\_on\_sale}]

最终排序分:$\hat{s}_{ui}^{final} = \hat{s}_{ui} + \Delta_{ui}$

$\beta_{ui}$ 学习(Bayesian 个性化估计):

\beta_{ui} = \bar{\beta}_u + \bar{\beta}_i - \bar{\beta} + \epsilon_{ui}^{noise}

其中 $\bar{\beta}_u$ 是用户全局价格敏感度(从历史行为学习),$\bar{\beta}_i$ 是商品价格弹性基线。

去偏处理(Debiasing)

价格感知推荐面临曝光偏差:推荐系统倾向于展示高转化商品(往往是打折品),导致用户对非打折期的价格感知偏高,学习到的 $\beta_{ui}$ 被高估。

去偏公式(逆倾向加权 IPW):

\hat{\mathcal{L}} = \frac{1}{|\mathcal{D}|} \sum_{(u,i,v) \in \mathcal{D}} \frac{\mathcal{L}(p_{ui}(v), y_{ui})}{e_{ui}}

其中 $e_{ui} = P(\text{曝光} | u, i)$ 为倾向分,可用推荐系统的排名估计。

与现有方法对比

方法个性化价格感知弹性建模去偏代表工作
纯 MF 推荐✅✗✗✗BPR-MF
动态定价✗✅聚合级✗Thompson Sampling
价格特征 MF部分部分✗✗FM + Price Feature
Price-Sensitive Rec(本方法)✅✅用户个体级✅(IPW)arXiv 2403.xxxxx

关键优势:用户级弹性建模允许对价格敏感用户展示折扣商品、对低弹性用户优先展示高利润商品,最大化平台 GMV。

参考论文

论文arXiv年份关键贡献
Price-Aware Recommendation with Dynamic User Preference[2403.07571](https://arxiv.org/abs/2403.07571)2024-03用户级弹性建模 + 动态价格效用函数
PIER: Price-Informed E-commerce Ranking[2408.11589](https://arxiv.org/abs/2408.11589)2024-08价格注入精排 + IPW 去偏框架
Elasticity-Aware Personalized Pricing and Recommendation[2501.09223](https://arxiv.org/abs/2501.09223)2025-01定价×推荐双向联合优化

与 Price-Sensitive-Personalized-Recommendation 合并(2026-10-02)

原 Price-Sensitive-Personalized-Recommendation(227 行)与本卡交付同一件东西,已并入本卡后退役,关系与引用一并转到这里。并进来时逐项核对过的独有内容:

  • 原卡的实现入口:estimate_user_price_sensitivity()、price_comfort_score()、price_sensitive_rerank()、run_price_sensitive_recom_demo()
  • 原卡引用而本卡未记的论文号:2407.12983

3. 业务应用场景

业务背景:Prime Day / Black Friday 母婴类目促销期间,某品牌对婴儿消毒器打折30%($59.99→$41.99)。但促销推送策略是"给所有收藏过该商品的用户群发",导致原本会全价购买的用户(低弹性)也被打折吸引,削减利润;而真正需要折扣激励才会购买的用户(高弹性)反而没被精准触达。

Price-Sensitive Recommendation 应用:

业务背景:AIM DTC 独立站(婴儿消毒设备)同时销售$49(基础款)、$79(升级款)、$129(旗舰款)三个价位产品。当前首页推荐对所有用户展示相同顺序,无法区分价格敏感度不同的访客。

4. 输入数据要求

未提取到输入条目;请核对原始 Skill 卡片与代码。

5. 输出结果

未提取到输出条目;请核对原始 Skill 卡片与代码。

6. 业务价值与 ROI

未自动抽取;请查看原始 Skill 卡片。

7. 代码模板

代码块数量:4

Python484 行 · 完整显示
"""
Price-Sensitive Recommendation: 价格感知个性化推荐
整合 MF 相关分 + 用户价格弹性估计 + 价格效用函数 + IPW 去偏
完全使用 mock 数据,无需真实 API
"""

import numpy as np
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple


# ── 数据结构 ──────────────────────────────────────────────────────────────────

@dataclass
class PriceHistory:
    """商品历史价格数据"""
    product_id: str
    prices: List[float]              # 历史价格序列
    sales_volumes: List[float]       # 对应销量
    reference_price: float = 0.0    # 参考价(类目均价)

    def __post_init__(self):
        if self.reference_price == 0.0 and self.prices:
            self.reference_price = float(np.mean(self.prices))


@dataclass
class PricedProduct:
    """带价格信息的商品"""
    product_id: str
    name: str
    current_price: float
    original_price: float       # 原价(促销时 < original_price)
    category: str
    reference_price: float = 0.0

    @property
    def is_on_sale(self) -> bool:
        return self.current_price < self.original_price * 0.97

    @property
    def discount_rate(self) -> float:
        if self.original_price <= 0:
            return 0.0
        return max(0.0, 1.0 - self.current_price / self.original_price)


@dataclass
class UserPriceProfile:
    """用户价格弹性画像"""
    user_id: str
    global_beta: float = 1.0         # 全局价格敏感系数 β_u
    category_betas: Dict[str, float] = field(default_factory=dict)
    purchase_price_history: List[float] = field(default_factory=list)  # 历史购买价格

    def get_beta(self, category: str) -> float:
        """获取特定品类的价格弹性"""
        return self.category_betas.get(category, self.global_beta)

    def elasticity_segment(self) -> str:
        """弹性分层"""
        if self.global_beta < 0.5:
            return "low"      # 低弹性
        elif self.global_beta < 1.5:
            return "medium"   # 中弹性
        else:
            return "high"     # 高弹性


# ── 核心算法 ──────────────────────────────────────────────────────────────────

class PriceElasticityEstimator:
    """
    用户价格弹性估计器
    从历史购买/放弃行为中学习 β_ui
    """

    def __init__(self, prior_beta: float = 1.0, smoothing: float = 0.1):
        self.prior_beta = prior_beta
        self.smoothing = smoothing      # 贝叶斯平滑
        # 存储 (user_id, product_id) → β 估计
        self.beta_cache: Dict[Tuple[str, str], float] = {}
        # 用户级全局 β
        self.user_beta: Dict[str, float] = {}
        # 品类级 β
        self.category_beta: Dict[str, float] = {}

    def update_from_event(
        self,
        user_id: str,
        product_id: str,
        category: str,
        price: float,
        ref_price: float,
        purchased: bool,
    ):
        """
        根据单次购买/放弃事件更新弹性估计
        - 低价购买高频:β 大(价格敏感)
        - 高价仍然购买:β 小(价格不敏感)
        """
        if ref_price <= 0:
            return

        price_ratio = price / ref_price
        # 价格低于参考价时购买 → 价格激励有效 → β 偏大
        # 价格高于参考价时购买 → 价格不敏感 → β 偏小
        signal = -np.log(max(price_ratio, 0.1)) if purchased else np.log(max(price_ratio, 0.1))
        signal = float(np.clip(signal, -2.0, 2.0))

        # 指数移动平均更新
        old_beta = self.user_beta.get(user_id, self.prior_beta)
        new_beta = (1 - self.smoothing) * old_beta + self.smoothing * (self.prior_beta + signal)
        self.user_beta[user_id] = float(np.clip(new_beta, 0.1, 5.0))

        # 更新品类弹性
        old_cat_beta = self.category_beta.get(category, self.prior_beta)
        self.category_beta[category] = (
            0.9 * old_cat_beta + 0.1 * (self.prior_beta + signal * 0.5)
        )

    def get_user_beta(self, user_id: str) -> float:
        return self.user_beta.get(user_id, self.prior_beta)

    def get_product_beta(self, user_id: str, category: str) -> float:
        """组合用户级 + 品类级弹性(矩阵分解形式)"""
        beta_u = self.user_beta.get(user_id, self.prior_beta)
        beta_c = self.category_beta.get(category, self.prior_beta)
        # 类似 MF 分解:β_ui = β_u + β_c - β_global
        return float(np.clip(beta_u + beta_c - self.prior_beta, 0.1, 5.0))

    def batch_simulate(
        self,
        n_users: int = 200,
        n_events_per_user: int = 20,
        seed: int = 42,
    ) -> Dict[str, float]:
        """
        批量模拟历史事件,生成用户弹性分布
        Returns: {user_id: beta}
        """
        rng = np.random.default_rng(seed)
        categories = ["奶粉", "奶嘴", "婴儿推车", "消毒器", "纸尿裤"]
        ref_prices = {"奶粉": 45.0, "奶嘴": 12.0, "婴儿推车": 299.0, "消毒器": 79.0, "纸尿裤": 35.0}

        # 真实弹性(hidden ground truth,用于生成事件)
        true_betas = rng.exponential(scale=1.0, size=n_users)

        for u_idx in range(n_users):
            user_id = f"U{u_idx:04d}"
            true_beta = true_betas[u_idx]
            for _ in range(n_events_per_user):
                cat = rng.choice(categories)
                ref = ref_prices[cat]
                price = ref * rng.uniform(0.6, 1.4)
                # 购买概率:高弹性用户更喜欢低价
                price_ratio = price / ref
                purchase_prob = 1.0 / (1.0 + np.exp(true_beta * np.log(price_ratio) + 0.5))
                purchased = rng.random() < purchase_prob
                self.update_from_event(user_id, f"P{rng.integers(100)}", cat, price, ref, purchased)

        return dict(self.user_beta)


class PriceSensitiveRecommender:
    """
    价格感知推荐器
    融合公式:s_hat = U_ui(v) + μ * r_ui_MF + Δ_ui (促销增益)
    """

    def __init__(
        self,
        elasticity_estimator: PriceElasticityEstimator,
        mf_scores: Optional[Dict[Tuple[str, str], float]] = None,
        mu: float = 0.4,        # MF 锚定权重
    ):
        self.estimator = elasticity_estimator
        self.mf_scores = mf_scores or {}
        self.mu = mu

    def price_utility(
        self,
        user_id: str,
        product: PricedProduct,
        mf_base_score: float = 0.5,
    ) -> float:
        """
        计算价格效用 U_ui(v)
        U_ui = r_ui_mf - β_ui * ln(v / v_ref)
        """
        beta_ui = self.estimator.get_product_beta(user_id, product.category)
        ref_price = product.reference_price if product.reference_price > 0 else product.original_price
        if ref_price <= 0:
            ref_price = product.current_price

        price_log_ratio = np.log(max(product.current_price, 0.01) / max(ref_price, 0.01))
        utility = mf_base_score - beta_ui * price_log_ratio
        return float(utility)

    def promotion_gain(
        self,
        user_id: str,
        product: PricedProduct,
    ) -> float:
        """
        促销增益 Δ_ui
        对价格敏感用户,折扣带来额外购买意愿提升
        """
        if not product.is_on_sale:
            return 0.0
        beta_ui = self.estimator.get_product_beta(user_id, product.category)
        discount_log = np.log(
            max(product.original_price, 0.01) / max(product.current_price, 0.01)
        )
        return float(beta_ui * discount_log * 0.3)  # 0.3 为促销敏感度系数

    def rank(
        self,
        user_id: str,
        products: List[PricedProduct],
        top_k: int = 10,
    ) -> List[Tuple[str, float, str]]:
        """
        对商品列表进行价格感知排序

        Returns:
            List of (product_id, final_score, price_segment_label)
        """
        beta_u = self.estimator.get_user_beta(user_id)
        segment = (
            "low_elastic" if beta_u < 0.5
            else "medium_elastic" if beta_u < 1.5
            else "high_elastic"
        )

        results = []
        for p in products:
            mf_base = self.mf_scores.get((user_id, p.product_id), 0.5)
            utility = self.price_utility(user_id, p, mf_base)
            promo = self.promotion_gain(user_id, p)
            final_score = (1 - self.mu) * utility + self.mu * mf_base + promo
            results.append((p.product_id, float(final_score), segment))

        results.sort(key=lambda x: -x[1])
        return results[:top_k]

    def personalized_pricing_advice(
        self,
        user_id: str,
        product: PricedProduct,
    ) -> Dict[str, float]:
        """
        为定价团队提供个性化价格建议
        Returns: 该用户对该商品的最优触达价格(最大化转化概率)
        """
        beta_ui = self.estimator.get_product_beta(user_id, product.category)
        ref = product.reference_price or product.original_price

        # 对高弹性用户:略低于参考价有最大边际效果
        # 对低弹性用户:当前价格已经最优,无需打折
        if beta_ui > 1.5:
            suggested_price = ref * np.exp(-0.5 / beta_ui)
        elif beta_ui > 0.5:
            suggested_price = ref * np.exp(-0.2 / beta_ui)
        else:
            suggested_price = ref  # 低弹性:不需要降价

        return {
            "user_id": user_id,
            "beta_ui": beta_ui,
            "suggested_price": round(float(np.clip(suggested_price, ref * 0.5, ref)), 2),
            "reference_price": ref,
            "expected_discount": round(float(max(0, 1 - suggested_price / ref)), 2),
        }


class IPWDebiaser:
    """
    逆倾向加权(IPW)去偏器
    修正推荐系统曝光偏差对弹性学习的影响
    """

    def __init__(self, min_propensity: float = 0.01):
        self.min_propensity = min_propensity
        # 曝光倾向(由推荐排名估计)
        self.propensity_cache: Dict[Tuple[str, str], float] = {}

    def estimate_propensity(
        self,
        user_id: str,
        product_id: str,
        recommendation_rank: Optional[int] = None,
    ) -> float:
        """
        估计(user, item)的曝光倾向分
        简化模型:rank越高,曝光概率越高
        """
        if (user_id, product_id) in self.propensity_cache:
            return self.propensity_cache[(user_id, product_id)]

        if recommendation_rank is not None:
            # 位置偏差模型:P(impression | rank) ∝ 1/rank^0.7
            propensity = min(1.0, 1.0 / (recommendation_rank ** 0.7))
        else:
            propensity = 0.5  # 默认均匀曝光

        propensity = max(self.min_propensity, propensity)
        self.propensity_cache[(user_id, product_id)] = propensity
        return propensity

    def debiased_loss(
        self,
        prediction: float,
        label: float,
        propensity: float,
    ) -> float:
        """
        IPW 加权损失
        L_debias = (y - y_hat)^2 / propensity
        """
        raw_loss = (label - prediction) ** 2
        return raw_loss / max(self.min_propensity, propensity)

    def compute_debiased_beta(
        self,
        events: List[Dict],
    ) -> Dict[str, float]:
        """
        批量去偏:从事件列表计算去偏后的用户弹性
        events: [{"user_id", "product_id", "price", "ref_price", "rank", "purchased"}]
        Returns: {user_id: debiased_beta}
        """
        user_signals: Dict[str, List[float]] = {}

        for event in events:
            uid = event["user_id"]
            price = event["price"]
            ref = event["ref_price"]
            rank = event.get("rank", 5)
            purchased = event["purchased"]

            propensity = self.estimate_propensity(uid, event["product_id"], rank)
            price_ratio = max(price / max(ref, 0.01), 0.01)

            raw_signal = float(np.log(1.0 / price_ratio)) if purchased else 0.0
            ipw_signal = raw_signal / propensity  # 去偏后信号

            if uid not in user_signals:
                user_signals[uid] = []
            user_signals[uid].append(ipw_signal)

        # 平均 IPW 信号作为去偏弹性估计
        return {
            uid: float(np.clip(np.mean(signals) + 1.0, 0.1, 5.0))
            for uid, signals in user_signals.items()
        }


# ── 使用示例 ─────────────────────────────────────────────────────────────────

def demo_price_sensitive_recommendation():
    """
    母婴电商价格感知推荐 Demo
    场景:婴儿消毒器商品对不同弹性用户的个性化排序
    """
    # Mock 商品数据(婴儿消毒器不同价位)
    products = [
        PricedProduct("S001", "Philips Avent 消毒器(旗舰)", current_price=129.0, original_price=129.0,
                     category="消毒器", reference_price=89.0),
        PricedProduct("S002", "Dr. Brown 消毒器(升级)", current_price=59.0, original_price=79.0,
                     category="消毒器", reference_price=89.0),   # 促销 25% off
        PricedProduct("S003", "Babisil 消毒器(基础)", current_price=39.0, original_price=39.0,
                     category="消毒器", reference_price=89.0),
        PricedProduct("S004", "安全保 消毒袋", current_price=18.0, original_price=22.0,
                     category="消毒器", reference_price=89.0),   # 促销
        PricedProduct("S005", "Chicco 旅行消毒器", current_price=55.0, original_price=55.0,
                     category="消毒器", reference_price=89.0),
    ]

    # 初始化弹性估计器并模拟历史数据
    estimator = PriceElasticityEstimator()
    print("[初始化] 模拟200个用户的历史购买行为...")
    estimator.batch_simulate(n_users=200, n_events_per_user=30)

    # Mock MF 基础分
    rng = np.random.default_rng(42)
    mf_scores = {
        ("U0042", p.product_id): float(rng.uniform(0.3, 0.8))
        for p in products
    }
    mf_scores[("U0042", "S002")] = 0.72  # 这款对U0042相关性高
    # U0099 的 MF 基础分
    for p in products:
        mf_scores[("U0099", p.product_id)] = float(rng.uniform(0.3, 0.8))

    # 初始化推荐器
    recommender = PriceSensitiveRecommender(estimator, mf_scores, mu=0.35)

    print("\n" + "=" * 65)
    print("价格感知推荐 Demo — 婴儿消毒器个性化排序")
    print("=" * 65)

    # 测试两个不同弹性的用户
    test_users = [
        ("U0042", "高弹性用户(价格敏感,等折扣购买)"),
        ("U0099", "低弹性用户(质量优先,全价购买)"),
    ]

    for user_id, user_desc in test_users:
        beta = estimator.get_user_beta(user_id)
        # 如果 mock 用户不存在,手动设置弹性
        if user_id not in estimator.user_beta:
            estimator.user_beta[user_id] = 2.2 if "高弹性" in user_desc else 0.3

        beta = estimator.get_user_beta(user_id)
        segment = estimator.user_beta.get(user_id, 1.0)

        print(f"\n[用户: {user_id} — {user_desc}]")
        print(f"  价格弹性 β={beta:.2f},分层: {UserPriceProfile(user_id, beta).elasticity_segment()}")

        results = recommender.rank(user_id, products, top_k=5)

        for rank, (pid, score, seg) in enumerate(results, 1):
            p = next(x for x in products if x.product_id == pid)
            sale_tag = f" 🔥促销{p.discount_rate:.0%}off" if p.is_on_sale else ""
            print(f"  {rank}. {p.name} ${p.current_price:.0f}{sale_tag} → 评分={score:.4f}")

        # 定价建议
        flagship = next(p for p in products if p.product_id == "S001")
        advice = recommender.personalized_pricing_advice(user_id, flagship)
        print(f"  💡 旗舰款定价建议: 参考价${advice['reference_price']},"
              f"建议触达价${advice['suggested_price']}(折扣{advice['expected_discount']:.0%})")

    return True


def test_high_elastic_prefers_discount():
    """单元测试:高弹性用户应优先看到促销商品"""
    products_test = [
        PricedProduct("A", "高价无折扣", current_price=100.0, original_price=100.0,
                     category="test", reference_price=80.0),
        PricedProduct("B", "低价有折扣", current_price=50.0, original_price=80.0,
                     category="test", reference_price=80.0),
    ]

    estimator = PriceElasticityEstimator()
    estimator.user_beta["high_user"] = 2.5    # 高弹性
    estimator.user_beta["low_user"] = 0.2     # 低弹性

    # A 是"相关性更高但全价"的商品,B 是"相关性略低但在打折"的商品。
    # 原先两者相关性都写 0.6,于是"低弹性用户应优先看到高价 A"这条断言
    # 在模型里永远不成立——低弹性意味着几乎不在乎价格,那排序就由相关性决定;
    # 两者相等时没有任何理由让高价款胜出(实测 B 恒第一)。
    mf_scores = {
        ("high_user", "A"): 0.75, ("high_user", "B"): 0.60,
        ("low_user", "A"): 0.75, ("low_user", "B"): 0.60,
    }
    rec = PriceSensitiveRecommender(estimator, mf_scores, mu=0.3)

    high_results = rec.rank("high_user", products_test, top_k=2)
    low_results = rec.rank("low_user", products_test, top_k=2)

    high_top = high_results[0][0]
    low_top = low_results[0][0]

    print(f"\n[价格弹性测试]")
    print(f"  高弹性用户优先推荐: {high_top}(期望B-折扣款)")
    print(f"  低弹性用户优先推荐: {low_top}(期望A-高价全价款)")
    assert high_top == "B", f"高弹性用户应优先看到折扣商品B,实际: {high_top}"
    assert low_top == "A", f"低弹性用户应优先看到高价商品A,实际: {low_top}"
    # 这张卡的全部卖点就是"同一份候选集,弹性不同的人排序应不同"
    assert high_top != low_top, "弹性差异没有改变首位商品,说明价格项没进排序"
    print(f"  ✅ 测试通过:弹性差异驱动排序差异化")
    return True


if __name__ == "__main__":
    np.random.seed(42)

    # 修正 demo 中的 dict comprehension 问题
    demo_price_sensitive_recommendation()
    test_high_elastic_prefers_discount()
    print("\n✅ 所有测试通过")
    print("[✓] Skill-Price-Sensitive-Recommendation 测试通过")

8. 论文来源

论文链接用于核验方法来源,不自动证明本页商业结果。