针对拥有多品类、多种类产品的企业,如何通过数据分析优化产品结构,实现最大化收益和资源分配。
案例背景:制造业企业的产品矩阵分析
某制造企业拥有复杂的产品体系,需要解决:
如何评估各产品线的健康度?
如何优化产品组合实现利润最大化?
如何分配研发和市场资源?
如何识别明星产品和问题产品?
数据架构设计
多层次产品分类体系
python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
import warnings
warnings.filterwarnings('ignore')
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# 生成多层次产品数据
np.random.seed(42)
n_products = 5000
# 定义产品层级结构
product_hierarchy = {
'业务单元': ['工业设备', '消费电子', '医疗设备', '汽车零部件', '智能家居'],
'产品线': {
'工业设备': ['重型机械', '自动化设备', '检测仪器', '动力系统'],
'消费电子': ['智能手机', '笔记本电脑', '智能穿戴', '影音设备'],
'医疗设备': ['影像设备', '监护仪器', '诊断设备', '治疗设备'],
'汽车零部件': ['发动机系统', '底盘系统', '电子系统', '内饰系统'],
'智能家居': ['安防监控', '环境控制', '娱乐系统', '厨房电器']
},
'产品类别': {
'重型机械': ['挖掘机', '装载机', '起重机', '推土机'],
'智能手机': ['旗舰机', '中端机', '入门机', '折叠屏'],
'影像设备': ['CT扫描仪', 'MRI设备', 'X光机', '超声设备']
# ... 其他产品线的具体分类
}
}
# 生成产品主数据
products = []
for unit in product_hierarchy['业务单元']:
for line in product_hierarchy['产品线'][unit]:
# 为每个产品线生成多个产品
n_line_products = np.random.randint(20, 100)
for i in range(n_line_products):
product_id = f"P{len(products)+1:04d}"
category_options = product_hierarchy['产品类别'].get(line, [f'{line}_标准型', f'{line}_专业型', f'{line}_经济型'])
category = np.random.choice(category_options)
products.append({
'product_id': product_id,
'business_unit': unit,
'product_line': line,
'product_category': category,
'product_name': f"{category}_{i+1}",
'launch_date': datetime(2020 + np.random.randint(0, 4),
np.random.randint(1, 13),
np.random.randint(1, 28)),
'cost_price': np.random.lognormal(7, 1.2),
'target_margin': np.random.uniform(0.1, 0.4)
})
products_df = pd.DataFrame(products)
products_df['sales_price'] = products_df['cost_price'] * (1 + products_df['target_margin'])
print("产品主数据概览:")
print(f"总产品数量: {len(products_df)}")
print(f"业务单元: {products_df['business_unit'].nunique()}个")
print(f"产品线: {products_df['product_line'].nunique()}个")
print(f"产品类别: {products_df['product_category'].nunique()}个")
display(products_df.head())
生成销售交易数据
python
# 生成销售数据
n_transactions = 50000
sales_data = []
for _ in range(n_transactions):
product = products_df.sample(1).iloc[0]
order_date = datetime(2023, np.random.randint(1, 13), np.random.randint(1, 28))
sales_data.append({
'order_id': f"ORDER{10000 + _}",
'order_date': order_date,
'product_id': product['produc
浙公网安备 33010602011771号