基于最小二乘支持向量机(LS-SVM)进行分类、函数估计、时间序列预测和无监督学习附Matlab代码

​✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

最小二乘支持向量机是支持向量机的一种改进,它是将传统支持向量机中的不等式约束改为等式约束, 且将误差平方和(SumSquaresError)损失函数作为训练集的经验损失,这样就把解二次规划问题转化为求解线性方程组问题, 提高求解问题的速度和收敛精度。

常用的核函数种类:

2、LSSVM工具箱的使用方法

2.1 最小二乘支持向量机Matlab工具箱下载链接:https://www.esat.kuleuven.be/sista/lssvmlab/(毫无疑问下载最新版本)

2.2 将LS-SVM文件添加到matlan使用路径中,便可直接使用。

具体使用步骤:

1 导入训练数据:load 读取mat文件和ASCII文件;xlsread读取.xls文件;csvread读取.csv文件。

2 数据预处理:效果是加快训练速度。

方法有:归一化处理(把每组数据都变为 - 1~ +1之间的数, 所涉及到的函数有premnmx, post mnmx, tramnmx)

              标准化处理(把每组数据都化为均值为 0, 方差为 1的一组数据, 所涉及到的函数有 prestd,poatstd, trastd)

             主成分分析 (进行正交处理, 减少输入数据的维数, 所涉及到的函数有 prepca, trapca)

3  LS-SVM lab用于函数回归主要用到 3个函数, trainlssvm函数用来训练建立模型, simlssvm函数用于预估模型, plotlssvm函数是 LS-SVM lab工具箱的专用绘图函数。

⛄ 部分代码

clc;

disp('This is a simple demo, solving a simple regression task using');

disp('LS-SVMlab and constructing confidence intervals. A dataset is constructed in the right formatting. The');

disp('data are represented as matrices where each row contains one');

disp('datapoint: ');

disp(' ');

disp('press <ENTER> key'); pause

disp(' ');

disp('>> X = (-3:0.02:3)'';');

X = (-3:0.02:3)';

disp('>> Y = sinc(X)+0.1.*randn(length(X),1);');

eval('Y = sinc(X)+0.1.*randn(length(X),1);',...

     'Y = sin(pi.*X+12345*eps)./(pi*X+12345*eps)+0.1.*randn(length(X),1);');

disp('>> X');

X

disp('>> Y');

Y

disp('In order to make an LS-SVM model, we need 2 extra parameters: gamma');

disp('(gam) is the regularization parameter, determining the trade-off');

disp('between the fitting error minimization and smoothness of the');

disp('estimated function. sigma^2 (sig2) is the kernel function');

disp('parameter of the RBF kernel. These can be found via cross-validation:');

disp(' ');

model = initlssvm(X,Y,'f',[],[],'RBF_kernel','o');

disp('>> model = tunelssvm(model,''simplex'',''crossvalidatelssvm'',{10,''mse''});');

model = tunelssvm(model,'simplex','crossvalidatelssvm',{10,'mse'});

disp(' ');

disp('press <ENTER> key'); pause

disp(' ');

disp('Training the model ');

disp(' ');

disp('>> model = trainlssvm(model)');

model = trainlssvm(model);

disp(' ');

disp('Computation of Confidence Intervals ');

disp(' ');

disp('press <ENTER> key'); pause

disp('ci = cilssvm(model);')

ci = cilssvm(model);

disp('The LS-SVM result and confidence intervals can be displayed if the dimension of the input');

disp('data is 1 or 2. ');

disp(' ');

disp('>> plotlssvm(model);');

figure; plotlssvm(model);

disp(' ');

hold all

fill([X;flipud(X)],[ci(:,1);flipud(ci(:,2))],'c','FaceAlpha',0.5,'EdgeAlpha',1,'EdgeColor','w')

disp('All plotting is done with this simple command. It looks for the');

disp('best way of displaying the result.') 

disp(' ');

disp(' This concludes the demo');

⛄ 运行结果

⛄ 参考文献

❤️ 关注我领取海量matlab电子书和数学建模资料

❤️部分理论引用网络文献,若有侵权联系博主删除

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值