贝叶斯优化XGBoost回归预测(matlab)

贝叶斯优化XGBoost回归预测(matlab)

想要更换数据,替换Excel数据即可运行

代码中含有详细中文注释

可代码定制!

实验结果如下:

贝叶斯优化XGBoost回归预测(matlab)_第1张图片

贝叶斯优化XGBoost回归预测(matlab)_第2张图片

贝叶斯优化XGBoost回归预测(matlab)_第3张图片

贝叶斯优化XGBoost回归预测(matlab)_第4张图片

部分代码如下:

clc;
clear;
close all;
% 导入数据
data = xlsread('数据集.xlsx');
%% 数据划分
x_feature_label = data(:, 1:end-1);   % x特征
y_feature_label = data(:, end);       % y标签
index_label = 1:length(x_feature_label);
spilt_ri = [8, 2];  % 划分比例 训练集:测试集
train_num = round(spilt_ri(1) / (sum(spilt_ri)) * length(x_feature_label));
train_x_feature_label = x_feature_label(index_label(1:train_num), :);
train_y_feature_label = y_feature_label(index_label(1:train_num), :);
test_x_feature_label = x_feature_label(index_label(train_num + 1:end), :);
test_y_feature_label = y_feature_label(index_label(train_num + 1:end), :);
% Zscore标准化
x_mu = mean(train_x_feature_label);
x_sig = std(train_x_feature_label);
train_x_feature_label_norm = (train_x_feature_label - x_mu) ./ x_sig;
y_mu = mean(train_y_feature_label);
y_sig = std(train_y_feature_label);
train_y_feature_label_norm = (train_y_feature_label - y_mu) ./ y_sig;
test_x_feature_label_norm = (test_x_feature_label - x_mu) ./ x_sig;
test_y_feature_label_norm = (test_y_feature_label - y_mu) ./ y_sig;
%% 算法处理块
disp('贝叶斯优化XGBoost回归');
t1 = clock;
Tmax = 30; % 贝叶斯优化最大迭代次数

你可能感兴趣的:(回归,matlab,数据挖掘)