科技功能性面料销量预测算法,恒温,防水,抗菌面料分场景预估季节销量。
科技功能性面料销量预测算法 —— 恒温 / 防水 / 抗菌分场景季节预估
一、实际应用场景描述
在《时尚产业与品牌创新》课程中,科技功能性面料(Technical Functional Fabrics)是近年来的核心议题之一:
- 恒温面料(相变材料 PCM / 石墨烯复合):户外品牌、都市通勤轻量化外套
- 防水面料(ePTFE 膜 / PU 涂层):硬壳冲锋衣、雨靴、户外包袋
- 抗菌面料(银离子 / 铜纤维 / 竹炭复合):运动内衣、瑜伽服、鞋垫、医疗工装
这三类面料有一个共同特征:销量高度依赖季节与场景,与纯时尚面料的"流行驱动"逻辑完全不同。
一个典型的品牌决策场景:
采购部问:下个冬季,恒温内衬面料要备多少卷?
销售部问:抗菌运动面料的春夏销量能到多少?
老板问:防水面料的秋季销量峰值在哪个月?
如果没有量化模型,答案通常是"去年差不多""凭经验估一下"——这就是痛点所在。
二、引入痛点
2.1 行业现状问题
痛点 具体表现 后果
经验拍脑袋 "去年卖了 3000 米,今年估 3500" 偏差 30%~50% 很常见
季节归因缺失 只看过年总量,不看月度分布 备货集中在错误月份
场景混为一谈 户外运动 / 都市通勤 / 工装 共用一条曲线 不同场景峰谷完全不同
功能性衰减忽略 抗菌有效期、防水涂层寿命未纳入 复购周期预测失真
无法做敏感性测试 暖冬 / 寒冬、多雨 / 少雨怎么影响? 缺乏风险预案
2.2 一个真实感模拟
品牌 A 的预测(纯经验):
冬季恒温面料:预估 5000 米
实际:暖冬,仅售出 3200 米
结果:库存积压 → 折价 40% 清仓 → 吞噬全年利润
核心矛盾:功能性面料的销量不是"匀速增长曲线",而是受温度、降水、场景活动强度三重驱动的脉冲式分布。
三、核心逻辑讲解
3.1 整体架构
输入层 计算层 输出层
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ 面料类型 │ │ 季节基准系数 │ │ 月度销量预测 │
│ 应用场景 │ → │ 场景修正系数 │ → │ 季度总量预测 │
│ 历史基准销量 │ │ 温度敏感系数 │ │ 峰值月份识别 │
│ 温度/降水数据 │ │ 降水敏感系数 │ │ 敏感性分析 │
│ 功能衰减参数 │ │ 功能衰减因子 │ │ 置信区间 │
└─────────────────┘ └──────────────────┘ └──────────────────┘
3.2 核心公式体系
① 月度基础预测
月销量 = 年基准销量 × 月份季节系数 × 场景权重
② 天气修正(关键差异化因子)
恒温面料:温度修正 = 1 + α × |月均温 − 舒适温度| × 方向系数
防水面料:降水修正 = 1 + β × (月降水量 − 基准降水)
抗菌面料:温度修正 = 1 + γ × (月均温 − 基准温度) (高温促运动出汗)
③ 功能衰减(复购周期)
有效需求 = 基础需求 × (1 − 衰减率)^月份
衰减率 = 1 − e^(−k × 使用强度)
④ 场景叠加
都市通勤场景:工作日权重高
户外运动场景:周末+节假日权重高
工装场景:无季节性,全年均匀
四、项目结构
fabric_sales_forecast/
├── config.py # 常量配置(面料参数/场景定义/季节系数)
├── data_models.py # 数据模型(面料/场景/历史数据)
├── season_engine.py # 季节系数引擎(月度分布/天气修正)
├── forecast_engine.py # 预测引擎(核心算法)
├── scenario_analyzer.py # 场景分析器(多场景对比)
├── sensitivity.py # 敏感性分析模块
├── report.py # 报告生成(控制台表格 + 简单可视化)
├── main.py # 主程序入口(含完整示例)
├── README.md # 项目说明
└── requirements.txt # 依赖声明
五、代码模块化实现
"requirements.txt"
# 核心依赖
numpy>=1.24.0
# 可视化(可选,不装也能跑基础功能)
matplotlib>=3.7.0
# 数据导出(可选)
# pandas>=2.0.0
"config.py"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
config.py
常量配置中心:面料参数、场景定义、月份基准系数
所有"经验参数"集中管理,修改一处全局生效
"""
from typing import Dict, List
import numpy as np
# ========== 月份列表(中文) ==========
MONTHS_CN = [
"1月", "2月", "3月", "4月", "5月", "6月",
"7月", "8月", "9月", "10月", "11月", "12月",
]
# ========== 面料类型枚举 ==========
FABRIC_THERMO = "thermo" # 恒温(相变/石墨烯)
FABRIC_WATERPROOF = "waterproof" # 防水(ePTFE/PU涂层)
FABRIC_ANTIBACTERIAL = "antibacterial" # 抗菌(银离子/铜纤维)
FABRIC_TYPES = [FABRIC_THERMO, FABRIC_WATERPROOF, FABRIC_ANTIBACTERIAL]
# ========== 应用场景枚举 ==========
SCENE_OUTDOOR = "outdoor" # 户外运动(登山/徒步/露营)
SCENE_URBAN = "urban" # 都市通勤
SCENE_WORKWEAR = "workwear" # 工装/医疗/军警
SCENE_SPORTS = "sports" # 运动健身(瑜伽/跑步)
SCENE_LEISURE = "leisure" # 休闲旅行
SCENE_TYPES = [SCENE_OUTDOOR, SCENE_URBAN, SCENE_WORKWEAR, SCENE_SPORTS, SCENE_LEISURE]
# ========== 季节基准系数(月度分布,全年之和=1) ==========
# 基于中国中东部气候的典型功能性面料需求分布
SEASON_COEFFICIENTS = {
# 恒温面料:10~3月为旺季(秋冬保暖需求),峰值为12月、1月
FABRIC_THERMO: np.array([
0.14, 0.10, 0.06, 0.03, 0.02, 0.01, # 1-6月
0.01, 0.02, 0.06, 0.12, 0.18, 0.25, # 7-12月
]),
# 防水面料:6~9月雨季旺季,峰值为7月、8月
FABRIC_WATERPROOF: np.array([
0.04, 0.04, 0.06, 0.08, 0.10, 0.16, # 1-6月
0.22, 0.18, 0.08, 0.04, 0.04, 0.06, # 7-12月
]),
# 抗菌面料:4~10月运动季旺季(高温促出汗),峰值为6月、7月
FABRIC_ANTIBACTERIAL: np.array([
0.05, 0.05, 0.07, 0.09, 0.12, 0.14, # 1-6月
0.14, 0.12, 0.10, 0.07, 0.05, 0.05, # 7-12月
]),
}
# ========== 场景权重系数(对月度分布的形状修正) ==========
# 值 > 1 表示该场景下该月份需求放大,< 1 表示缩小
SCENE_MONTH_MODIFIERS = {
SCENE_OUTDOOR: np.array([
0.8, 0.7, 1.0, 1.3, 1.5, 1.6, # 春秋户外黄金期
1.5, 1.3, 1.5, 1.3, 0.9, 0.8, # 秋季也是户外旺季
]),
SCENE_URBAN: np.array([
1.2, 1.1, 1.0, 0.9, 0.8, 0.8, # 夏季通勤需求略降(短途多)
0.9, 1.0, 1.1, 1.2, 1.3, 1.3, # 秋冬通勤高峰
]),
SCENE_WORKWEAR: np.array([
1.0, 0.9, 1.0, 1.0, 1.0, 1.0, # 工装全年均匀
1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
]),
SCENE_SPORTS: np.array([
0.7, 0.8, 1.1, 1.3, 1.5, 1.6, # 春夏运动高峰
1.5, 1.3, 1.2, 0.9, 0.7, 0.6, # 秋季尚可,冬季下降
]),
SCENE_LEISURE: np.array([
0.6, 0.8, 1.2, 1.4, 1.5, 1.5, # 春夏旅行旺季
1.4, 1.2, 1.3, 1.1, 0.8, 0.7, # 国庆旅行小高峰
]),
}
# ========== 天气敏感系数 ==========
# α/β/γ:每单位天气变化对销量的影响强度
WEATHER_SENSITIVITY = {
FABRIC_THERMO: {
"temp_coef": 0.08, # 温度每偏离舒适区1°C,销量变化8%
"comfort_temp": 15.0, # 恒温面料舒适温度(°C)
"direction": "colder", # 越冷需求越高(也可设 "warmer" 或 "both")
},
FABRIC_WATERPROOF: {
"rain_coef": 0.12, # 降水每超基准10mm,销量变化12%
"base_rainfall": 80.0, # 基准月降水(mm)
},
FABRIC_ANTIBACTERIAL: {
"temp_coef": 0.05, # 温度每升高1°C,运动出汗需求增5%
"comfort_temp": 25.0, # 适宜运动温度
"direction": "warmer",
},
}
# ========== 功能衰减参数 ==========
# 功能性面料的效果随时间/洗涤递减,影响复购周期
DECAY_PARAMS = {
FABRIC_THERMO: {
"decay_rate": 0.03, # 每月性能衰减3%(相变材料循环老化)
"wash_accelerator": 0.15, # 每次洗涤额外加速15%
"typical_washes_per_month": 4, # 月均洗涤次数
},
FABRIC_WATERPROOF: {
"decay_rate": 0.02, # 每月2%(涂层缓慢老化)
"wash_accelerator": 0.10, # 洗涤加速10%
"typical_washes_per_month": 3,
},
FABRIC_ANTIBACTERIAL: {
"decay_rate": 0.05, # 每月5%(银离子缓释消耗)
"wash_accelerator": 0.20, # 洗涤加速20%(抗菌层最怕水洗)
"typical_washes_per_month": 6, # 运动面料洗得更勤
},
}
# ========== 月份天气基准数据(中国中东部平均,可替换) ==========
# 格式:{月份索引(0-11): (平均温度°C, 平均降水量mm)}
MONTHLY_WEATHER_BASE = {
0: (3.0, 35), # 1月
1: (5.0, 45), # 2月
2: (10.0, 60), # 3月
3: (16.0, 85), # 4月
4: (21.0, 110), # 5月
5: (25.0, 160), # 6月
6: (28.0, 200), # 7月
7: (27.0, 175), # 8月
8: (23.0, 120), # 9月
9: (17.0, 70), # 10月
10: (10.0, 50), # 11月
11: (4.0, 30), # 12月
}
"data_models.py"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
data_models.py
数据模型层:面料定义、场景绑定、历史销售数据
"""
from dataclasses import dataclass, field
from typing import Dict, Optional, List
import numpy as np
@dataclass
class Fabric:
"""
功能性面料定义
"""
fabric_id: str # 面料编号,如 "FM-THERMO-001"
fabric_type: str # 类型:thermo / waterproof / antibacterial
name: str # 面料名称
annual_base_sales: float # 年基准销量(米 / 件,视粒度而定)
unit: str = "米" # 计量单位
def __post_init__(self):
if self.fabric_type not in ["thermo", "waterproof", "antibacterial"]:
raise ValueError(f"未知面料类型: {self.fabric_type}")
if self.annual_base_sales < 0:
raise ValueError("年基准销量不能为负")
@dataclass
class SceneBinding:
"""
面料 × 场景绑定关系
一款面料可绑定多个场景,每个场景有权重
"""
fabric_id: str
scene: str # outdoor / urban / workwear / sports / leisure
weight: float = 1.0 # 该场景在总销量中的权重占比
def __post_init__(self):
if self.weight < 0:
raise ValueError("场景权重不能为负")
@dataclass
class HistoricalData:
"""
历史月度销量数据(用于校准和对比)
如果某月无数据,值为 None
"""
fabric_id: str
monthly_sales: Dict[int, Optional[float]] # {0: 1200, 1: 1350, ..., 11: 980}
year: int = 2024
def get_array(self) -> np.ndarray:
"""转为12个月的数组,无数据月份填 NaN"""
arr = np.full(12, np.nan)
for m, v in self.monthly_sales.items():
if 0 <= m <= 11:
arr[m] = v if v is not None else np.nan
return arr
def has_data(self, month: int) -> bool:
return month in self.monthly_sales and self.monthly_sales[month] is not None
"season_engine.py"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
season_engine.py
季节系数引擎:生成月度季节分布 + 天气修正
"""
import numpy as np
from typing import Dict, Tuple
from config import (
SEASON_COEFFICIENTS,
SCENE_MONTH_MODIFIERS,
WEATHER_SENSITIVITY,
MONTHLY_WEATHER_BASE,
)
class SeasonEngine:
"""
季节系数引擎
职责:
1. 根据面料类型生成基础月度分布
2. 叠加场景修正
3. 叠加天气敏感修正
4. 输出最终月度系数(12个月,和为1)
"""
def __init__(
self,
fabric_type: str,
scenes: Dict[str, float],
weather_override: Optional[Dict[int, Tuple[float, float]]] = None,
):
"""
Args:
fabric_type: 面料类型
scenes: {场景: 权重} 字典,权重和为1
weather_override: 自定义天气数据 {月份: (温度, 降水)}
"""
self.fabric_type = fabric_type
self.scenes = scenes
self.weather = weather_override or MONTHLY_WEATHER_BASE
# 校验
if fabric_type not in SEASON_COEFFICIENTS:
raise ValueError(f"未注册的面料类型: {fabric_type}")
for s in scenes:
if s not in SCENE_MONTH_MODIFIERS:
raise ValueError(f"未注册的场景: {s}")
def base_season_curve(self) -> np.ndarray:
"""基础季节系数(未叠加场景和天气)"""
return SEASON_COEFFICIENTS[self.fabric_type].copy()
def scene_adjusted_curve(self) -> np.ndarray:
"""
叠加场景修正后的月度系数
公式:season_coef(m) = base_coef(m) × Σ(scene_weight × scene_modifier(m))
"""
base = self.base_season_curve()
scene_sum = np.zeros(12)
for scene, weight in self.scenes.items():
scene_sum += weight * SCENE_MONTH_MODIFIERS[scene]
# 归一化场景修正(保持总量不变)
scene_sum = scene_sum / scene_sum.mean() if scene_sum.mean() > 0 else np.ones(12)
return base * scene_sum
def weather_adjusted_curve(self) -> np.ndarray:
"""
叠加天气敏感修正
不同面料对天气的响应函数不同
"""
base = self.scene_adjusted_curve()
weather_params = WEATHER_SENSITIVITY.get(self.fabric_type, {})
if self.fabric_type == "thermo":
return self._apply_thermo_weather(base, weather_params)
elif self.fabric_type == "waterproof":
return self._apply_waterproof_weather(base, weather_params)
elif self.fabric_type == "antibacterial":
return self._apply_antibacterial_weather(base, weather_params)
return base
def _apply_thermo_weather(self, base: np.ndarray, params: dict) -> np.ndarray:
"""恒温面料:温度越低 → 需求越高"""
alpha = params.get("temp_coef", 0.08)
t_comfort = params.get("comfort_temp", 15.0)
direction = params.get("direction", "colder")
修正 = np.ones(12)
for m in range(12):
temp, _ = self.weather[m]
if direction == "colder":
# 越冷越需求高 → 温度低于舒适温度时放大
if temp < t_comfort:
修正[m] = 1 + alpha * (t_comfort - temp)
else:
修正[m] = 1 - alpha * 0.3 * (temp - t_comfort)
else:
diff = abs(temp - t_comfort)
修正[m] = 1 + alpha * diff
return base * 修正
def _apply_waterproof_weather(self, base: np.ndarray, params: dict) -> np.ndarray:
"""防水面料:降水越多 → 需求越高"""
beta = params.get("rain_coef", 0.12)
base_rain = params.get("base_rainfall", 80.0)
修正 = np.ones(12)
for m in range(12):
_, rain = self.weather[m]
修正[m] = 1 + beta * (rain - base_rain) / 100.0
return base * 修正
def _apply_antibacterial_weather(self, base: np.ndarray, params: dict) -> np.ndarray:
"""抗菌面料:温度越高 → 运动出汗越多 → 需求越高"""
gamma = params.get("temp_coef", 0.05)
t_comfort = params.get("comfort_temp", 25.0)
修正 = np.ones(12)
for m in range(12):
temp, _ = self.weather[m]
if temp > t_comfort:
修正[m] = 1 + gamma * (temp - t_comfort)
else:
修正[m] = 1 - gamma * 0.3 * (t_comfort - temp)
return base * 修正
def final_coefficients(self) -> np.ndarray:
"""
最终月度系数(经过场景+天气修正)
保证12个月系数之和 = 1
"""
raw = self.weather_adjusted_curve()
total = raw.sum()
if total > 0:
return raw / total
return raw
def describe(self) -> Dict:
"""返回各阶段系数,用于调试和展示"""
base = self.base_season_curve()
scene = self.scene_adjusted_curve()
weather = self.weather_adjusted_curve()
final = self.final_coefficients()
return {
"base_sum": round(base.sum(), 4),
"scene_sum": round(scene.sum(), 4),
"weather_sum": round(weather.sum(), 4),
"final_sum": round(final.sum(), 4),
"peak_month": int(np.argmax(final)) + 1,
"peak_value": round(float(final.max()), 4),
"trough_month": int(np.argmin(final)) + 1,
"trough_value": round(float(final.min()), 4),
}
"forecast_engine.py"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
forecast_engine.py
预测引擎:整合季节系数 + 功能衰减 + 历史校准,输出月度/季度预测
"""
import numpy as np
from typing import Dict, Optional, Tuple
from config import DECAY_PARAMS
from data_models import Fabric, HistoricalData
from season_engine import SeasonEngine
class ForecastEngine:
"""
功能性面料销量预测引擎
核心方法:
- predict_monthly: 预测指定年份的12个月销量
- predict_quarterly: 按季度汇总
- apply_decay: 叠加功能衰减效应
- calibrate_with_history: 用历史数据校准预测
"""
def __init__(self, fabric: Fabric, season_engine: SeasonEngine):
self.fabric = fabric
self.season_engine = season_engine
self.monthly_coefficients = season_engine.final_coefficients()
def predict_monthly(
self,
year: int = 2025,
apply_decay: bool = True,
growth_rate: float = 0.0,
) -> np.ndarray:
"""
预测指定年份的月度销量
Args:
year: 预测年份
apply_decay: 是否叠加功能衰减
growth_rate: 年同比增长率(如 0.15 表示增长15%)
Returns:
12个月的预测销量数组
"""
base_annual = self.fabric.annual_base_sales * (1 + growth_rate)
monthly = base_annual * self.monthly_coefficients
if apply_decay:
monthly = self._apply_decay(monthly)
return monthly
def _apply_decay(self, monthly: np.ndarray) -> np.ndarray:
"""
叠加功能性衰减效应
模拟已购买用户的面料性能递减 → 复购需求渐进释放
使用指数衰减模型:
decay_factor(m) = (1 − decay_rate) ^ m × (1 − wash_accel) ^ (washes_per_month × m)
"""
params = DECAY_PARAMS.get(self.fabric.fabric_type, {})
if not params:
return monthly
decay_rate = params.get("decay_rate", 0.0)
wash_accel = params.get("wash_accelerator", 0.0)
washes = params.get("typical_washes_per_month", 0)
result = np.zeros(12)
for m in range(12):
# 时间衰减
time_factor = (1 - decay_rate) ** m
# 洗涤加速衰减
wash_factor = (1 - wash_accel) ** (washes * m)
combined = time_factor * wash_factor
# 衰减作用于"存量用户复购释放",简化处理:
# 第m月的实际系数 = 基础系数 × (1 − 衰减释放比例)
# 即:越往后,新用户占比越低,复购用户贡献递增
result[m] = monthly[m] * (1 + 0.15 * (1 - combined))
return result
def predict_quarterly(self, monthly: np.ndarray) -> Dict[str, float]:
"""按季度汇总"""
return {
"Q1 (1-3月)": round(float(monthly[0:3].sum()), 2),
"Q2 (4-6月)": round(float(monthly[3:6].sum()), 2),
"Q3 (7-9月)": round(float(monthly[6:9].sum()), 2),
"Q4 (10-12月)": round(float(monthly[9:12].sum()), 2),
"全年合计": round(float(monthly.sum()), 2),
}
def predict_seasonal(self, monthly: np.ndarray) -> Dict[str, float]:
"""按冬/春/夏/秋四季汇总"""
return {
"冬季(12-2月)": round(float(monthly[[11, 0, 1]].sum()), 2),
"春季(3-5月)": round(float(monthly[2:5].sum()), 2),
"夏季(6-8月)": round(float(monthly[5:8].sum()), 2),
"秋季(9-11月)": round(float(monthly[8:11].sum()), 2),
}
def calibrate_with_history(
self,
monthly: np.ndarray,
history: HistoricalData,
) -> Tuple[np.ndarray, Dict]:
"""
用历史数据校准预测
方法:对历史有数据的月份,计算预测/实际比值,
用该比值修正未来月份
Returns:
(校准后月度数组, 校准统计信息)
"""
actual = history.get_array()
has_data = ~np.isnan(actual)
if has_data.sum() == 0:
return monthly, {"status": "无历史数据,跳过校准"}
# 计算有数据月份的平均偏差
ratio = np.where(has_data, actual / np.where(monthly > 0, monthly, np.nan), np.nan)
valid_ratios = ratio[~np.isnan(ratio)]
if len(valid_ratios) == 0:
return monthly, {"status": "有效数据不足"}
avg_ratio = np.nanmean(valid_ratios)
# 用平均偏差修正未来月份(无数据月份)
calibrated = monthly.copy()
for m in range(12):
if not has_data[m]:
calibrated[m] *= avg_ratio
stats = {
"status": "已校准",
"历史数据月份数": int(has_data.sum()),
"平均修正系数": round(float(avg_ratio), 3),
"修正方向": "上调" if avg_ratio > 1 else "下调" if avg_ratio < 1 else "不变",
}
return calibrated, stats
def peak_analysis(self, monthly: np.ndarray) -> Dict:
"""峰值分析:找出旺季月份、集中度等"""
total = monthly.sum()
if total == 0:
return {"error": "总销量为零"}
# 累计占比
cumsum = np.cumsum(monthly / total)
# 达到50%销量所需的月份数
months_to_half = int(np.argmax(cumsum >= 0.5)) + 1
# 旺季月份(单月占比 > 8.33% 即超过均匀分布的月份)
peak_months = [int(m + 1) for m in range(12) if monthly[m] / total > 0.10]
# 集中度指数(赫芬达尔指数变体)
concentration = float(np.sum((monthly / total) ** 2))
return {
"峰值月份": int(np.argmax(monthly)) + 1,
"峰值占比": round(float(monthly.max() / total * 100), 1),
"旺季月份(>10%)": peak_months,
"达到50%销量所需月份": months_to_half,
"集中度指数": round(concentration, 3),
"均匀度评估": "高度集中" if concentration > 0.15 else "分布较均匀",
}
"scenario_analyzer.py"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
scenario_analyzer.py
场景分析器:多场景对比、面料间横向对比
"""
import numpy as np
from typing import List, Dict
from data_models import Fabric, SceneBinding
from season_engine import SeasonEngine
from forecast_engine import ForecastEngine
class ScenarioAnalyzer:
"""
多场景对比分析器
支持:
- 同一面料在不同场景组合下的销量分布对比
- 三种面料在同一场景下的竞争力对比
- 生成对比矩阵
"""
@staticmethod
def compare_scenes(
fabric: Fabric,
scene_configs: List[Dict[str, float]],
year: int = 2025,
) -> Dict:
"""
对比同一面料在不同场景配置下的预测结果
Args:
fabric: 面料对象
scene_configs: 场景配置列表,每个元素是 {场景: 权重} 字典
year: 预测年份
Returns:
对比结果字典
"""
results = {}
for i, scenes in enumerate(scene_configs):
engine = SeasonEngine(fabric.fabric_type, scenes)
forecast = ForecastEngine(fabric, engine)
monthly = forecast.predict_monthly(year)
label = f"配置{i+1}: " + ", ".join(f"{s}({w})" for s, w in scenes.items())
results[label] = {
"月度销量": [round(float(v), 1) for v in monthly],
"季度汇总": forecast.predict_quarterly(monthly),
"峰值月份": int(np.argmax(monthly)) + 1,
"峰值销量": round(float(monthly.max()), 1),
"年总量": round(float(monthly.sum()), 1),
}
return results
@staticmethod
def compare_fabrics(
fabrics: List[Fabric],
common_scenes: Dict[str, float],
year: int = 2025,
) -> Dict:
"""
对比多种面料在同一场景下的预测结果
Args:
fabrics: 面料列表
common_scenes: 统一场景配置
year: 预测年份
Returns:
对比结果字典
"""
results = {}
for f in fabrics:
engine = SeasonEngine(f.fabric_type, common_scenes)
forecast = ForecastEngine(f, engine)
monthly = forecast.predict_monthly
利用AI解决实际问题,如果你觉得这个工具好用,欢迎关注长安牧笛!