预测模型基于哈里斯鹰改进核极限学习机(KELM)分类算法 matlab源码

Posted 博主QQ2449341593

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了预测模型基于哈里斯鹰改进核极限学习机(KELM)分类算法 matlab源码相关的知识,希望对你有一定的参考价值。

一、核极限学习机

本文将介绍一种新的SLFN的算法,极限学习机,该算法将随机产生输入层和隐含层间的连接权值和隐含层神经元的阈值,且在训练过程中无需调整,只需要设置隐含层的神经元的个数,便可以获得唯一最优解,与传统的训练方法相比,该方法具有学习速率快、泛化性能好等优点。

典型的单隐层前馈神经网络如上图所示,输入层与隐含层,隐含层与输出层之间是全连接的。输入层的神经元的个数是根据样本的而特征数的多少来确定的,输出层的神经元的个数是根据样本的种类数来确定的

设隐含层神经元的阈值 b为:


当隐层神经元的个数和样本数相同时(10)式有唯一的解,也就是说零误差的逼近训练样本。通常的学习算法中,W和b需要不断进行调整,但研究结果告诉我们,他们事实上是不需要进行不断调整的,甚至可以随意指定。调整他们不仅费时,而且并没有太多的好处。(此处有疑虑,可能是断章取义,这个结论有可能是基于某个前提下的)。

二、哈里斯鹰算法

三、代码介绍

function [TrainingTime, TestingTime, TrainingAccuracy, TestingAccuracy] = elm_kernel(TrainingData, TestingData, Elm_Type, Regularization_coefficient, Kernel_type, Kernel_para)

% Usage: elm(TrainingData_File, TestingData_File, Elm_Type, NumberofHiddenNeurons, ActivationFunction)
% OR:    [TrainingTime, TestingTime, TrainingAccuracy, TestingAccuracy] = elm(TrainingData_File, TestingData_File, Elm_Type, NumberofHiddenNeurons, ActivationFunction)
%
% Input:
% TrainingData_File           - Filename of training data set

tic;
Omega_test = kernel_matrix(P',Kernel_type, Kernel_para,TV.P');
TY=(Omega_test' * OutputWeight)';                            %   TY: the actual output of the testing data
TestingTime=toc

%%%%%%%%%% Calculate training & testing classification accuracy

if Elm_Type == REGRESSION
%%%%%%%%%% Calculate training & testing accuracy (RMSE) for regression case
    TrainingAccuracy=sqrt(mse(T - Y))
    TestingAccuracy=sqrt(mse(TV.T - TY))           
end

if Elm_Type == CLASSIFIER
%%%%%%%%%% Calculate training & testing classification accuracy
    MissClassificationRate_Training=0;
    MissClassificationRate_Testing=0;

    for i = 1 : size(T, 2)
        [x, label_index_expected]=max(T(:,i));
        [x, label_index_actual]=max(Y(:,i));
        if label_index_actual~=label_index_expected
            MissClassificationRate_Training=MissClassificationRate_Training+1;
        end
    end
    TrainingAccuracy=1-MissClassificationRate_Training/size(T,2)  
    for i = 1 : size(TV.T, 2)
        [x, label_index_expected]=max(TV.T(:,i));
        [x, label_index_actual]=max(TY(:,i));
        if label_index_actual~=label_index_expected
            MissClassificationRate_Testing=MissClassificationRate_Testing+1;
        end
    end
    TestingAccuracy=(1-MissClassificationRate_Testing/size(TV.T,2))*100
end
    
    
%%%%%%%%%%%%%%%%%% Kernel Matrix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
function omega = kernel_matrix(Xtrain,kernel_type, kernel_pars,Xt)

nb_data = size(Xtrain,1);


if strcmp(kernel_type,'RBF_kernel'),
    if nargin<4,
        XXh = sum(Xtrain.^2,2)*ones(1,nb_data);
        omega = XXh+XXh'-2*(Xtrain*Xtrain');
        omega = exp(-omega./kernel_pars(1));
    else
        XXh1 = sum(Xtrain.^2,2)*ones(1,size(Xt,1));
        XXh2 = sum(Xt.^2,2)*ones(1,nb_data);
        omega = XXh1+XXh2' - 2*Xtrain*Xt';
        omega = exp(-omega./kernel_pars(1));
    end
    
elseif strcmp(kernel_type,'lin_kernel')
    if nargin<4,
        omega = Xtrain*Xtrain';
    else
        omega = Xtrain*Xt';
    end
    
elseif strcmp(kernel_type,'poly_kernel')
    if nargin<4,
        omega = (Xtrain*Xtrain'+kernel_pars(1)).^kernel_pars(2);
    else
        omega = (Xtrain*Xt'+kernel_pars(1)).^kernel_pars(2);
    end
    
elseif strcmp(kernel_type,'wav_kernel')
    if nargin<4,
        XXh = sum(Xtrain.^2,2)*ones(1,nb_data);
        omega = XXh+XXh'-2*(Xtrain*Xtrain');
        
        XXh1 = sum(Xtrain,2)*ones(1,nb_data);
        omega1 = XXh1-XXh1';
        omega = cos(kernel_pars(3)*omega1./kernel_pars(2)).*exp(-omega./kernel_pars(1));
        
    else
        XXh1 = sum(Xtrain.^2,2)*ones(1,size(Xt,1));
        XXh2 = sum(Xt.^2,2)*ones(1,nb_data);
        omega = XXh1+XXh2' - 2*(Xtrain*Xt');
        
        XXh11 = sum(Xtrain,2)*ones(1,size(Xt,1));
        XXh22 = sum(Xt,2)*ones(1,nb_data);
        omega1 = XXh11-XXh22';
        
        omega = cos(kernel_pars(3)*omega1./kernel_pars(2)).*exp(-omega./kernel_pars(1));
    end
end

在这里插入图片描述

测试集结果如下图所示:
在这里插入图片描述

四、参考文献

完整代码下载https://www.cnblogs.com/ttmatlab/p/14882966.html

以上是关于预测模型基于哈里斯鹰改进核极限学习机(KELM)分类算法 matlab源码的主要内容,如果未能解决你的问题,请参考以下文章

回归预测基于matlab哈里斯鹰算法优化混合核极限学习机KELM回归预测含Matlab源码 1751期

预测模型基于遗传算法改进核极限学习机(KELM)分类算法 matlab源码

预测模型基于麻雀算法改进核极限学习机(KELM)分类算法 matlab源码

预测模型基于遗传算法改进核极限学习机(KELM)分类算法 matlab源码

预测模型基于麻雀算法改进核极限学习机(KELM)分类算法 matlab源码

预测模型基于狮群算法改进核极限学习机(KELM)分类算法 matlab源码