{
"cells": [
{
"cell_type": "markdown",
"id": "54c4935b-859f-4508-b0ca-f5129feb781c",
"metadata": {},
"source": [
"
客户购物记录关联规则挖掘"
]
},
{
"cell_type": "markdown",
"id": "48db5e80-cb0e-4c6e-a3df-399ebeb1a409",
"metadata": {},
"source": [
"## 1. 导入所需的库和数据集"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5d60a947-5b5a-4624-a3a5-0c4efa10af37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Looking in indexes: https://mirrors.aliyun.com/pypi/simple/\n",
"Requirement already satisfied: mlxtend in /usr/local/anaconda3/lib/python3.9/site-packages (0.20.0)\n",
"Requirement already satisfied: numpy>=1.16.2 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (1.20.3)\n",
"Requirement already satisfied: setuptools in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (61.2.0)\n",
"Requirement already satisfied: matplotlib>=3.0.0 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (3.4.3)\n",
"Requirement already satisfied: scipy>=1.2.1 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (1.7.1)\n",
"Requirement already satisfied: scikit-learn>=1.0.2 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (1.1.1)\n",
"Requirement already satisfied: joblib>=0.13.2 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (1.1.0)\n",
"Requirement already satisfied: pandas>=0.24.2 in /usr/local/anaconda3/lib/python3.9/site-packages (from mlxtend) (1.3.4)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/anaconda3/lib/python3.9/site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/anaconda3/lib/python3.9/site-packages (from matplotlib>=3.0.0->mlxtend) (1.3.1)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /usr/local/anaconda3/lib/python3.9/site-packages (from matplotlib>=3.0.0->mlxtend) (2.8.2)\n",
"Requirement already satisfied: pillow>=6.2.0 in /usr/local/anaconda3/lib/python3.9/site-packages (from matplotlib>=3.0.0->mlxtend) (8.4.0)\n",
"Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/anaconda3/lib/python3.9/site-packages (from matplotlib>=3.0.0->mlxtend) (3.0.4)\n",
"Requirement already satisfied: pytz>=2017.3 in /usr/local/anaconda3/lib/python3.9/site-packages (from pandas>=0.24.2->mlxtend) (2021.3)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/anaconda3/lib/python3.9/site-packages (from scikit-learn>=1.0.2->mlxtend) (2.2.0)\n",
"Requirement already satisfied: six in /usr/local/anaconda3/lib/python3.9/site-packages (from cycler>=0.10->matplotlib>=3.0.0->mlxtend) (1.16.0)\n",
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.\n",
"You should consider upgrading via the '/usr/local/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
],
"source": [
"# 安装机器学习扩展库mlxtend\n",
"! pip install mlxtend"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d7aedf0f-73e6-45c1-b961-099c3249d495",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from mlxtend.frequent_patterns import apriori, association_rules"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "22a2eba2-8f34-4481-983a-07209018e031",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" products | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" MILK,BREAD,BISCUIT | \n",
"
\n",
" \n",
" 1 | \n",
" BREAD,MILK,BISCUIT,CORNFLAKES | \n",
"
\n",
" \n",
" 2 | \n",
" BREAD,TEA,BOURNVITA | \n",
"
\n",
" \n",
" 3 | \n",
" JAM,MAGGI,BREAD,MILK | \n",
"
\n",
" \n",
" 4 | \n",
" MAGGI,TEA,BISCUIT | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" products\n",
"0 MILK,BREAD,BISCUIT\n",
"1 BREAD,MILK,BISCUIT,CORNFLAKES\n",
"2 BREAD,TEA,BOURNVITA\n",
"3 JAM,MAGGI,BREAD,MILK\n",
"4 MAGGI,TEA,BISCUIT"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 使用pandas读取并查看数据集\n",
"df = pd.read_csv('./data/GroceryStoreDataSet.csv', names = ['products'], sep = ',')\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c786d38a-7538-417d-887b-083eaec8e8ea",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(20, 1)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "markdown",
"id": "a0cfbcf1-d5ac-4adb-b6f8-b94d735f4f71",
"metadata": {},
"source": [
"## 2. 对数据集进行格式转换"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a80a3ac0-8863-46dd-9029-18b4239ec94f",
"metadata": {},
"outputs": [],
"source": [
"# 将商品交易记录转化为嵌套列表\n",
"data = list(df[\"products\"].apply(lambda x:x.split(\",\") ))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "21324126-cccc-47bd-a290-3c92a3f2d318",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[['MILK', 'BREAD', 'BISCUIT'],\n",
" ['BREAD', 'MILK', 'BISCUIT', 'CORNFLAKES'],\n",
" ['BREAD', 'TEA', 'BOURNVITA'],\n",
" ['JAM', 'MAGGI', 'BREAD', 'MILK'],\n",
" ['MAGGI', 'TEA', 'BISCUIT'],\n",
" ['BREAD', 'TEA', 'BOURNVITA'],\n",
" ['MAGGI', 'TEA', 'CORNFLAKES'],\n",
" ['MAGGI', 'BREAD', 'TEA', 'BISCUIT'],\n",
" ['JAM', 'MAGGI', 'BREAD', 'TEA'],\n",
" ['BREAD', 'MILK'],\n",
" ['COFFEE', 'COCK', 'BISCUIT', 'CORNFLAKES'],\n",
" ['COFFEE', 'COCK', 'BISCUIT', 'CORNFLAKES'],\n",
" ['COFFEE', 'SUGER', 'BOURNVITA'],\n",
" ['BREAD', 'COFFEE', 'COCK'],\n",
" ['BREAD', 'SUGER', 'BISCUIT'],\n",
" ['COFFEE', 'SUGER', 'CORNFLAKES'],\n",
" ['BREAD', 'SUGER', 'BOURNVITA'],\n",
" ['BREAD', 'COFFEE', 'SUGER'],\n",
" ['BREAD', 'COFFEE', 'SUGER'],\n",
" ['TEA', 'MILK', 'COFFEE', 'CORNFLAKES']]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "markdown",
"id": "e029b519-dcda-4bdd-8aa0-7c2841dd43ab",
"metadata": {},
"source": [
"使用`TransactionEncoder`,将列表转换为One-Hot编码的布尔列表,每条交易记录中,True表示购买某商品,False表示未购买某商品"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a4a1ceba-c5ce-4e6d-ab1d-0e91cc966677",
"metadata": {},
"outputs": [],
"source": [
"from mlxtend.preprocessing import TransactionEncoder\n",
"a = TransactionEncoder()\n",
"a_data = a.fit(data).transform(data)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "70645bc8-22dc-45bb-8b3f-7a9030589768",
"metadata": {},
"outputs": [],
"source": [
"# a_data是值为True或False的布尔数组\n",
"# a_data"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "29e982b9-cf78-4681-9a35-210b6413a11b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" BISCUIT | \n",
" BOURNVITA | \n",
" BREAD | \n",
" COCK | \n",
" COFFEE | \n",
" CORNFLAKES | \n",
" JAM | \n",
" MAGGI | \n",
" MILK | \n",
" SUGER | \n",
" TEA | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 1 | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 2 | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 3 | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 4 | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 5 | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 6 | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 7 | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 8 | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
" 9 | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 10 | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 11 | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 12 | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 13 | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
"
\n",
" \n",
" 14 | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 15 | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 16 | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 17 | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 18 | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" True | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
"
\n",
" \n",
" 19 | \n",
" False | \n",
" False | \n",
" False | \n",
" False | \n",
" True | \n",
" True | \n",
" False | \n",
" False | \n",
" True | \n",
" False | \n",
" True | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" BISCUIT BOURNVITA BREAD COCK COFFEE CORNFLAKES JAM MAGGI MILK \\\n",
"0 True False True False False False False False True \n",
"1 True False True False False True False False True \n",
"2 False True True False False False False False False \n",
"3 False False True False False False True True True \n",
"4 True False False False False False False True False \n",
"5 False True True False False False False False False \n",
"6 False False False False False True False True False \n",
"7 True False True False False False False True False \n",
"8 False False True False False False True True False \n",
"9 False False True False False False False False True \n",
"10 True False False True True True False False False \n",
"11 True False False True True True False False False \n",
"12 False True False False True False False False False \n",
"13 False False True True True False False False False \n",
"14 True False True False False False False False False \n",
"15 False False False False True True False False False \n",
"16 False True True False False False False False False \n",
"17 False False True False True False False False False \n",
"18 False False True False True False False False False \n",
"19 False False False False True True False False True \n",
"\n",
" SUGER TEA \n",
"0 False False \n",
"1 False False \n",
"2 False True \n",
"3 False False \n",
"4 False True \n",
"5 False True \n",
"6 False True \n",
"7 False True \n",
"8 False True \n",
"9 False False \n",
"10 False False \n",
"11 False False \n",
"12 True False \n",
"13 False False \n",
"14 True False \n",
"15 True False \n",
"16 True False \n",
"17 True False \n",
"18 True False \n",
"19 False True "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.DataFrame(a_data,columns=a.columns_)\n",
"df"
]
},
{
"cell_type": "markdown",
"id": "f92ed288-c0b0-4e6d-8b70-89c70e876bff",
"metadata": {},
"source": [
"## 3. 应用Apriori算法"
]
},
{
"cell_type": "markdown",
"id": "3614d735-23d0-4ed4-8a49-b98937ba66c3",
"metadata": {},
"source": [
"`mlxtend`包中Apriori模型的所有参数均可调节,可使用`help`函数查看`apriori`模型的用法和参数。"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "b0c224e6-2829-450b-a237-a3d6a90f6337",
"metadata": {},
"outputs": [],
"source": [
"# help(apriori)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "503fb28f-35a4-4e4b-be81-d62dbf4e1899",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing 42 combinations | Sampling itemset size 3\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" support | \n",
" itemsets | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0.35 | \n",
" (BISCUIT) | \n",
"
\n",
" \n",
" 1 | \n",
" 0.20 | \n",
" (BOURNVITA) | \n",
"
\n",
" \n",
" 2 | \n",
" 0.65 | \n",
" (BREAD) | \n",
"
\n",
" \n",
" 3 | \n",
" 0.40 | \n",
" (COFFEE) | \n",
"
\n",
" \n",
" 4 | \n",
" 0.30 | \n",
" (CORNFLAKES) | \n",
"
\n",
" \n",
" 5 | \n",
" 0.25 | \n",
" (MAGGI) | \n",
"
\n",
" \n",
" 6 | \n",
" 0.25 | \n",
" (MILK) | \n",
"
\n",
" \n",
" 7 | \n",
" 0.30 | \n",
" (SUGER) | \n",
"
\n",
" \n",
" 8 | \n",
" 0.35 | \n",
" (TEA) | \n",
"
\n",
" \n",
" 9 | \n",
" 0.20 | \n",
" (BISCUIT, BREAD) | \n",
"
\n",
" \n",
" 10 | \n",
" 0.20 | \n",
" (BREAD, MILK) | \n",
"
\n",
" \n",
" 11 | \n",
" 0.20 | \n",
" (BREAD, SUGER) | \n",
"
\n",
" \n",
" 12 | \n",
" 0.20 | \n",
" (BREAD, TEA) | \n",
"
\n",
" \n",
" 13 | \n",
" 0.20 | \n",
" (CORNFLAKES, COFFEE) | \n",
"
\n",
" \n",
" 14 | \n",
" 0.20 | \n",
" (COFFEE, SUGER) | \n",
"
\n",
" \n",
" 15 | \n",
" 0.20 | \n",
" (MAGGI, TEA) | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" support itemsets\n",
"0 0.35 (BISCUIT)\n",
"1 0.20 (BOURNVITA)\n",
"2 0.65 (BREAD)\n",
"3 0.40 (COFFEE)\n",
"4 0.30 (CORNFLAKES)\n",
"5 0.25 (MAGGI)\n",
"6 0.25 (MILK)\n",
"7 0.30 (SUGER)\n",
"8 0.35 (TEA)\n",
"9 0.20 (BISCUIT, BREAD)\n",
"10 0.20 (BREAD, MILK)\n",
"11 0.20 (BREAD, SUGER)\n",
"12 0.20 (BREAD, TEA)\n",
"13 0.20 (CORNFLAKES, COFFEE)\n",
"14 0.20 (COFFEE, SUGER)\n",
"15 0.20 (MAGGI, TEA)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 将最小支持度设为0.2\n",
"freq_df = apriori(df, min_support = 0.2, use_colnames = True, verbose = 1)\n",
"freq_df"
]
},
{
"cell_type": "markdown",
"id": "ce17b2cb-2efe-49d8-a640-ae576f9ed6de",
"metadata": {},
"source": [
"置信度值设置为0.6,即,在购买商品X的条件下,有0.6的概率会购买商品Y"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "e9385133-e585-40a2-aa5d-6d8266cfdcfa",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" antecedents | \n",
" consequents | \n",
" antecedent support | \n",
" consequent support | \n",
" support | \n",
" confidence | \n",
" lift | \n",
" leverage | \n",
" conviction | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" (MILK) | \n",
" (BREAD) | \n",
" 0.25 | \n",
" 0.65 | \n",
" 0.2 | \n",
" 0.800000 | \n",
" 1.230769 | \n",
" 0.0375 | \n",
" 1.75 | \n",
"
\n",
" \n",
" 1 | \n",
" (SUGER) | \n",
" (BREAD) | \n",
" 0.30 | \n",
" 0.65 | \n",
" 0.2 | \n",
" 0.666667 | \n",
" 1.025641 | \n",
" 0.0050 | \n",
" 1.05 | \n",
"
\n",
" \n",
" 2 | \n",
" (CORNFLAKES) | \n",
" (COFFEE) | \n",
" 0.30 | \n",
" 0.40 | \n",
" 0.2 | \n",
" 0.666667 | \n",
" 1.666667 | \n",
" 0.0800 | \n",
" 1.80 | \n",
"
\n",
" \n",
" 3 | \n",
" (SUGER) | \n",
" (COFFEE) | \n",
" 0.30 | \n",
" 0.40 | \n",
" 0.2 | \n",
" 0.666667 | \n",
" 1.666667 | \n",
" 0.0800 | \n",
" 1.80 | \n",
"
\n",
" \n",
" 4 | \n",
" (MAGGI) | \n",
" (TEA) | \n",
" 0.25 | \n",
" 0.35 | \n",
" 0.2 | \n",
" 0.800000 | \n",
" 2.285714 | \n",
" 0.1125 | \n",
" 3.25 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" antecedents consequents antecedent support consequent support support \\\n",
"0 (MILK) (BREAD) 0.25 0.65 0.2 \n",
"1 (SUGER) (BREAD) 0.30 0.65 0.2 \n",
"2 (CORNFLAKES) (COFFEE) 0.30 0.40 0.2 \n",
"3 (SUGER) (COFFEE) 0.30 0.40 0.2 \n",
"4 (MAGGI) (TEA) 0.25 0.35 0.2 \n",
"\n",
" confidence lift leverage conviction \n",
"0 0.800000 1.230769 0.0375 1.75 \n",
"1 0.666667 1.025641 0.0050 1.05 \n",
"2 0.666667 1.666667 0.0800 1.80 \n",
"3 0.666667 1.666667 0.0800 1.80 \n",
"4 0.800000 2.285714 0.1125 3.25 "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_rules = association_rules(freq_df, metric = \"confidence\", min_threshold = 0.6)\n",
"df_rules"
]
},
{
"cell_type": "markdown",
"id": "2b2caf12-06e7-4dba-b1ae-0c27108e719a",
"metadata": {},
"source": [
"## 4. 结果分析支持商业决策"
]
},
{
"cell_type": "markdown",
"id": "0992227b-8c00-4da7-b34d-dcc96d8f1844",
"metadata": {},
"source": [
"以上述结果中的第四(索引值为3)条规则为例分析如下:\n",
"\n",
"- 方糖在所有销售记录中的比率占30%;\n",
"\n",
"- 咖啡在所有销售记录中的比率占40%;\n",
"\n",
"- 方糖+咖啡组合在所有销售记录中的比率占20%;\n",
"\n",
"- 在购买方糖的顾客中,有约67%的顾客也会购买咖啡;\n",
"\n",
"- 购买糖的用户可能会比不购买糖的用户多购买8%的咖啡;\n",
"\n",
"- 方糖和咖啡的关联度可用conviction值衡量(1.8)。"
]
},
{
"cell_type": "markdown",
"id": "5d7994d6-e433-409f-ae4e-bbb78087f701",
"metadata": {},
"source": [
"如果商品集合X和Y一起购买的频率高,关联性强,可采取以下几个步骤增加利润:\n",
"\n",
"- 通过产品组合改善交叉销售,如顾客购买了电脑后,可提醒其购买鼠标;\n",
"\n",
"- 更改商店布局,将高度关联商品放在一起以提高销售额;\n",
"\n",
"- 为销量较低的产品设计促销活动,以提高销售额;\n",
"\n",
"- 对关联产品,提供组合购买折扣,如,购买电脑后,加够某款鼠标只需9.9元。"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}