当前位置:网站首页>【回归预测-lssvm分类】基于最小二乘支持向量机lssvm实现数据分类代码
【回归预测-lssvm分类】基于最小二乘支持向量机lssvm实现数据分类代码
2022-07-30 14:07:00 【Matlab科研工作室】
1 内容介绍
在信息爆炸的新时代,由于全球科技与经济迅猛发展,数据充斥在各行各业,数据的结构也变得多样化.其中对于数据的分类最常见,伴随着数据分类的同时出现两大处理难点,一个是非均衡问题,另一个就是高维问题.但是传统的数据方法在进行数据挖掘时,低维平衡数据被重点关注,传统分类方法有线性判别分析,Logistic判别模型,支持向量机算法,K近邻算法,决策树算法,随机森林算法,神经网络学习,等.但是目前各个领域充斥着大量高维非均衡数据,而传统方法对非均衡数据分类问题的关注比较缺失.目前对于非均衡数据分类时,由于数量本身的严重偏斜,分类器整体的分类准确度良好恰恰归功于多数类样本的正确分类.

2 仿真代码
%基于SVM的iris数据辨识clear;clc;A=load('irisdata.txt'); %导入数据data = A(:,1:4); %1—4列数据是鸢尾花的4个特征:花萼和花瓣的长度和宽度labels = A(:,5); %最后一列是属性标签。1代表山鸢尾(iris-setosa),%2代表变色鸢尾(iris-versicolor),3代表维吉尼亚鸢尾(iris-virginica)%将第一类的1-20,第二类的51-70,第三类的101-120做为训练集train_iris=[data(1:20,:);data(51:70,:);data(101:120,:)];%相应的训练集的标签也要分离出来train_iris_labels = [labels(1:20);labels(51:70);labels(101:120)];%将第一类的21-50,第二类的71-100,第三类的121-150做为测试集test_iris=[data(21:50,:);data(71:100,:);data(121:150,:)];%相应的测试集的标签也要分离出来test_iris_labels = [labels(21:50);labels(71:100);labels(121:150)];%数据预处理 将训练集和测试集进行归一化处理 归一化到[0,1]区间[mtrain,ntrain] = size(train_iris);[mtest,ntest] = size(test_iris);dataset = [train_iris;test_iris];% mapminmax为MATLAB自带的归一化函数[dataset_scale,ps] = mapminmax(dataset',0,1)dataset_scale = dataset_scale';train_iris = dataset_scale(1:mtrain,:);test_iris = dataset_scale( (mtrain+1):(mtrain+mtest),: );% SVM网络训练model = svmtrain(train_iris_labels, train_iris, '-c 2 -g 1');%% SVM网络预测[predict_label,accuracy] = svmpredict(test_iris_labels,test_iris,model);figure;hold on;plot(test_iris_labels,'o');plot(predict_label,'r*');xlabel('测试集样本','FontSize',12);ylabel('类别标签','FontSize',12);legend('实际测试集分类','预测测试集分类');title('测试集的实际分类和预测分类图','FontSize',12);grid on;snapnow;
3 运行结果

4 参考文献
[1]李飞. 基于改进粒子群算法的支持向量机参数优化[D]. 河北工业大学.
[1]沈会. 基于最小二乘支持向量机方法的统计优化预测模型[D]. 武汉理工大学, 2018.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
边栏推荐
- Desktop Software Development Framework Awards
- 网络安全——lcx的使用
- 新一代开源免费的终端工具,太酷了
- PyQt5快速开发与实战 9.1 使用PyInstaller打包项目生成exe文件
- pytorch学习记录(六):循环神经网络 RNN & LSTM
- 六面蚂蚁金服,抗住面试官的狂轰乱炸,前来面试复盘
- Eclipse connects to SQL server database "recommended collection"
- 接口自动化框架,lm-easytest内测版发布,赶紧用起来~
- Flask框架——Sijax
- 吃透Chisel语言.29.Chisel进阶之通信状态机(一)——通信状态机:以闪光灯为例
猜你喜欢

Why did I switch from developer to testing, 3 years software testing engineer, tell you the secret of this

LeetCode二叉树系列——107.二叉树的层序遍历II

八年测试经验,为何惨遭领导痛批:你写的测试文档还不如刚来的应届生

Teach you how to write an eye-catching software testing resume, if you don't receive an interview invitation, I will lose

Data Middle Office Construction (5): Breaking Enterprise Data Silos and Extracting Data Value

容器排序案例

A new generation of open source free terminal tools, so cool

How awesome is the "12306" architecture?

记面试外包公司的一次经历,到底该不该去?

Flask框架——Flask-Mail邮件
随机推荐
开始学习C语言了
The website adds a live 2d kanban girl that can dress up and interact
pytorch学习记录(五):卷积神经网络的实现
The truth of the industry: I will only test those that have no future, and I panic...
Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review
CF1320E Treeland and Viruses
UPC2022 Summer Individual Training Game 19 (B, P)
sql server安装失败怎么办(sql server安装不了怎么办)
【Vue.js 3.0源码】KeepAlive 组件:如何让组件在内存中缓存和调度?
什么是缺陷分析?一篇文章带你了解,测试工程师必备技能
记面试外包公司的一次经历,到底该不该去?
What is the relationship between the construction of smart cities and 5G technology in the new era
JSON常用注解
Digital signal processing course lab report (what foundation is needed for digital signal processing)
LeetCode二叉树系列——145.二叉树的后序遍历
Eight years of testing experience, why was the leader criticized: the test documents you wrote are not as good as those of fresh graduates
PyQt5快速开发与实战 9.1 使用PyInstaller打包项目生成exe文件
Recommended open source tools: MegPeak, a high-performance computing tool
Huawei's 7-year-experienced software testing director, gives some advice to all friends who want to change careers to learn software testing
Remember an experience of interviewing an outsourcing company, should you go?