当前位置:网站首页>【回归预测-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代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
边栏推荐
- 自动化测试之数据驱动DDT详细篇
- Baijiahao cancels the function of posting documents on the interface: the weight of the plug-in chain is blocked
- LeetCode二叉树系列——515.最每个树行中找最大值
- ARC115F Migration
- Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review
- Application of time series database in the field of ship risk management
- #第九章 子查询课后习题
- CF338E Optimize!
- 近两年激光雷达运动物体分割论文阅读小结
- selenium4+pyetsst+allure+pom进行自动化测试框架的最新设计
猜你喜欢

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

(HR Interview) Most Common Interview Questions and Skilled Answers

近两年激光雷达运动物体分割论文阅读小结

一文读懂网络效应对Web3的重要意义

如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南

Why do software testing have to learn automation?Talk about the value of automated testing in my eyes

Meta首份元宇宙白皮书9大看点,瞄准80万亿美元市场

Eight years of testing experience, why was the leader criticized: the test documents you wrote are not as good as those of fresh graduates

自动化测试之数据驱动DDT详细篇

VLAN实验
随机推荐
JSON常用注解
AT4108 [ARC094D] Normalization
A simple change for problem, knapsack problem sets of shell
LeetCode_98_验证二叉搜索树
Web3创始人和建设者必备指南:如何构建适合的社区?
Huawei's 7-year-experienced software testing director, gives some advice to all friends who want to change careers to learn software testing
PyQt5快速开发与实战 9.1 使用PyInstaller打包项目生成exe文件
开始学习C语言了
The truth of the industry: I will only test those that have no future, and I panic...
Remember an experience of interviewing an outsourcing company, should you go?
The path to uniting the programmer: "titles bucket" to the highest state of pragmatic
pytorch与keras的相互转换(代码以LeNet-5为例)
ECCV 2022 | 通往数据高效的Transformer目标检测器
ddl and dml in sql (the difference between sql and access)
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
CF1677E Tokitsukaze and Beautiful Subsegments
还在说软件测试没有中年危机?9年测试工程师惨遭淘汰
Classic test interview questions set - logical reasoning questions
吃透Chisel语言.28.Chisel进阶之有限状态机(二)——Mealy状态机及与Moore状态机的对比
cookie模拟登录「建议收藏」