{"id":4077,"date":"2025-10-18T11:58:04","date_gmt":"2025-10-18T03:58:04","guid":{"rendered":"http:\/\/viplao.com\/?p=4077"},"modified":"2025-10-18T11:58:31","modified_gmt":"2025-10-18T03:58:31","slug":"%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/viplao.com\/index.php\/2025\/10\/18\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90\/","title":{"rendered":"\u3010\u8fd0\u8425\u6570\u636e\u5206\u6790-\u8fdb\u9636\u7bc7\u3011 \u5546\u54c1\u4e0e\u5e93\u5b58\u5206\u6790"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/viplao.com\/index.php\/2025\/10\/18\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90\/#61_%E5%95%86%E5%93%81%E9%94%80%E5%94%AE%E5%88%86%E6%9E%90\" title=\"6.1 \u5546\u54c1\u9500\u552e\u5206\u6790\">6.1 \u5546\u54c1\u9500\u552e\u5206\u6790<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/viplao.com\/index.php\/2025\/10\/18\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90\/#62_%E5%BA%93%E5%AD%98%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BC%98%E5%8C%96\" title=\"6.2 \u5e93\u5b58\u7ba1\u7406\u4e0e\u4f18\u5316\">6.2 \u5e93\u5b58\u7ba1\u7406\u4e0e\u4f18\u5316<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/viplao.com\/index.php\/2025\/10\/18\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90\/#63_%E4%BB%B7%E6%A0%BC%E6%95%8F%E6%84%9F%E6%80%A7%E5%88%86%E6%9E%90\" title=\"6.3 \u4ef7\u683c\u654f\u611f\u6027\u5206\u6790\">6.3 \u4ef7\u683c\u654f\u611f\u6027\u5206\u6790<\/a><\/li><\/ul><\/nav><\/div>\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"61_%E5%95%86%E5%93%81%E9%94%80%E5%94%AE%E5%88%86%E6%9E%90\"><\/span><strong>6.1 \u5546\u54c1\u9500\u552e\u5206\u6790<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><strong>\u3010\u7406\u8bba\u8bb2\u89e3\u3011<\/strong><\/p>\n\n\n\n<p>\u5546\u54c1\u9500\u552e\u5206\u6790\u662f\u7535\u5546\u8fd0\u8425\u7684\u6838\u5fc3\u3002\u901a\u8fc7\u5206\u6790\u5546\u54c1\u7684\u9500\u552e\u989d\u3001\u9500\u91cf\u3001\u6bdb\u5229\u7387\u3001\u54c1\u7c7b\u8868\u73b0\u4ee5\u53ca\u5546\u54c1\u4e4b\u95f4\u7684\u5173\u8054\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u4f18\u5316\u5546\u54c1\u7ed3\u6784\u3001\u5236\u5b9a\u5b9a\u4ef7\u7b56\u7565\u3001\u6346\u7ed1\u9500\u552e\u548c\u4ea4\u53c9\u9500\u552e\uff0c\u4ece\u800c\u63d0\u5347\u6574\u4f53\u9500\u552e\u4e1a\u7ee9\u3002<\/p>\n\n\n\n<p><strong>\u6838\u5fc3\u6307\u6807\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u9500\u552e\u989d (Revenue)\uff1a<\/strong>&nbsp;<code>\u4ef7\u683c * \u6570\u91cf<\/code><\/li>\n\n\n\n<li><strong>\u9500\u91cf (Volume)\uff1a<\/strong>&nbsp;\u552e\u51fa\u7684\u5546\u54c1\u6570\u91cf<\/li>\n\n\n\n<li><strong>\u6bdb\u5229\u7387 (Gross Margin)\uff1a<\/strong>&nbsp;<code>(\u9500\u552e\u989d-\u6210\u672c) \/ \u9500\u552e\u989d<\/code><\/li>\n\n\n\n<li><strong>\u54c1\u7c7b\u8868\u73b0\uff1a<\/strong>&nbsp;\u4e0d\u540c\u54c1\u7c7b\u7684\u9500\u552e\u8d21\u732e<\/li>\n\n\n\n<li><strong>\u5546\u54c1\u5173\u8054\uff1a<\/strong>&nbsp;\u54ea\u4e9b\u5546\u54c1\u7ecf\u5e38\u4e00\u8d77\u88ab\u8d2d\u4e70\uff08\u201c\u5564\u9152\u4e0e\u5c3f\u5e03\u201d\u6548\u5e94\uff09<\/li>\n<\/ul>\n\n\n\n<p><strong>\u3010\u81ea\u52a8\u751f\u6210\u6570\u636e\u96c6\u4e0e\u4ee3\u7801\u5b9e\u4f8b\u3011<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u751f\u6210\u5305\u542b\u8ba2\u5355\u3001\u5546\u54c1\u4fe1\u606f\u548c\u6210\u672c\u4ef7\u7684\u6a21\u62df\u6570\u636e\u96c6\u3002<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport numpy as np\nfrom datetime import datetime, timedelta\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# --- \u6570\u636e\u96c6\u751f\u6210 ---\nnp.random.seed(42)\n\ndef generate_product_sales_data(num_orders=5000, start_date='2023-01-01', end_date='2023-03-31'):\n    users = &#91;f'U{i:04d}' for i in range(500)]\n    \n    # \u6a21\u62df\u5546\u54c1\u4fe1\u606f (\u5305\u542b\u6210\u672c\u4ef7)\n    products_info = {}\n    product_categories = &#91;'Electronics', 'Apparel', 'Home', 'Books', 'Sports']\n    product_brands = &#91;'BrandA', 'BrandB', 'BrandC', 'BrandD', 'BrandE']\n    \n    for i in range(100): # 100\u4e2a\u5546\u54c1\n        pid = f'P{i:03d}'\n        category = np.random.choice(product_categories, p=&#91;0.25, 0.25, 0.2, 0.15, 0.15]) # \u6a21\u62df\u4e0d\u540c\u54c1\u7c7b\u70ed\u5ea6\n        brand = np.random.choice(product_brands)\n        price = round(np.random.uniform(20, 1000), 2)\n        cost_price = round(price * np.random.uniform(0.3, 0.8), 2) # \u6210\u672c\u4ef7\u662f\u552e\u4ef7\u768430%-80%\n        products_info&#91;pid] = {'category': category, 'brand': brand, 'price': price, 'cost_price': cost_price}\n        \n    product_ids = list(products_info.keys())\n\n    order_items_data = &#91;]\n    for i in range(num_orders):\n        order_id = f'ORD{i:05d}'\n        user_id = np.random.choice(users)\n        order_time = pd.to_datetime(start_date) + timedelta(seconds=np.random.randint(0, (pd.to_datetime(end_date) - pd.to_datetime(start_date)).total_seconds()))\n        \n        num_items_in_order = np.random.randint(1, 4) # \u6bcf\u4e2a\u8ba2\u53551-3\u4ef6\u5546\u54c1\n        for _ in range(num_items_in_order):\n            product_id = np.random.choice(product_ids)\n            quantity = np.random.randint(1, 3)\n            \n            # \u4ece products_info \u83b7\u53d6\u4ef7\u683c\u548c\u6210\u672c\u4ef7\n            price = products_info&#91;product_id]&#91;'price']\n            cost_price = products_info&#91;product_id]&#91;'cost_price']\n            category = products_info&#91;product_id]&#91;'category']\n            brand = products_info&#91;product_id]&#91;'brand']\n            \n            order_items_data.append(&#91;order_id, user_id, order_time, product_id, category, brand, price, cost_price, quantity])\n            \n    df_sales = pd.DataFrame(order_items_data, columns=&#91;'order_id', 'user_id', 'order_time', 'product_id', 'category', 'brand', 'price', 'cost_price', 'quantity'])\n    df_sales&#91;'order_time'] = pd.to_datetime(df_sales&#91;'order_time'])\n    df_sales&#91;'total_revenue'] = df_sales&#91;'price'] * df_sales&#91;'quantity']\n    df_sales&#91;'total_cost'] = df_sales&#91;'cost_price'] * df_sales&#91;'quantity']\n    df_sales&#91;'gross_profit'] = df_sales&#91;'total_revenue'] - df_sales&#91;'total_cost']\n    \n    return df_sales\n\ndf_sales_analysis = generate_product_sales_data(num_orders=5000)\nprint(\"--- \u5546\u54c1\u9500\u552e\u6570\u636e\u9884\u89c8 ---\")\nprint(df_sales_analysis.head())\n\n# --- \u5546\u54c1\u9500\u552e\u989d\u3001\u9500\u552e\u91cf\u3001\u6bdb\u5229\u7387\u8ba1\u7b97 ---\nprint(\"\\n--- \u5546\u54c1\u9500\u552e\u989d\u3001\u9500\u552e\u91cf\u3001\u6bdb\u5229\u7387\u8ba1\u7b97 ---\")\n\n# 1. \u603b\u9500\u552e\u989d\u3001\u603b\u9500\u91cf\u3001\u603b\u6bdb\u5229\ntotal_revenue = df_sales_analysis&#91;'total_revenue'].sum()\ntotal_quantity_sold = df_sales_analysis&#91;'quantity'].sum()\ntotal_gross_profit = df_sales_analysis&#91;'gross_profit'].sum()\noverall_gross_margin = (total_gross_profit \/ total_revenue) if total_revenue &gt; 0 else 0\n\nprint(f\"\u603b\u9500\u552e\u989d: {total_revenue:.2f}\")\nprint(f\"\u603b\u9500\u91cf: {total_quantity_sold}\")\nprint(f\"\u603b\u6bdb\u5229: {total_gross_profit:.2f}\")\nprint(f\"\u6574\u4f53\u6bdb\u5229\u7387: {overall_gross_margin:.2%}\")\n\n# 2. \u6309\u5546\u54c1\u7ef4\u5ea6\u8ba1\u7b97\nproduct_performance = df_sales_analysis.groupby('product_id').agg(\n    total_sales=('total_revenue', 'sum'),\n    total_quantity=('quantity', 'sum'),\n    total_profit=('gross_profit', 'sum'),\n    avg_price=('price', 'mean')\n).reset_index()\nproduct_performance&#91;'gross_margin'] = (product_performance&#91;'total_profit'] \/ product_performance&#91;'total_sales']).fillna(0)\n\nprint(\"\\n\u5546\u54c1\u7ef4\u5ea6\u9500\u552e\u8868\u73b0 (Top 5):\\n\", product_performance.sort_values(by='total_sales', ascending=False).head())\n\n# 3. \u6309\u54c1\u7c7b\u7ef4\u5ea6\u8ba1\u7b97\ncategory_performance = df_sales_analysis.groupby('category').agg(\n    total_sales=('total_revenue', 'sum'),\n    total_quantity=('quantity', 'sum'),\n    total_profit=('gross_profit', 'sum')\n).reset_index()\ncategory_performance&#91;'gross_margin'] = (category_performance&#91;'total_profit'] \/ category_performance&#91;'total_sales']).fillna(0)\n\nprint(\"\\n\u54c1\u7c7b\u7ef4\u5ea6\u9500\u552e\u8868\u73b0 (Top 3):\\n\", category_performance.sort_values(by='total_sales', ascending=False).head(3))\n\n# \u53ef\u89c6\u5316\u54c1\u7c7b\u9500\u552e\u989d\u8d21\u732e\nplt.figure(figsize=(10, 6))\nsns.barplot(x='category', y='total_sales', data=category_performance.sort_values(by='total_sales', ascending=False))\nplt.title('\u5404\u5546\u54c1\u7c7b\u522b\u9500\u552e\u989d\u8d21\u732e')\nplt.xlabel('\u5546\u54c1\u7c7b\u522b')\nplt.ylabel('\u9500\u552e\u989d')\nplt.show()\n\n# --- \u5546\u54c1\u5173\u8054\u5206\u6790 (Apriori\u7b97\u6cd5\u5165\u95e8) ---\nprint(\"\\n--- \u5546\u54c1\u5173\u8054\u5206\u6790 ---\")\n# \u76ee\u6807\uff1a\u53d1\u73b0\u54ea\u4e9b\u5546\u54c1\u7ecf\u5e38\u4e00\u8d77\u88ab\u8d2d\u4e70\n\n# 1. \u51c6\u5907\u6570\u636e\uff1a\u5c06\u6bcf\u4e2a\u8ba2\u5355\u7684\u5546\u54c1\u5217\u8868\u8f6c\u6362\u4e3a\u5217\u8868\norders_products = df_sales_analysis.groupby('order_id')&#91;'product_id'].apply(list).reset_index()\ntransactions = orders_products&#91;'product_id'].tolist()\nprint(\"\\n\u524d5\u4e2a\u8ba2\u5355\u7684\u5546\u54c1\u5217\u8868:\\n\", transactions&#91;:5])\n\n# 2. \u4f7f\u7528mlxtend\u5e93\u8fdb\u884cApriori\u7b97\u6cd5 (\u9700\u8981\u5b89\u88c5: pip install mlxtend)\nfrom mlxtend.preprocessing import TransactionEncoder\nfrom mlxtend.frequent_patterns import apriori, association_rules\n\n# \u5c06\u4ea4\u6613\u6570\u636e\u8f6c\u6362\u4e3aOne-Hot\u7f16\u7801\u683c\u5f0f\nte = TransactionEncoder()\nte_ary = te.fit(transactions).transform(transactions)\ndf_transactions = pd.DataFrame(te_ary, columns=te.columns_)\n\n# \u67e5\u627e\u9891\u7e41\u9879\u96c6 (\u652f\u6301\u5ea6 support)\n# support: \u67d0\u4e2a\u5546\u54c1\u7ec4\u5408\u5728\u6240\u6709\u8ba2\u5355\u4e2d\u51fa\u73b0\u7684\u9891\u7387\nfrequent_itemsets = apriori(df_transactions, min_support=0.01, use_colnames=True) # \u81f3\u5c11\u57281%\u7684\u8ba2\u5355\u4e2d\u51fa\u73b0\nprint(\"\\n\u9891\u7e41\u9879\u96c6 (Top 5):\\n\", frequent_itemsets.sort_values(by='support', ascending=False).head())\n\n# \u751f\u6210\u5173\u8054\u89c4\u5219 (\u7f6e\u4fe1\u5ea6 confidence, \u63d0\u5347\u5ea6 lift)\n# confidence(A-&gt;B): \u4e70\u4e86A\u5546\u54c1\u540e\uff0c\u518d\u4e70B\u5546\u54c1\u7684\u6982\u7387\n# lift(A-&gt;B): \u4e70\u4e86A\u5546\u54c1\u540e\uff0c\u4e70B\u5546\u54c1\u7684\u6982\u7387\u4e0e\u5355\u72ec\u4e70B\u5546\u54c1\u7684\u6982\u7387\u4e4b\u6bd4\u3002&gt;1\u8868\u793a\u6b63\u76f8\u5173\nrules = association_rules(frequent_itemsets, metric=\"lift\", min_threshold=1) # lift &gt; 1\u8868\u793a\u6709\u6b63\u76f8\u5173\nrules = rules.sort_values(by=&#91;'lift', 'confidence'], ascending=&#91;False, False])\n\nprint(\"\\n\u5173\u8054\u89c4\u5219 (Top 5):\\n\", rules.head())\n\n# \u3010\u8fd0\u8425\u7b56\u7565\u5efa\u8bae\u3011\nprint(\"\\n--- \u57fa\u4e8e\u5546\u54c1\u9500\u552e\u5206\u6790\u7684\u8fd0\u8425\u7b56\u7565\u5efa\u8bae ---\")\nprint(\"1. **\u4f18\u5316\u5546\u54c1\u7ed3\u6784:** \u6839\u636e\u54c1\u7c7b\u8d21\u732e\u8c03\u6574\u91c7\u8d2d\u548c\u63a8\u5e7f\u91cd\u5fc3\u3002\")\nprint(\"2. **\u6346\u7ed1\u9500\u552e\/\u4ea4\u53c9\u9500\u552e:** \u5229\u7528\u5173\u8054\u89c4\u5219\uff0c\u5c06\u7ecf\u5e38\u4e00\u8d77\u8d2d\u4e70\u7684\u5546\u54c1\u8fdb\u884c\u6346\u7ed1\u9500\u552e\u6216\u5728\u5546\u54c1\u8be6\u60c5\u9875\u63a8\u8350\u3002\")\nprint(\"3. **\u65b0\u54c1\u63a8\u5e7f:** \u7ed3\u5408\u7545\u9500\u54c1\u7c7b\u548c\u5173\u8054\u89c4\u5219\uff0c\u8bbe\u8ba1\u65b0\u54c1\u63a8\u5e7f\u65b9\u6848\u3002\")\nprint(\"4. **\u6ede\u9500\u54c1\u5904\u7406:** \u8bc6\u522b\u6ede\u9500\u54c1\uff08\u9500\u91cf\u4f4e\uff09\uff0c\u5206\u6790\u539f\u56e0\u5e76\u5236\u5b9a\u6e05\u4ed3\u7b56\u7565\u3002\")<\/code><\/pre>\n\n\n\n<p><strong>\u3010\u4e92\u52a8\u95ee\u7b54\u3011<\/strong><\/p>\n\n\n\n<ul>\n<li>\u6bdb\u5229\u7387\u5bf9\u7535\u5546\u8fd0\u8425\u51b3\u7b56\u6709\u4ec0\u4e48\u91cd\u8981\u610f\u4e49\uff1f<\/li>\n\n\n\n<li>\u5982\u4f55\u6839\u636e\u5546\u54c1\u9500\u552e\u6570\u636e\u8bc6\u522b\u51fa\u201c\u7206\u6b3e\u201d\u5546\u54c1\u548c\u201c\u6ede\u9500\u201d\u5546\u54c1\uff1f<\/li>\n\n\n\n<li>Apriori\u7b97\u6cd5\u4e2d\u7684\u201c\u652f\u6301\u5ea6\u201d\u3001\u201c\u7f6e\u4fe1\u5ea6\u201d\u3001\u201c\u63d0\u5347\u5ea6\u201d\u5206\u522b\u4ee3\u8868\u4ec0\u4e48\uff1f\u5b83\u4eec\u5728\u5546\u54c1\u5173\u8054\u5206\u6790\u4e2d\u6709\u4ec0\u4e48\u4f5c\u7528\uff1f<\/li>\n\n\n\n<li>\u5728\u7535\u5546\u573a\u666f\u4e2d\uff0c\u5546\u54c1\u5173\u8054\u89c4\u5219\u53ef\u4ee5\u5e94\u7528\u5728\u54ea\u4e9b\u5730\u65b9\uff1f\uff08\u4f8b\u5982\uff1a\u8d2d\u7269\u8f66\u63a8\u8350\u3001\u8be6\u60c5\u9875\u63a8\u8350\u3001\u5957\u9910\u7ec4\u5408\uff09<\/li>\n\n\n\n<li>\u5982\u679c\u9891\u7e41\u9879\u96c6\u592a\u591a\uff0c<code>min_support<\/code>&nbsp;\u5e94\u8be5\u5982\u4f55\u8c03\u6574\uff1f<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"62_%E5%BA%93%E5%AD%98%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BC%98%E5%8C%96\"><\/span><strong>6.2 \u5e93\u5b58\u7ba1\u7406\u4e0e\u4f18\u5316<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><strong>\u3010\u7406\u8bba\u8bb2\u89e3\u3011<\/strong><\/p>\n\n\n\n<p>\u5e93\u5b58\u7ba1\u7406\u662f\u7535\u5546\u6210\u672c\u63a7\u5236\u548c\u5ba2\u6237\u6ee1\u610f\u5ea6\u7684\u5173\u952e\u73af\u8282\u3002\u8fc7\u591a\u7684\u5e93\u5b58\u4f1a\u5360\u7528\u8d44\u91d1\u3001\u589e\u52a0\u4ed3\u50a8\u6210\u672c\uff0c\u8fc7\u5c11\u7684\u5e93\u5b58\u5219\u53ef\u80fd\u5bfc\u81f4\u7f3a\u8d27\uff0c\u5f71\u54cd\u9500\u552e\u548c\u7528\u6237\u4f53\u9a8c\u3002\u901a\u8fc7\u6570\u636e\u5206\u6790\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u79d1\u5b66\u5730\u9884\u6d4b\u9700\u6c42\u3001\u8bbe\u7f6e\u5b89\u5168\u5e93\u5b58\u3001\u8bc6\u522b\u6ede\u9500\u54c1\uff0c\u4ece\u800c\u4f18\u5316\u5e93\u5b58\u5468\u8f6c\u3002<\/p>\n\n\n\n<p><strong>\u6838\u5fc3\u6307\u6807\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u5e93\u5b58\u5468\u8f6c\u7387\uff1a<\/strong>&nbsp;\u8861\u91cf\u5e93\u5b58\u9500\u552e\u7684\u901f\u5ea6\u3002<\/li>\n\n\n\n<li><strong>\u5b89\u5168\u5e93\u5b58\uff1a<\/strong>&nbsp;\u4e3a\u5e94\u5bf9\u4e0d\u786e\u5b9a\u6027\uff08\u5982\u9700\u6c42\u6ce2\u52a8\u3001\u4f9b\u8d27\u5ef6\u8fdf\uff09\u800c\u989d\u5916\u50a8\u5907\u7684\u5e93\u5b58\u91cf\u3002<\/li>\n\n\n\n<li><strong>\u6ede\u9500\u7387\uff1a<\/strong>&nbsp;\u6ede\u9500\u5546\u54c1\u5360\u603b\u5546\u54c1\u6570\u7684\u6bd4\u4f8b\u3002<\/li>\n\n\n\n<li><strong>\u7f3a\u8d27\u7387\uff1a<\/strong>&nbsp;\u56e0\u7f3a\u8d27\u800c\u635f\u5931\u7684\u9500\u552e\u673a\u4f1a\u6bd4\u4f8b\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u3010\u81ea\u52a8\u751f\u6210\u6570\u636e\u96c6\u4e0e\u4ee3\u7801\u5b9e\u4f8b\u3011<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u751f\u6210\u5305\u542b\u5e93\u5b58\u3001\u9500\u552e\u5386\u53f2\u548c\u9884\u6d4b\u9700\u6c42\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport numpy as np\nfrom datetime import datetime, timedelta\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# --- \u6570\u636e\u96c6\u751f\u6210 ---\nnp.random.seed(42)\n\ndef generate_inventory_data(num_products=100, start_date='2023-01-01', end_date='2023-03-31'):\n    products_info = {}\n    product_categories = &#91;'Electronics', 'Apparel', 'Home', 'Books', 'Sports']\n    \n    inventory_data = &#91;]\n    \n    for i in range(num_products):\n        pid = f'P{i:03d}'\n        category = np.random.choice(product_categories)\n        initial_stock = np.random.randint(50, 500) # \u521d\u59cb\u5e93\u5b58\n        lead_time = np.random.randint(3, 15) # \u4f9b\u8d27\u5468\u671f\uff0c\u5929\n        std_demand = np.random.uniform(5, 20) # \u6bcf\u65e5\u9700\u6c42\u6807\u51c6\u5dee\n        \n        # \u6a21\u62df\u6bcf\u65e5\u9500\u552e\u6570\u636e\n        current_stock = initial_stock\n        daily_sales_data = &#91;]\n        current_date = pd.to_datetime(start_date)\n        while current_date &lt;= pd.to_datetime(end_date):\n            # \u6a21\u62df\u6bcf\u65e5\u9700\u6c42\u91cf (\u6b63\u6001\u5206\u5e03\uff0c\u6709\u6ce2\u52a8)\n            demand = max(0, int(np.random.normal(initial_stock \/ ((pd.to_datetime(end_date) - pd.to_datetime(start_date)).days \/ 20), std_demand))) # \u786e\u4fdd\u9700\u6c42\u91cf\u4e3a\u6b63\n            \n            # \u6a21\u62df\u5b9e\u9645\u9500\u552e (\u4e0d\u80fd\u8d85\u8fc7\u5e93\u5b58)\n            sales = min(demand, current_stock)\n            current_stock -= sales\n            \n            daily_sales_data.append(&#91;pid, current_date, sales, current_stock])\n            \n            # \u6a21\u62df\u8865\u8d27 (\u5f53\u5e93\u5b58\u4f4e\u4e8e\u67d0\u4e2a\u9608\u503c\u65f6)\n            if current_stock &lt; 0.2 * initial_stock and np.random.rand() &lt; 0.5: # 20%\u521d\u59cb\u5e93\u5b58\u4ee5\u4e0b\u4e1450%\u6982\u7387\u8865\u8d27\n                replenishment_quantity = np.random.randint(50, 200)\n                current_stock += replenishment_quantity\n            \n            current_date += timedelta(days=1)\n        \n        # \u5c06\u6bcf\u65e5\u9500\u552e\u6570\u636e\u6dfb\u52a0\u5230\u603b\u5e93\u5b58\u6570\u636e\u4e2d\n        for row in daily_sales_data:\n            inventory_data.append(&#91;row&#91;0], category, products_info.get(row&#91;0], {'price': 0}).get('price'), initial_stock, lead_time, std_demand, row&#91;1], row&#91;2], row&#91;3]])\n\n    df_inventory = pd.DataFrame(inventory_data, columns=&#91;'product_id', 'category', 'price', 'initial_stock', 'lead_time', 'std_demand', 'date', 'daily_sales', 'current_stock'])\n    df_inventory&#91;'date'] = pd.to_datetime(df_inventory&#91;'date'])\n    \n    return df_inventory\n\ndf_inventory_analysis = generate_inventory_data(num_products=50)\nprint(\"--- \u5e93\u5b58\u6570\u636e\u9884\u89c8 ---\")\nprint(df_inventory_analysis.head())\n\n# --- \u5b89\u5168\u5e93\u5b58\u91cf\u8ba1\u7b97 ---\nprint(\"\\n--- \u5b89\u5168\u5e93\u5b58\u91cf\u8ba1\u7b97 ---\")\n\n# \u5047\u8bbe\u6211\u4eec\u5173\u6ce8\u8fc7\u53bb30\u5929\u7684\u5e73\u5747\u65e5\u9500\u91cf\u548c\u6807\u51c6\u5dee\nlookback_days = 30\ndf_inventory_analysis&#91;'rolling_avg_sales'] = df_inventory_analysis.groupby('product_id')&#91;'daily_sales'].transform(lambda x: x.rolling(window=lookback_days).mean())\ndf_inventory_analysis&#91;'rolling_std_sales'] = df_inventory_analysis.groupby('product_id')&#91;'daily_sales'].transform(lambda x: x.rolling(window=lookback_days).std())\n\n# \u4ec5\u4fdd\u7559\u6700\u8fd1\u7684\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\nlatest_inventory_data = df_inventory_analysis.sort_values(by='date').groupby('product_id').tail(1).copy()\n\n# \u5b89\u5168\u7cfb\u6570 Z (\u901a\u5e38\u53d61.65\u4ee3\u886895%\u670d\u52a1\u6c34\u5e73\uff0c1.96\u4ee3\u886897.5%\u670d\u52a1\u6c34\u5e73)\nZ = 1.65 # 95%\u670d\u52a1\u6c34\u5e73\n\n# \u5b89\u5168\u5e93\u5b58\u516c\u5f0f: \u5b89\u5168\u5e93\u5b58 = Z * (\u65e5\u9700\u6c42\u6807\u51c6\u5dee) * sqrt(\u4f9b\u8d27\u5468\u671f)\nlatest_inventory_data&#91;'safety_stock'] = (Z * latest_inventory_data&#91;'rolling_std_sales'] * np.sqrt(latest_inventory_data&#91;'lead_time'])).fillna(0).astype(int)\n\n# \u8ba2\u8d27\u70b9\u516c\u5f0f: \u8ba2\u8d27\u70b9 = (\u5e73\u5747\u65e5\u9700\u6c42 * \u4f9b\u8d27\u5468\u671f) + \u5b89\u5168\u5e93\u5b58\nlatest_inventory_data&#91;'reorder_point'] = (latest_inventory_data&#91;'rolling_avg_sales'] * latest_inventory_data&#91;'lead_time'] + latest_inventory_data&#91;'safety_stock']).fillna(0).astype(int)\n\nprint(\"\\n\u5404\u5546\u54c1\u7684\u5b89\u5168\u5e93\u5b58\u4e0e\u8ba2\u8d27\u70b9:\\n\", latest_inventory_data&#91;&#91;'product_id', 'rolling_avg_sales', 'rolling_std_sales', 'lead_time', 'safety_stock', 'reorder_point', 'current_stock']].head())\n\n# --- \u6ede\u9500\u5546\u54c1\u8bc6\u522b\u4e0e\u5904\u7406 ---\nprint(\"\\n--- \u6ede\u9500\u5546\u54c1\u8bc6\u522b\u4e0e\u5904\u7406 ---\")\n\n# \u6ede\u9500\u5b9a\u4e49\uff1a\u4f8b\u5982\uff0c\u8fc7\u53bb90\u5929\u5185\u9500\u91cf\u4e3a0\u7684\u5546\u54c1\ndf_sales_last_90_days = df_inventory_analysis&#91;df_inventory_analysis&#91;'date'] &gt;= (current_date - timedelta(days=90))]\nproduct_sales_last_90_days = df_sales_last_90_days.groupby('product_id')&#91;'daily_sales'].sum().reset_index(name='total_sales_90_days')\n\n# \u627e\u51fa\u6ca1\u6709\u9500\u552e\u8bb0\u5f55\u7684\u5546\u54c1\nall_products = df_inventory_analysis&#91;'product_id'].unique()\nproducts_with_sales = product_sales_last_90_days&#91;product_sales_last_90_days&#91;'total_sales_90_days'] &gt; 0]&#91;'product_id']\ndead_stock_products = pd.DataFrame({'product_id': list(set(all_products) - set(products_with_sales))})\n\nprint(\"\\n\u6ede\u9500\u5546\u54c1ID:\\n\", dead_stock_products)\n\n# \u3010\u8fd0\u8425\u7b56\u7565\u5efa\u8bae\u3011\nprint(\"\\n--- \u57fa\u4e8e\u5e93\u5b58\u5206\u6790\u7684\u8fd0\u8425\u7b56\u7565\u5efa\u8bae ---\")\nprint(\"1. **\u52a8\u6001\u8c03\u6574\u5e93\u5b58:** \u6839\u636e\u5b89\u5168\u5e93\u5b58\u548c\u8ba2\u8d27\u70b9\uff0c\u53ca\u65f6\u8fdb\u884c\u8865\u8d27\uff0c\u907f\u514d\u7f3a\u8d27\u6216\u79ef\u538b\u3002\")\nprint(\"2. **\u6ede\u9500\u54c1\u6e05\u4ed3:** \u5bf9\u6ede\u9500\u5546\u54c1\u8fdb\u884c\u4fc3\u9500\u3001\u6346\u7ed1\u9500\u552e\u6216\u964d\u4ef7\u6e05\u4ed3\uff0c\u51cf\u5c11\u5e93\u5b58\u6210\u672c\u3002\")\nprint(\"3. **\u7f3a\u8d27\u9884\u8b66:** \u76d1\u63a7\u5f53\u524d\u5e93\u5b58\u4e0e\u8ba2\u8d27\u70b9\u7684\u5173\u7cfb\uff0c\u63d0\u524d\u9884\u8b66\u5e76\u7d27\u6025\u8865\u8d27\u3002\")<\/code><\/pre>\n\n\n\n<p><strong>\u3010\u4e92\u52a8\u95ee\u7b54\u3011<\/strong><\/p>\n\n\n\n<ul>\n<li>\u5b89\u5168\u5e93\u5b58\u548c\u8ba2\u8d27\u70b9\u5728\u5e93\u5b58\u7ba1\u7406\u4e2d\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\uff1f<\/li>\n\n\n\n<li>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u5b89\u5168\u7cfb\u6570Z\uff1f\u5b83\u4e0e\u670d\u52a1\u6c34\u5e73\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f<\/li>\n\n\n\n<li>\u9664\u4e86\u201c\u8fc7\u53bb90\u5929\u9500\u91cf\u4e3a0\u201d\uff0c\u4f60\u8fd8\u80fd\u60f3\u5230\u54ea\u4e9b\u65b9\u6cd5\u6765\u5b9a\u4e49\u201c\u6ede\u9500\u5546\u54c1\u201d\uff1f<\/li>\n\n\n\n<li>\u5982\u4f55\u8bc4\u4f30\u5e93\u5b58\u7ba1\u7406\u7684\u6548\u679c\uff1f\uff08\u4f8b\u5982\uff1a\u5e93\u5b58\u5468\u8f6c\u7387\u3001\u7f3a\u8d27\u7387\uff09<\/li>\n\n\n\n<li>\u5728\u5b9e\u9645\u7535\u5546\u8fd0\u8425\u4e2d\uff0c\u5e93\u5b58\u6570\u636e\u8fd8\u4f1a\u53d7\u5230\u54ea\u4e9b\u56e0\u7d20\u7684\u5f71\u54cd\uff1f\u5982\u4f55\u5c06\u8fd9\u4e9b\u56e0\u7d20\u7eb3\u5165\u5206\u6790\uff1f<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"63_%E4%BB%B7%E6%A0%BC%E6%95%8F%E6%84%9F%E6%80%A7%E5%88%86%E6%9E%90\"><\/span><strong>6.3 \u4ef7\u683c\u654f\u611f\u6027\u5206\u6790<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><strong>\u3010\u7406\u8bba\u8bb2\u89e3\u3011<\/strong><\/p>\n\n\n\n<p>\u4ef7\u683c\u654f\u611f\u6027\u5206\u6790\u65e8\u5728\u4e86\u89e3\u6d88\u8d39\u8005\u5bf9\u5546\u54c1\u4ef7\u683c\u53d8\u5316\u7684\u53cd\u5e94\u3002\u901a\u8fc7\u5206\u6790\u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u9500\u552e\u8868\u73b0\uff0c\u4ee5\u53ca\u4fc3\u9500\u6d3b\u52a8\u5bf9\u9500\u91cf\u7684\u5f71\u54cd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5236\u5b9a\u66f4\u79d1\u5b66\u7684\u5b9a\u4ef7\u7b56\u7565\u548c\u4fc3\u9500\u65b9\u6848\u3002<\/p>\n\n\n\n<p><strong>\u6838\u5fc3\u601d\u60f3\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u9700\u6c42\u5f39\u6027\uff1a<\/strong>&nbsp;\u5546\u54c1\u4ef7\u683c\u53d8\u5316\u767e\u5206\u6bd4\u4e0e\u9700\u6c42\u91cf\u53d8\u5316\u767e\u5206\u6bd4\u7684\u6bd4\u7387\u3002<\/li>\n\n\n\n<li><strong>\u4ef7\u683c\u533a\u95f4\uff1a<\/strong>&nbsp;\u4e86\u89e3\u5728\u4e0d\u540c\u4ef7\u683c\u70b9\u4e0b\uff0c\u5546\u54c1\u7684\u9500\u552e\u60c5\u51b5\u3002<\/li>\n\n\n\n<li><strong>\u4fc3\u9500\u6548\u679c\uff1a<\/strong>&nbsp;\u8bc4\u4f30\u4ef7\u683c\u6298\u6263\u3001\u6ee1\u51cf\u7b49\u4fc3\u9500\u624b\u6bb5\u5bf9\u9500\u552e\u7684\u523a\u6fc0\u4f5c\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u3010\u81ea\u52a8\u751f\u6210\u6570\u636e\u96c6\u4e0e\u4ee3\u7801\u5b9e\u4f8b\u3011<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u751f\u6210\u5305\u542b\u5546\u54c1\u4ef7\u683c\u3001\u9500\u552e\u91cf\u4ee5\u53ca\u662f\u5426\u8fdb\u884c\u4fc3\u9500\u7684\u6a21\u62df\u6570\u636e\u3002<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# --- \u6570\u636e\u96c6\u751f\u6210 ---\nnp.random.seed(42)\n\ndef generate_price_sensitivity_data(num_products=50, num_days=90):\n    data = &#91;]\n    \n    for i in range(num_products):\n        pid = f'P{i:03d}'\n        base_price = round(np.random.uniform(50, 500), 2)\n        \n        for day in range(num_days):\n            current_date = pd.to_datetime('2023-01-01') + timedelta(days=day)\n            \n            # \u6a21\u62df\u4ef7\u683c\u6ce2\u52a8 (\u5728\u57fa\u7840\u4ef7\u683c\u4e0a\u4e0b\u6d6e\u52a8)\n            price_factor = np.random.uniform(0.9, 1.1)\n            current_price = round(base_price * price_factor, 2)\n            \n            # \u6a21\u62df\u4fc3\u9500\u6d3b\u52a8 (\u968f\u673a\u8fdb\u884c\u4fc3\u9500)\n            is_promotion = np.random.rand() &lt; 0.2 # 20%\u7684\u6982\u7387\u6709\u4fc3\u9500\n            if is_promotion:\n                promotion_discount = np.random.uniform(0.7, 0.9) # 7-9\u6298\n                current_price = round(current_price * promotion_discount, 2)\n            \n            # \u6a21\u62df\u9500\u91cf (\u4ef7\u683c\u8d8a\u4f4e\uff0c\u9500\u91cf\u8d8a\u9ad8\uff1b\u6709\u4fc3\u9500\u9500\u91cf\u4e5f\u9ad8)\n            # \u57fa\u7840\u9500\u91cf\u53d7\u4ef7\u683c\u5f71\u54cd\n            base_demand = 1000 \/ current_price + np.random.normal(0, 5)\n            if is_promotion:\n                base_demand *= np.random.uniform(1.2, 1.5) # \u4fc3\u9500\u589e\u52a0\u9500\u91cf\n            \n            sales_volume = max(0, int(base_demand + np.random.normal(0, 10))) # \u589e\u52a0\u968f\u673a\u6ce2\u52a8\n            \n            data.append(&#91;pid, current_date, base_price, current_price, is_promotion, sales_volume])\n            \n    df_price_sensitivity = pd.DataFrame(data, columns=&#91;'product_id', 'date', 'base_price', 'current_price', 'is_promotion', 'sales_volume'])\n    return df_price_sensitivity\n\ndf_price_analysis = generate_price_sensitivity_data(num_products=50)\nprint(\"--- \u4ef7\u683c\u654f\u611f\u6027\u6570\u636e\u9884\u89c8 ---\")\nprint(df_price_analysis.head())\n\n# --- \u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u9500\u552e\u8868\u73b0 ---\nprint(\"\\n--- \u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u9500\u552e\u8868\u73b0 ---\")\n\n# 1. \u5bf9\u4ef7\u683c\u8fdb\u884c\u5206\u7bb1\nprice_bins = &#91;0, 50, 100, 200, 300, 500, 1000]\nprice_labels = &#91;'0-50', '51-100', '101-200', '201-300', '301-500', '501-1000']\ndf_price_analysis&#91;'price_range'] = pd.cut(df_price_analysis&#91;'current_price'], bins=price_bins, labels=price_labels, right=True)\n\n# 2. \u7edf\u8ba1\u6bcf\u4e2a\u4ef7\u683c\u533a\u95f4\u7684\u5e73\u5747\u9500\u91cf\nsales_by_price_range = df_price_analysis.groupby('price_range')&#91;'sales_volume'].mean().reset_index()\nprint(\"\\n\u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u5e73\u5747\u9500\u91cf:\\n\", sales_by_price_range)\n\n# \u53ef\u89c6\u5316\u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u5e73\u5747\u9500\u91cf\nplt.figure(figsize=(10, 6))\nsns.barplot(x='price_range', y='sales_volume', data=sales_by_price_range, palette='coolwarm')\nplt.title('\u4e0d\u540c\u4ef7\u683c\u533a\u95f4\u7684\u5546\u54c1\u5e73\u5747\u9500\u91cf')\nplt.xlabel('\u4ef7\u683c\u533a\u95f4 (\u5143)')\nplt.ylabel('\u5e73\u5747\u9500\u91cf')\nplt.xticks(rotation=45, ha='right')\nplt.show()\n\n# --- \u4fc3\u9500\u5bf9\u9500\u91cf\u7684\u5f71\u54cd ---\nprint(\"\\n--- \u4fc3\u9500\u5bf9\u9500\u91cf\u7684\u5f71\u54cd ---\")\n\n# \u6bd4\u8f83\u6709\u4fc3\u9500\u548c\u65e0\u4fc3\u9500\u65f6\u7684\u5e73\u5747\u9500\u91cf\npromotion_effect = df_price_analysis.groupby('is_promotion')&#91;'sales_volume'].mean().reset_index()\npromotion_effect&#91;'is_promotion'] = promotion_effect&#91;'is_promotion'].map({True: '\u6709\u4fc3\u9500', False: '\u65e0\u4fc3\u9500'})\nprint(\"\\n\u4fc3\u9500\u5bf9\u5e73\u5747\u9500\u91cf\u7684\u5f71\u54cd:\\n\", promotion_effect)\n\n# \u53ef\u89c6\u5316\u4fc3\u9500\u6548\u679c\nplt.figure(figsize=(6, 5))\nsns.barplot(x='is_promotion', y='sales_volume', data=promotion_effect, palette='pastel')\nplt.title('\u4fc3\u9500\u5bf9\u9500\u91cf\u7684\u5f71\u54cd')\nplt.xlabel('\u662f\u5426\u4fc3\u9500')\nplt.ylabel('\u5e73\u5747\u9500\u91cf')\nplt.show()\n\n# \u66f4\u7cbe\u7ec6\u7684\u5206\u6790\uff1a\u6bd4\u8f83\u4fc3\u9500\u524d\u540e\u7684\u9500\u91cf\u53d8\u5316\n# \u9009\u53d6\u4e00\u4e2a\u5546\u54c1\u8fdb\u884c\u89c2\u5bdf\nproduct_to_analyze = np.random.choice(df_price_analysis&#91;'product_id'].unique())\ndf_single_product = df_price_analysis&#91;df_price_analysis&#91;'product_id'] == product_to_analyze].sort_values(by='date')\n\nplt.figure(figsize=(12, 6))\nsns.lineplot(x='date', y='sales_volume', data=df_single_product, label='\u9500\u91cf')\nsns.lineplot(x='date', y='current_price', data=df_single_product, label='\u4ef7\u683c', color='red', linestyle='--')\n# \u6807\u8bb0\u4fc3\u9500\u65e5\u671f\nfor index, row in df_single_product&#91;df_single_product&#91;'is_promotion']].iterrows():\n    plt.axvline(x=row&#91;'date'], color='gray', linestyle=':', alpha=0.7)\nplt.title(f'\u5546\u54c1 {product_to_analyze} \u4ef7\u683c\u4e0e\u9500\u91cf\u8d8b\u52bf (\u865a\u7ebf\u4e3a\u4fc3\u9500\u65e5)')\nplt.xlabel('\u65e5\u671f')\nplt.ylabel('\u9500\u91cf \/ \u4ef7\u683c')\nplt.legend()\nplt.show()\n\n# \u3010\u8fd0\u8425\u7b56\u7565\u5efa\u8bae\u3011\nprint(\"\\n--- \u57fa\u4e8e\u4ef7\u683c\u654f\u611f\u6027\u5206\u6790\u7684\u8fd0\u8425\u7b56\u7565\u5efa\u8bae ---\")\nprint(\"1. **\u5b9a\u4ef7\u7b56\u7565\u4f18\u5316:** \u6839\u636e\u4ef7\u683c\u533a\u95f4\u548c\u9500\u91cf\u5173\u7cfb\uff0c\u627e\u5230\u6700\u4f18\u4ef7\u683c\u70b9\uff0c\u6216\u8005\u9488\u5bf9\u4e0d\u540c\u4ef7\u683c\u654f\u611f\u5ea6\u7684\u7528\u6237\u7fa4\u4f53\u8bbe\u5b9a\u4e0d\u540c\u4ef7\u683c\u3002\")\nprint(\"2. **\u4fc3\u9500\u6548\u679c\u8bc4\u4f30:** \u6301\u7eed\u76d1\u6d4b\u4fc3\u9500\u6d3b\u52a8\u5bf9\u9500\u91cf\u7684\u5b9e\u9645\u5f71\u54cd\uff0c\u4f18\u5316\u6298\u6263\u529b\u5ea6\u548c\u4fc3\u9500\u65f6\u673a\u3002\")\nprint(\"3. **\u5dee\u5f02\u5316\u5b9a\u4ef7:** \u5bf9\u4e8e\u4ef7\u683c\u654f\u611f\u5ea6\u4f4e\u7684\u5546\u54c1\uff0c\u53ef\u4ee5\u8003\u8651\u63d0\u4ef7\uff1b\u5bf9\u4e8e\u4ef7\u683c\u654f\u611f\u5ea6\u9ad8\u7684\u5546\u54c1\uff0c\u5219\u9700\u8c28\u614e\u5b9a\u4ef7\u3002\")<\/code><\/pre>\n\n\n\n<p><strong>\u3010\u4e92\u52a8\u95ee\u7b54\u3011<\/strong><\/p>\n\n\n\n<ul>\n<li>\u5982\u4f55\u6839\u636e\u4ef7\u683c\u654f\u611f\u6027\u5206\u6790\u7684\u7ed3\u679c\uff0c\u4e3a\u65b0\u54c1\u5b9a\u4ef7\u63d0\u4f9b\u5efa\u8bae\uff1f<\/li>\n\n\n\n<li>\u9664\u4e86\u6211\u4eec\u5206\u6790\u7684\u8fd9\u4e9b\uff0c\u8fd8\u6709\u54ea\u4e9b\u56e0\u7d20\u4f1a\u5f71\u54cd\u5546\u54c1\u7684\u9500\u91cf\uff1f\uff08\u63d0\u793a\uff1a\u54c1\u724c\u3001\u8bc4\u8bba\u3001\u5b63\u8282\u3001\u7ade\u54c1\u7b49\uff09<\/li>\n\n\n\n<li>\u5728\u8fdb\u884c\u4fc3\u9500\u6548\u679c\u8bc4\u4f30\u65f6\uff0c\u9664\u4e86\u5e73\u5747\u9500\u91cf\uff0c\u8fd8\u9700\u8981\u8003\u8651\u54ea\u4e9b\u6307\u6807\uff1f\uff08\u4f8b\u5982\uff1a\u6bdb\u5229\u3001\u7528\u6237\u8f6c\u5316\u7387\uff09<\/li>\n\n\n\n<li>\u5982\u4f55\u8bbe\u8ba1\u4e00\u4e2aA\/B\u6d4b\u8bd5\u6765\u9a8c\u8bc1\u65b0\u7684\u5b9a\u4ef7\u7b56\u7565\u662f\u5426\u6709\u6548\uff1f<\/li>\n\n\n\n<li>\u5982\u679c\u4e00\u4e2a\u5546\u54c1\u7684\u4ef7\u683c\u53d8\u52a8\u5f88\u5c0f\uff0c\u4f46\u9500\u91cf\u53d8\u5316\u5f88\u5927\uff0c\u8bf4\u660e\u5b83\u7684\u4ef7\u683c\u654f\u611f\u5ea6\u662f\u9ad8\u8fd8\u662f\u4f4e\uff1f<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>6.1 \u5546\u54c1\u9500\u552e\u5206\u6790 \u3010\u7406\u8bba\u8bb2\u89e3\u3011 \u5546\u54c1\u9500\u552e\u5206\u6790\u662f\u7535\u5546\u8fd0\u8425\u7684\u6838\u5fc3\u3002\u901a\u8fc7\u5206\u6790\u5546\u54c1\u7684\u9500\u552e\u989d\u3001\u9500\u91cf\u3001\u6bdb\u5229\u7387&hellip; <a href=\"http:\/\/viplao.com\/index.php\/2025\/10\/18\/%e3%80%90%e8%bf%90%e8%90%a5%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90-%e8%bf%9b%e9%98%b6%e7%af%87%e3%80%91-%e5%95%86%e5%93%81%e4%b8%8e%e5%ba%93%e5%ad%98%e5%88%86%e6%9e%90\/\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u3010\u8fd0\u8425\u6570\u636e\u5206\u6790-\u8fdb\u9636\u7bc7\u3011 \u5546\u54c1\u4e0e\u5e93\u5b58\u5206\u6790<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[28],"views":708,"_links":{"self":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4077"}],"collection":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/comments?post=4077"}],"version-history":[{"count":2,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4077\/revisions"}],"predecessor-version":[{"id":4100,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/4077\/revisions\/4100"}],"wp:attachment":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/media?parent=4077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/categories?post=4077"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/tags?post=4077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}