资源简介
混凝土抗压强度预测_SVM_Matlab_归一_实例
![](http://www.nz998.com/pic/56819.jpg)
代码片段和文件信息
%% 第29章 支持向量机的回归拟合——混凝土抗压强度预测
%
% 该案例作者申明: 1:本人长期驻扎在此板块里,对该案例提问,做到有问必答。 2:此案例有配套的教学视频,视频下载请点击http://www.matlabsky.com/forum-91-1.html。 3:此案例为原创案例,转载请注明出处(《MATLAB智能算法30个案例分析》)。 4:若此案例碰巧与您的研究有关联,我们欢迎您提意见,要求等,我们考虑后可以加在案例里。 5:以下内容为初稿,与实际发行的书籍内容略有出入,请以书籍中的内容为准。
%
%% 清空环境变量
clear all
clc
%% 导入数据
load concrete_data.mat
% 随机产生训练集和测试集
n = randperm(size(attributes2));
% 训练集——80个样本
p_train = attributes(:n(1:80))‘;
t_train = strength(:n(1:80))‘;
% 测试集——23个样本
p_test = attributes(:n(81:end))‘;
t_test = strength(:n(81:end))‘;
%% 数据归一化
% 训练集
[pn_traininputps] = mapminmax(p_train‘);
pn_train = pn_train‘;
pn_test = mapminmax(‘apply‘p_test‘inputps);
pn_test = pn_test‘;
% 测试集
[tn_trainoutputps] = mapminmax(t_train‘);
tn_train = tn_train‘;
tn_test = mapminmax(‘apply‘t_test‘outputps);
tn_test = tn_test‘;
%% SVM模型创建/训练
% 寻找最佳c参数/g参数
[cg] = meshgrid(-10:0.5:10-10:0.5:10);
[mn] = size(c);
cg = zeros(mn);
eps = 10^(-4);
v = 5;
bestc = 0;
bestg = 0;
error = Inf;
for i = 1:m
for j = 1:n
cmd = [‘-v ‘num2str(v)‘ -t 2‘‘ -c ‘num2str(2^c(ij))‘ -g ‘num2str(2^g(ij) )‘ -s 3 -p 0.1‘];
cg(ij) = svmtrain(tn_trainpn_traincmd);
if cg(ij) < error
error = cg(ij);
bestc = 2^c(ij);
bestg = 2^g(ij);
end
if abs(cg(ij) - error) <= eps && bestc > 2^c(ij)
error = cg(ij);
bestc = 2^c(ij);
bestg = 2^g(ij);
end
end
end
% 创建/训练SVM
cmd = [‘ -t 2‘‘ -c ‘num2str(bestc)‘ -g ‘num2str(bestg)‘ -s 3 -p 0.01‘];
model = svmtrain(tn_trainpn_traincmd);
%% SVM仿真预测
[Predict_1error_1] = svmpredict(tn_trainpn_trainmodel);
[Predict_2error_2] = svmpredict(tn_testpn_testmodel);
% 反归一化
predict_1 = mapminmax(‘reverse‘Predict_1outputps);
predict_2 = mapminmax(‘reverse‘Predict_2outputps);
% 结果对比
result_1 = [t_train predict_1];
result_2 = [t_test predict_2];
%% 绘图
figure(1)
plot(1:length(t_train)t_train‘r-*‘1:length(t_train)predict_1‘b:o‘)
grid on
legend(‘真实值‘‘预测值‘)
xlabel(‘样本编号‘)
ylabel(‘耐压强度‘)
string_1 = {‘训练集预测结果对比‘;
[‘mse = ‘ num2str(error_1(2)) ‘ R^2 = ‘ num2str(error_1(3))]};
title(string_1)
figure(2)
plot(1:length(t_test)t_test‘r-*‘1:length(t_test)predict_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2286 2010-11-04 20:07 混凝土抗压强度预测\concrete_data.mat
文件 4841 2015-06-17 16:06 混凝土抗压强度预测\main.m
目录 0 2018-03-16 18:12 混凝土抗压强度预测\
- 上一篇:MATLAB之LSTM预测
- 下一篇:Aloha系统MATLAB仿真代码
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论