当前位置: 首页 > news >正文

2025年“创新杯”(原钉钉杯) A题 建模思路

2025年“创新杯”(原钉钉杯) 建模思路

A题 智慧工厂工业设备传感器数据分析

问题重述

智慧工厂的核心目标是通过传感器数据分析实现预测性维护和资源优化。
本赛题提供包含 50万台工业设备 的传感器数据集,涵盖 温度、振动、功耗、维护记录等30+维特征,需解决两个关键问题:

任务A:设备故障预测
基于历史数据构建 二分类模型,预测设备未来7天内是否发生故障(目标变量 Failure_Within_7_Days),要求输出 准确率、召回率、F1值特征重要性分析

任务B:剩余寿命预测
在不使用故障标签的条件下,预测设备剩余使用寿命(目标变量 Remaining_Useful_Life_days),要求输出 MSE、R²特征影响分析


任务A:设备故障预测

问题分析

  • 数据规模大:50万台设备,需高效算法。
  • 特征复杂:非线性交互(如振动+温度→轴承磨损)。
  • 样本不均衡:故障样本占比通常 <5%。
  • 可解释性:需明确关键故障驱动因素。

推荐模型

  • 随机森林(Random Forest):抗过拟合、并行高效、原生特征重要性。
  • SHAP解释:通过博弈论量化特征贡献,解决传统特征重要性偏差。

数学模型

随机森林
  • Bootstrap抽样:约36.8%样本为OOB(袋外验证)。
  • 分裂准则
    • 分类:基尼指数 / 信息增益
    • 回归:最小化均方误差(MSE)
  • 泛化误差上界(Breiman证明):
    Error≤ρˉ(1−s2)/s2 \text{Error} \leq \bar{\rho}(1-s^2)/s^2 Errorρˉ(1s2)/s2
    其中 ρˉ\bar{\rho}ρˉ 为树间相关性,sss 为单树强度。
SHAP值
  • Shapley值
    ϕi=∑S⊆F∖{i}∣S∣!(∣F∣−∣S∣−1)!∣F∣![fS∪{i}−fS] \phi_i = \sum_{S \subseteq F \setminus \{i\}} \frac{|S|!(|F|-|S|-1)!}{|F|!} [f_{S \cup \{i\}} - f_S] ϕi=SF{i}F!S!(FS1)![fS{i}fS]
    满足加性一致性:y^=ϕ0+∑ϕi\hat{y} = \phi_0 + \sum \phi_iy^=ϕ0+ϕi

Python代码示例

import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, recall_score, f1_score
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from imblearn.over_sampling import SMOTE
import shap# 数据加载与预处理
data = pd.read_csv('sensor_data.csv')
X = data.drop(['Failure_Within_7_Days', 'Machine_ID'], axis=1)
y = data['Failure_Within_7_Days']# 类别特征编码
encoder = OneHotEncoder(sparse_output=False)
encoded_cols = encoder.fit_transform(X[['Machine_Type']])
X_encoded = pd.concat([X.drop('Machine_Type', axis=1), pd.DataFrame(encoded_cols)], axis=1)# 标准化连续特征
scaler = StandardScaler()
cont_features = ['Temperature_C', 'Vibration_mms', 'Operational_Hours']
X_encoded[cont_features] = scaler.fit_transform(X_encoded[cont_features])# SMOTE过采样(若故障样本<5%)
if sum(y) / len(y) < 0.05:smote = SMOTE(random_state=42)X_res, y_res = smote.fit_resample(X_encoded, y)
else:X_res, y_res = X_encoded, y# 划分训练集与测试集
X_train, X_test, y_train, y_test = train_test_split(X_res, y_res, test_size=0.2, random_state=42)# 训练随机森林
model = RandomForestClassifier(n_estimators=200, max_depth=10, class_weight='balanced', random_state=42)
model.fit(X_train, y_train)# 预测与评估
y_pred = model.predict(X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))
print("Recall:", recall_score(y_test, y_pred))
print("F1 Score:", f1_score(y_test, y_pred))# SHAP特征重要性分析
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)
shap.summary_plot(shap_values[1], X_test, plot_type="bar")

任务B:剩余寿命预测(RUL)

1 问题分析

  • 非线性退化:设备性能衰减并非线性,轴承磨损初期缓慢、后期加速。
  • 特征交互:温度、油位、振动等参数存在协同影响。
  • 关键样本稀疏:临近失效的数据仅占 5–10%,需要增强。

推荐方案

  • 模型:支持向量回归(SVR)+ RBF 核,天然处理非线性。
  • 解释:SHAP 量化每个特征对剩余寿命的贡献。
  • 数据增强:SMOGN 合成少数关键样本(剩余寿命短的设备)。

2 数学模型(SVR 概要)

  • 原始优化目标
    min⁡w,b,ξ  12∥w∥2+C∑i(ξi+ξi∗) \min_{w,b,\xi}\; \frac{1}{2}\|w\|^2 + C\sum_i(\xi_i+\xi_i^*) w,b,ξmin21w2+Ci(ξi+ξi)
    约束
    {yi−w⊤xi−b≤ε+ξiw⊤xi+b−yi≤ε+ξi∗ξi,ξi∗≥0 \begin{cases} y_i - w^\top x_i - b \le \varepsilon + \xi_i \\ w^\top x_i + b - y_i \le \varepsilon + \xi_i^* \\ \xi_i,\xi_i^* \ge 0 \end{cases} yiwxibε+ξiwxi+byiε+ξiξi,ξi0

  • RBF 核
    K(x,x′)=exp⁡(−γ∥x−x′∥2),γ>0 K(x,x')=\exp(-\gamma\|x-x'\|^2),\quad \gamma>0 K(x,x)=exp(γxx2),γ>0


3 Python 完整代码

需提前安装:pip install smogn shap scikit-learn

import pandas as pd
import numpy as np
from sklearn.svm import SVR
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.model_selection import train_test_split, GridSearchCV
import shap
import smogn   # SMOGN: 针对回归的少数样本合成# 1. 读取数据
data = pd.read_csv('sensor_data.csv')# 2. 特征与标签
features = ['Operational_Hours', 'Temperature_C', 'Vibration_mms','Oil_Level_pct', 'Coolant_Level_pct', 'Maintenance_History_Count']
X = data[features]
y = data['Remaining_Useful_Life_days']# 3. 关键样本增强(SMOGN)
low_life = np.percentile(y, 10)
X_res, y_res = smogn.smoter(data=pd.concat([X, y], axis=1),y='Remaining_Useful_Life_days',pert=0.05,y_thresh=low_life
)# 4. 标准化
X_scaler = StandardScaler()
y_scaler = StandardScaler()
X_scaled = X_scaler.fit_transform(X_res)
y_scaled = y_scaler.fit_transform(y_res.values.reshape(-1, 1)).ravel()# 5. 训练/测试划分
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y_scaled, test_size=0.2, random_state=42)# 6. 网格搜索最优超参数
param_grid = {'C':      [0.1, 1, 10, 100],'gamma':  [0.01, 0.1, 1],'epsilon':[0.05, 0.1, 0.2]
}
svr = SVR(kernel='rbf')
grid = GridSearchCV(svr, param_grid, cv=5,scoring=['neg_mean_squared_error','r2'],refit='neg_mean_squared_error',n_jobs=-1)
grid.fit(X_train, y_train)
best = grid.best_estimator_# 7. 预测与反标准化
y_pred_scaled = best.predict(X_test)
y_pred = y_scaler.inverse_transform(y_pred_scaled.reshape(-1, 1)).ravel()
y_test_orig = y_scaler.inverse_transform(y_test.reshape(-1, 1)).ravel()# 8. 评估指标
mse = mean_squared_error(y_test_orig, y_pred)
r2  = r2_score(y_test_orig, y_pred)
print(f"MSE = {mse:.2f}, R² = {r2:.4f}")# 9. SHAP 解释
explainer = shap.KernelExplainer(best.predict,shap.sample(X_train, 100))
shap_values = explainer.shap_values(X_test)# 9.1 全局特征重要性
shap.summary_plot(shap_values, X_test,feature
http://www.dtcms.com/a/295237.html

相关文章:

  • Java 实现 C/S 架构详解:从基础到实战,彻底掌握客户端/服务端编程
  • Socket编程入门:从IP到端口全解析
  • OSPF路由协议单区域
  • MSOP/DIFOP端口 vs. IP地址的关系以及每个IP下面有什么自己的东西
  • 征服 Linux 网络:核心服务与实战解析
  • RWA与DeFi(去中心化金融)的关系是什么?RWA在DeFi中扮演什么角色?
  • 香草社游戏系列原声大碟OST合集全无损 FLAC格式 30GB
  • 详细介绍AI在金融、医疗、教育、制造四大领域的落地案例,每个案例均包含实际应用场景、技术实现方案、可视化图表和核心代码示例
  • 【每天一个知识点】生成对抗聚类(Generative Adversarial Clustering, GAC)
  • 【Unity开发】数据存储——XML
  • C++11+ 原子操作 `std::atomic`,现代并发编程的核心
  • Delegate、Action 与 Func 委托的全面解析
  • GitHub Actions打包容器,推送 AWS ECR 并使 EKS 自动拉取以完成发版部署
  • 【Java基础06】ArrayList
  • 软考 系统架构设计师系列知识点之杂项集萃(115)
  • Python 程序设计讲义(14):Python 的数据运算——数值运算
  • RabbitMQ--消息顺序性
  • Java集合去重
  • OpenMed 项目深度分析:推动医疗 NLP 领域的开源革命
  • pcie常用的查看寄存器方法
  • node.js中的path模块
  • 低速信号设计之 QSPI 篇
  • 【LeetCode数据结构】二叉树的应用(一)——单值二叉树问题、相同的树问题、对称二叉树问题、另一棵树的子树问题详解
  • Faiss中L2欧式距离与余弦相似度:究竟该如何选择?
  • Web前端入门:JavaScript 哪些地方需要 try...catch 异常捕获
  • 【图论】倍增与lca
  • Avalonia 基于MVVM的时间统计/系统时间显示 示例
  • EPSON爱普生全系列废墨垫已满清零工具分享附教程下载
  • EasyExcel 模板导出数据 + 自定义策略(合并单元格)
  • 基于深度学习的胸部 X 光图像肺炎分类系统(三)