资源简介
粒子群优化的支持向量机matlab源代码 有自己的部分还有其他人的需要可以下载

代码片段和文件信息
%% 清空环境
clc
clear
load matlab111.mat
%% 载入数据
train= data_train‘;
train_label =label_train‘;
test =data_test‘;
test_label =label_test‘;
[trainpstrain] = mapminmax(train‘);
pstrain.ymin = 0;
pstrain.ymax = 1;
[trainpstrain] = mapminmax(trainpstrain);
[testpstest] = mapminmax(test‘);
pstest.ymin = 0;
pstest.ymax = 1;
[testpstest] = mapminmax(testpstest);
train = train‘;
test = test‘;
%% 参数初始化
%粒子群算法中的两个参数
c1 = 1.6; % c1 belongs to [02]
c2 = 1.5; % c2 belongs to [02]
maxgen=300; % 进化次数
sizepop=30; % 种群规模
popcmax=10^(2);
popcmin=10^(-1);
popgmax=10^(3);
popgmin=10^(-2);
k = 0.6; % k belongs to [0.11.0];
Vcmax = k*popcmax;
Vcmin = -Vcmax ;
Vgmax = k*popgmax;
Vgmin = -Vgmax ;
% SVM参数初始化
v = 3;
%% 产生初始粒子和速度
for i=1:sizepop
% 随机产生种群
pop(i1) = (popcmax-popcmin)*rand+popcmin; % 初始种群
pop(i2) = (popgmax-popgmin)*rand+popgmin;
V(i1)=Vcmax*rands(1); % 初始化速度
V(i2)=Vgmax*rands(1);
% 计算初始适应度
cmd = [‘-v ‘num2str(v)‘ -c ‘num2str( pop(i1) )‘ -g ‘num2str( pop(i2) )];
fitness(i) = svmtrain(train_label train cmd);
fitness(i) = -fitness(i);
end
% 找极值和极值点
[global_fitness bestindex]=min(fitness); % 全局极值
local_fitness=fitness; % 个体极值初始化
global_x=pop(bestindex:); % 全局极值点
local_x=pop; % 个体极值点初始化
tic
%% 迭代寻优
for i=1:maxgen
for j=1:sizepop
%速度更新
wV = 0.9; % wV best belongs to [0.81.2]
V(j:) = wV*V(j:) + c1*rand*(local_x(j:) - pop(j:)) + c2*rand*(global_x - pop(j:));
if V(j1) > Vcmax
V(j1) = Vcmax;
end
if V(j1) < Vcmin
V(j1) = Vcmin;
end
if V(j2) > Vgmax
V(j2) = Vgmax;
end
if V(j2) < Vgmin
V(j2) = Vgmin;
end
%种群更新
wP = 0.6;
pop(j:)=pop(j:)+wP*V(j:);
if pop(j1) > popcmax
pop(j1) = popcmax;
end
if pop(j1) < popcmin
pop(j1) = popcmin;
end
if pop(j2) > popgmax
pop(j2) = popgmax;
end
if pop(j2) < popgmin
pop(j2) = popgmin;
end
% 自适应粒子变异
if rand>0.5
k=ceil(2*rand);
if k == 1
pop(jk) = (20-1)*rand+1;
end
if k == 2
pop(jk) = (popgmax-popgmin)*rand+popgmin;
end
end
%适应度值
cmd = [‘-v ‘num2str(v)‘ -c ‘num2str( pop(j1) )‘ -g ‘num2str( pop(j2) )];
fitness(j) = svmtrain(train_label train cmd);
fitness(j) = -fitness(j);
end
%个体最优更新
if fitness(j) < local_fitness(j)
local_x(j:) = pop(j:);
local_fitness(j) = fitness(j);
end
%群体最优更新
if fitness(j) < global_fitness
global_x = pop(j:);
global_fitness = fitness(j);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9187 2018-04-18 16:18 pso-SVM\matlab111.mat
文件 3957 2018-04-18 20:13 pso-SVM\psoSVM.m
文件 20168 2010-01-30 18:38 pso-SVM\wine.mat
- 上一篇:偏最小二乘算法多输入单输出系统
- 下一篇:polar码的SC译码算法matlab实现
相关资源
- 粒子群算法matlab工具箱
- 基于粒子群算法的非合作博弈的matl
- SVM的回归预测分析——上证指数开盘
- 粒子群算法优化pid源码 matlab仿真.ra
- 粒子群算法优化RBF网络matlab源码
- zw_支持向量机与朴素贝叶斯算法matl
- 基本粒子群算法,MATLAB文件的M文件编
- svm支持向量机与nbc朴素贝叶斯算法比
- 有约束的基于适应度和连续世代策略
- 粒子群算法求解函数优化问题.zip
- svm 支持向量机 回归 预测
- 支持向量机的matlab实现及相应Demo
- matlab粒子群算法PSO实现函数极值优化
- 神经网络、遗传算法、支持向量机、
- 支持向量机matlab
- 遗传算法优化支持向量机GASVM
- 支持向量机matlab工具箱含资料及gui模
- 最新版,最小二乘支持向量机2010年
- l粒子群算法工具箱psot
- 最小二乘支持向量机matlab程序+使用教
- MATLAB.遗传算法和粒子群算法程序设计
- 支持向量机回归smo的matlab实现 附带测
- 支持向量机 SVM 和 核函数的 MATLAB 程序
- 支持向量机SVM和核函数的matlab程序代
- 最小二乘支持向量机MATLAB程序附详细
- 神经网络的43个源程序及数据
- MATLAB实现支持向量机的图像分类:完
- HOG_SVM的行人检测
- 多目标粒子群社团检测算法MODPSO
- 蜂群SVMABC-SVM遗传算法SVMGA-SVM粒子群
评论
共有 条评论