【RVM分类】基于麻雀搜索算法优化相关向量机实现数据分类附matlab代码
1 简介
目前常用的一些基本的故障诊断,故障预测方法都将大样本数据作为基础,但在实际问题中常常能得到的故障数据都属于小样本类型.传统的故障诊断,故障预测方法已不适于用来解决小样本类型的故障问题.相关向量机(Relevance Vector Machine,简称RVM)是新提出的以支持向量机(Support Vector Machine,简称SVM)为基础的模型,该模型更适应于解决小样本问题.已经被应用于语音及图像处理,医学诊断,模式分类等很多领域.
2 部分代码
%_________________________________________________________________________%
麻雀优化算法 %
%_________________________________________________________________________%
function [Best_pos,Best_score,curve]=SSA(pop,Max_iter,lb,ub,dim,fobj)
ST = 0.6;%预警值
PD = 0.7;%发现者的比列,剩下的是加入者
SD = 0.2;%意识到有危险麻雀的比重
PDNumber = pop*PD; %发现者数量
SDNumber = pop - pop*PD;%意识到有危险麻雀数量
= 1) =
ub = ub.*ones(1,dim);
lb = lb.*ones(1,dim);
end
%种群初始化
X0=initialization(pop,dim,ub,lb);
X = X0;
%计算初始适应度值
fitness = zeros(1,pop);
for i = 1:pop
fobj(X(i,:)); =
end
index]= sort(fitness);%排序
BestF = fitness(1);
WorstF = fitness(end);
GBestF = fitness(1);%全局最优适应度值
for i = 1:pop
) = X0(index(i),:); :
end
curve=zeros(1,Max_iter);
GBestX = X(1,:);%全局最优位置
X_new = X;
for i = 1: Max_iter
BestF = fitness(1);
WorstF = fitness(end);
R2 = rand(1);
for j = 1:PDNumber
if(R2<ST)
) = X(j,:).*exp(-j/(rand(1)*Max_iter)); :
else
) = X(j,:) + randn()*ones(1,dim); :
end
end
for j = PDNumber+1:pop
if(j>(pop/2))
- PDNumber)/2 + PDNumber)
)= randn().*exp((X(end,:) - X(j,:))/j^2); :
else
%产生-1,1的随机数
A = ones(1,dim);
for a = 1:dim
if(rand()>0.5)
-1; =
end
end
AA = A'*inv(A*A');
)= X(1,:) + abs(X(j,:) - X(1,:)).*AA'; :
end
end
Temp = randperm(pop);
SDchooseIndex = Temp(1:SDNumber);
for j = 1:SDNumber
if(fitness(SDchooseIndex(j))>BestF)
) = X(1,:) + randn().*abs(X(SDchooseIndex(j),:) - X(1,:)); :
= BestF) =
K = 2*rand() -1;
) = X(SDchooseIndex(j),:) + K.*(abs( X(SDchooseIndex(j),:) - X(end,:))./(fitness(SDchooseIndex(j)) - fitness(end) + 10^-8)); :
end
end
%边界控制
for j = 1:pop
for a = 1: dim
if(X_new(j,a)>ub)
ub(a); =
end
if(X_new(j,a)<lb)
lb(a); =
end
end
end
%更新位置
for j=1:pop
fobj(X_new(j,:)); =
end
for j = 1:pop
< GBestF)
GBestF = fitness_new(j);
GBestX = X_new(j,:);
end
end
X = X_new;
fitness = fitness_new;
%排序更新
index]= sort(fitness);%排序
BestF = fitness(1);
WorstF = fitness(end);
for j = 1:pop
) = X(index(j),:); :
end
GBestF; =
end
Best_pos =GBestX;
Best_score = curve(end);
end
3 仿真结果
4 参考文献
[1]马晨佩, 李明辉, 巩强令,等. 基于麻雀搜索算法优化支持向量机的滚动轴承故障诊断[J]. 科学技术与工程, 2021, 21(10):5.