赞
踩
铛铛!小秘籍来咯!
小秘籍希望大家都能轻松建模呀,数维杯也会持续给大家放送思路滴~
抓紧小秘籍,我们出发吧~
来看看 数维杯国际大学生数学建模挑战赛的B题!
完整版内容在文末领取噢~
问题一:针对催化剂(脱硫灰)在棉秆(cotton stalk)和模型化合物(CE和LG)的催化热解实验,通过数学建模分析,探讨催化剂在不同混合比例下对产物(焦油、水、焦渣、合成气)产量的影响,并判断脱硫灰是否在催化棉秆、纤维素和木质素的热解过程中发挥显著作用。
问题二:基于实验数据,对三种热解组合(脱硫灰-棉秆、脱硫灰-CE、脱硫灰-LG)进行深入分析,关注混合比例对热解气体产物(H2、CO、CO2、CH4等)产量的影响,通过图形化呈现和解释结果。
问题三:在相同脱硫灰催化比例下,探讨纤维素(CE)和木质素(LG)的热解产物产量以及热解气体组分的差异,并提供解释。
问题四:建立脱硫灰对模型化合物(CE和LG)的催化反应机理模型,进行反应动力学分析,通过最小二乘法和统计检验验证模型的可靠性。
问题五:使用机器学习方法(如支持向量回归),基于给定数据,建立模型预测催化剂在不同条件下对产物产量的影响,实现对热解产物的定量预测。
问题一要求对每个热解组合分析与其对应的热解产物(焦油、水、焦渣、合成气)的产量之间的关系,以及判断脱硫灰作为催化剂是否在促进棉秆、纤维素和木质素的热解过程中发挥了显著的作用。以下是问题一的建模思路:
数据理解与预处理:
选择适当的模型:
特征选择与工程:
建立多元回归模型:
from sklearn.linear_model import LinearRegression
# 假设 X 是热解组合的相关参数,y 是对应产物的产量
model_tar = LinearRegression()
model_water = LinearRegression()
model_coke = LinearRegression()
model_syngas = LinearRegression()
# 训练模型
model_tar.fit(X, y_tar)
model_water.fit(X, y_water)
model_coke.fit(X, y_coke)
model_syngas.fit(X, y_syngas)
模型评估:
统计检验:
结果解释:
可视化:
模型应用与验证:
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error import statsmodels.api as sm # 读取数据 data = pd.read_excel('热解组合产物数据.xlsx') # 数据预处理 X = data[['脱硫灰混合比例', '其他相关参数']] # 输入特征 y_tar = data['焦油产量'] # 目标变量:焦油产量 y_water = data['水产量'] # 目标变量:水产量 y_coke = data['焦渣产量'] # 目标变量:焦渣产量 y_syngas = data['合成气产量'] # 目标变量:合成气产量 # 分割数据集为训练集和测试集 X_train, X_test, y_tar_train, y_tar_test, y_water_train, y_water_test, y_coke_train, y_coke_test, y_syngas_train, y_syngas_test = train_test_split( X, y_tar, y_water, y_coke, y_syngas, test_size=0.2, random_state=42) # 创建并训练多元回归模型 model_tar = LinearRegression() model_tar.fit(X_train, y_tar_train) model_water = LinearRegression() model_water.fit(X_train, y_water_train) model_coke = LinearRegression() model_coke.fit(X_train, y_coke_train) model_syngas = LinearRegression() model_syngas.fit(X_train, y_syngas_train) # 预测测试集 y_tar_pred = model_tar.predict(X_test) y_water_pred = model_water.predict(X_test) y_coke_pred = model_coke.predict(X_test) y_syngas_pred = model_syngas.predict(X_test) # 评估模型性能 mse_tar = mean_squared_error(y_tar_test, y_tar_pred) mse_water = mean_squared_error(y_water_test, y_water_pred) mse_coke = mean_squared_error(y_coke_test, y_coke_pred) mse_syngas = mean_squared_error(y_syngas_test, y_syngas_pred) print(f'Mean Squared Error (Tar): {mse_tar}') print(f'Mean Squared Error (Water): {mse_water}') print(f'Mean Squared Error (Coke): {mse_coke}') print(f'Mean Squared Error (Syngas): {mse_syngas}') # 统计检验 X_train = sm.add_constant(X_train) # 添加截距项 model_tar_stats = sm.OLS(y_tar_train, X_train).fit() model_water_stats = sm.OLS(y_water_train, X_train).fit() model_coke_stats = sm.OLS(y_coke_train, X_train).fit() model_syngas_stats = sm.OLS(y_syngas_train, X_train).fit() # 打印模型统计信息 print(model_tar_stats.summary()) #见完整代码
数据理解与预处理:
选择适当的模型:
特征选择与工程:
建立多项式回归模型:
PolynomialFeatures
进行特征的多项式转换,并使用LinearRegression
进行多项式回归。from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LinearRegression # 假设 X 是混合比例,y 是对应产物的产量 degree = 2 # 多项式次数 poly = PolynomialFeatures(degree) X_poly = poly.fit_transform(X_train) model_tar = LinearRegression() model_water = LinearRegression() model_coke = LinearRegression() model_syngas = LinearRegression() # 训练模型 model_tar.fit(X_poly, y_tar_train) model_water.fit(X_poly, y_water_train) model_coke.fit(X_poly, y_coke_train) model_syngas.fit(X_poly, y_syngas_train)
模型评估:
from sklearn.metrics import mean_squared_error X_poly_test = poly.transform(X_test) y_tar_pred = model_tar.predict(X_poly_test) y_water_pred = model_water.predict(X_poly_test) y_coke_pred = model_coke.predict(X_poly_test) y_syngas_pred = model_syngas.predict(X_poly_test) mse_tar = mean_squared_error(y_tar_test, y_tar_pred) mse_water = mean_squared_error(y_water_test, y_water_pred) mse_coke = mean_squared_error(y_coke_test, y_coke_pred) mse_syngas = mean_squared_error(y_syngas_test, y_syngas_pred) print(f'Mean Squared Error (Tar): {mse_tar}') print(f'Mean Squared Error (Water): {mse_water}') print(f'Mean Squared Error (Coke): {mse_coke}') print(f'Mean Squared Error (Syngas): {mse_syngas}')
结果可视化:
import matplotlib.pyplot as plt
plt.scatter(X_test, y_tar_test, color='black', label='Actual')
plt.scatter(X_test, y_tar_pred, color='red', label='Predicted')
plt.title('Tar Production Prediction')
plt.xlabel('Mixture Ratio')
plt.ylabel('Tar Production')
plt.legend()
plt.show()
统计检验(可选):
import statsmodels.api as sm
X_poly_stats = sm.add_constant(X_poly) # 添加截距项
model_tar_stats = sm.OLS(y_tar_train, X_poly_stats).fit()
# 进行其他产物的统计检验...
print(model_tar_stats.summary())
模型解释与应用:
对于问题三,我们可以采用多元回归分析来建模,以研究脱硫灰催化下纤维素(CE)和木质素(LG)的热解产物产量及热解气体组分之间的关系。以下是更详细的建模思路:
数据理解与预处理:
选择适当的模型:
特征选择与工程:
建立多元回归模型:
LinearRegression
。from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error # 选择特征和目标变量 X = data[['催化比例']] y_tar = data[['CE_tar_production', 'LG_tar_production']] y_gas = data[['CE_H2', 'CE_CO', 'LG_H2', 'LG_CO']] # 以此类推... # 分割数据集 X_train, X_test, y_tar_train, y_tar_test, y_gas_train, y_gas_test = train_test_split( X, y_tar, y_gas, test_size=0.2, random_state=42 ) # 创建并训练多元回归模型 model_tar = LinearRegression() model_tar.fit(X_train, y_tar_train) model_gas = LinearRegression() model_gas.fit(X_train, y_gas_train)
模型评估:
# 预测测试集
y_tar_pred = model_tar.predict(X_test)
y_gas_pred = model_gas.predict(X_test)
# 评估模型性能
mse_tar = mean_squared_error(y_tar_test, y_tar_pred)
mse_gas = mean_squared_error(y_gas_test, y_gas_pred)
print(f'Mean Squared Error (Tar): {mse_tar}')
print(f'Mean Squared Error (Gas): {mse_gas}')
解释结果:
import statsmodels.api as sm
X_train_stats = sm.add_constant(X_train) # 添加截距项
model_tar_stats = sm.OLS(y_tar_train, X_train_stats).fit()
model_gas_stats = sm.OLS(y_gas_train, X_train_stats).fit()
print(model_tar_stats.summary())
print(model_gas_stats.summary())
统计检验:
模型解释与应用:
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error import statsmodels.api as sm # 读取数据 data = pd.read_excel('热解组合产物数据.xlsx') # 数据预处理 # 选择特征和目标变量 X = data[['催化比例']] y_tar = data[['CE_tar_production', 'LG_tar_production']] y_gas = data[['CE_H2', 'CE_CO', 'LG_H2', 'LG_CO']] # 以此类推... # 分割数据集 X_train, X_test, y_tar_train, y_tar_test, y_gas_train, y_gas_test = train_test_split( X, y_tar, y_gas, test_size=0.2, random_state=42 ) # 创建并训练多元回归模型 - 产物产量 model_tar = LinearRegression() model_tar.fit(X_train, y_tar_train) # 创建并训练多元回归模型 - 热解气体组分 model_gas = LinearRegression() model_gas.fit(X_train, y_gas_train) # 预测测试集 y_tar_pred = model_tar.predict(X_test) y_gas_pred = model_gas.predict(X_test) # 评估模型性能 mse_tar = mean_squared_error(y_tar_test, y_tar_pred) mse_gas = mean_squared_error(y_gas_test, y_gas_pred) print(f'Mean Squared Error (Tar): {mse_tar}') print(f'Mean Squared Error (Gas): {mse_gas}') # 模型统计检验 X_train_stats = sm.add_constant(X_train) # 添加截距项 model_tar_stats = sm.OLS(y_tar_train, X_train_stats).fit()
问题四需要建立脱硫灰对模型化合物(如纤维素和木质素)的催化反应机理模型,并对反应动力学进行分析。以下是一个建模思路:
机理模型的构建:
动力学参数的估计:
模型验证:
模型应用与解释:
敏感性分析:
模型改进:
import numpy as np from scipy.integrate import odeint from scipy.optimize import curve_fit import matplotlib.pyplot as plt # 定义一阶反应模型 def first_order_reaction(C, t, k): return -k * C # 生成模拟数据 t_data = np.linspace(0, 10, 50) k_true = 0.2 # 真实的反应速率常数 C_true = odeint(first_order_reaction, 1.0, t_data, args=(k_true,)).flatten() # 添加噪声模拟实验数据 np.random.seed(42) C_noisy = C_true + 0.05 * np.random.normal(size=len(t_data)) # 定义拟合函数 def fit_function(t, k): return odeint(first_order_reaction, 1.0, t, args=(k,)).flatten()
使用支持向量回归(Support Vector Regression,SVR方法。SVR 是一种回归分析的机器学习算法,适用于非线性关系的建模。
数据预处理:
选择特征和目标变量:
支持向量回归模型:
模型训练:
模型评估:
调整模型参数:
特征重要性分析(可选):
模型解释:
模型应用:
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.svm import SVR from sklearn.metrics import mean_squared_error import matplotlib.pyplot as plt # 读取数据 data = pd.read_excel('你的数据文件.xlsx') # 数据预处理 # 选择特征和目标变量 X = data[['催化比例', '其他特征1', '其他特征2', ...]] # 添加其他可能的影响因素 y = data['产物产量'] # 分割数据集 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # 支持向量回归模型 # 这里可以根据需要调整SVR的参数,如kernel类型、C值等 model = SVR(kernel='rbf', C=1.0, gamma='scale') model.fit(X_train, y_train) # 模型预测 y_pred = model.predict(X_test) # 模型评估 mse = mean_squared_error(y_test, y_pred) print(f'Mean Squared Error: {mse}') # 绘制真实值与预测值的对比图 plt.scatter(y_test, y_pred) plt.xlabel('真实值') plt.ylabel('预测值')
完整内容点击下方名片详细了解噢~
一起来关注数学建模小秘籍冲刺数位杯最强王者!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。