├── MKELM ├── AverageMKELM.m ├── AveragemulticlassMKELM.m ├── basicRadius.m ├── datasets │ └── heart_Kmatrix.mat ├── kcenter.m ├── knorm.m ├── minBallRadius.m ├── mkELM_demo.m ├── mkMulticlassELM.m ├── mkMulticlassRadiusELM.m ├── multiclassELM.m ├── mymonqp.m └── sumKbeta.m └── README.md /MKELM/AverageMKELM.m: -------------------------------------------------------------------------------- 1 | function [alpha] = AverageMKELM(K,C,Y) 2 | numKer = size(K,3); 3 | numTrn = size(K,1); 4 | gamma0 = ones(numKer,1)/numKer; 5 | KC = sumKbeta(K,gamma0); 6 | 7 | alpha = (KC+eye(numTrn)/C)\Y; -------------------------------------------------------------------------------- /MKELM/AveragemulticlassMKELM.m: -------------------------------------------------------------------------------- 1 | function [alpha] = AveragemulticlassMKELM(K,C,Y) 2 | 3 | classIndx = unique(Y); 4 | numClass = length(classIndx); 5 | numTrn = size(K,1); 6 | %%% YF coding class information. 7 | YF = zeros(numTrn,numClass); 8 | for i =1:numTrn 9 | for c =1:numClass 10 | if Y(i)==classIndx(c) 11 | YF(i,c) = 1; 12 | end 13 | end 14 | end 15 | numKer = size(K,3); 16 | gamma0 = ones(numKer,1)/numKer; 17 | KC = sumKbeta(K,gamma0); 18 | %%%% alpha should be numTrn*numClass 19 | alpha = (KC+eye(numTrn)/C)\YF; -------------------------------------------------------------------------------- /MKELM/basicRadius.m: -------------------------------------------------------------------------------- 1 | function [radiusp]= basicRadius(K) 2 | 3 | d=size(K,3); 4 | n=size(K,1); 5 | 6 | radiusp = zeros(d,1); 7 | for p = 1:d 8 | H= 2 * K(:,:,p); 9 | f= diag(K(:,:,p)); 10 | A=ones(n,1); 11 | b=1; 12 | B=1; 13 | [beta, lambdat, pos] = mymonqp(H,f,A,b,B); 14 | 15 | optimalBeta=zeros(n,1); 16 | optimalBeta(pos)=beta; 17 | 18 | radiusp(p) = -0.5*optimalBeta'*H*optimalBeta + f'*optimalBeta; 19 | end 20 | -------------------------------------------------------------------------------- /MKELM/datasets/heart_Kmatrix.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangsiwei2010/Multi-Kernel-Extreme-Learning-Machine/ad95b67ea2bfa8b88021e0559bf382bdc779c2b5/MKELM/datasets/heart_Kmatrix.mat -------------------------------------------------------------------------------- /MKELM/kcenter.m: -------------------------------------------------------------------------------- 1 | function K = kcenter(K) 2 | % kcenter - center a kernel matrix 3 | % 4 | % Synopsis: 5 | % Kc = kcenter(K); 6 | % 7 | % Arguments: 8 | % K: Kernel matrix 9 | % 10 | % Return: 11 | % Kc: centered kernel matrix 12 | % 13 | % Code-Reference: 14 | % Shawe-Taylor, Cristianini, 'Kernel Methods for Pattern Analysis', 15 | % Cambridge University Press, 2004, http://www.kernel-methods.net 16 | % 17 | % Authors: K. Rieck, M. Kloft 18 | % 19 | 20 | n = size(K,2); 21 | 22 | if ismatrix(K) 23 | 24 | D = sum(K) / n; 25 | E = sum(D) / n; 26 | J = ones(n,1) * D; 27 | K = K - J - J' + E * ones(n, n); 28 | K = 0.5 * (K + K'); 29 | 30 | elseif ndims(K)==3 31 | 32 | for i=1:size(K,3) 33 | D = sum(K(:,:,i)) / n; 34 | E = sum(D) / n; 35 | J = ones(n,1) * D; 36 | K(:,:,i) = K(:,:,i) - J - J' + E * ones(n, n); 37 | K(:,:,i) = 0.5 * (K(:,:,i) + K(:,:,i)') + 1e-12*eye(n); 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /MKELM/knorm.m: -------------------------------------------------------------------------------- 1 | function K = knorm(K) 2 | % knorm - normalize a kernel matrix 3 | % 4 | % Synopsis: 5 | % K = knorm(K); 6 | % 7 | % Arguments: 8 | % K: kernel matrix (n x n) 9 | % 10 | % Returns: 11 | % K: normalized kernel matrix 12 | % 13 | % Description: 14 | % kn(x,y) = k(x,y) / sqrt(k(x,x) k(y,y)) 15 | % 16 | % $Id: knorm.m,v 1.1 2005/05/30 12:07:21 neuro_cvs Exp $ 17 | % 18 | % Copyright (C) 2005 Fraunhofer FIRST 19 | % Author: Konrad Rieck (rieck@first.fhg.de) 20 | % Modified by Marius Kloft 21 | 22 | if size(K,3)>1 23 | for i=1:size(K,3) 24 | K(:,:,i) = K(:,:,i) ./ sqrt(diag(K(:,:,i)) * diag(K(:,:,i))'); 25 | end 26 | else 27 | K = K ./ sqrt(diag(K) * diag(K)'); 28 | end 29 | 30 | -------------------------------------------------------------------------------- /MKELM/minBallRadius.m: -------------------------------------------------------------------------------- 1 | function [radius, optimalBeta]= minBallRadius(K) 2 | 3 | n=size(K,1); 4 | H=2*K; 5 | f=diag(K); 6 | A=ones(n,1); 7 | b=1; 8 | C=1; 9 | 10 | [beta, lambda, pos] = mymonqp(H,f,A,b,C); 11 | optimalBeta=zeros(n,1); 12 | optimalBeta(pos)=beta; 13 | 14 | radius = -0.5*optimalBeta'*H*optimalBeta + f'*optimalBeta; 15 | -------------------------------------------------------------------------------- /MKELM/mkELM_demo.m: -------------------------------------------------------------------------------- 1 | clear 2 | clc 3 | warning off; 4 | path = '.\'; 5 | addpath(genpath(path)); 6 | dataName = 'heart'; %%% flower17; flower102; CCV; caltech101_numofbasekernel_10 7 | %% UCI_DIGIT; proteinFold; psortPos 8 | %% washington; wisconsin; texas; cornell 9 | %% AR10P 10 | %% caltech101_10base 11 | load([path,'datasets\',dataName,'_Kmatrix'],'K','Y'); 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | if min(Y)==-1 14 | Y(Y==-1)=2; 15 | end 16 | numclass = length(unique(Y)); 17 | numker = size(K,3); 18 | num = size(K,1); 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | K = kcenter(K); 21 | % K = knorm(K); 22 | 23 | %%%--- Training----%%%%%%%%% 24 | C=1; %% Needing to be tuned 25 | qnorm = 2; %% 26 | [gamma1,alpha1,obj1] = mkMulticlassELM(K,C,Y,qnorm); 27 | %%%%----Test-----%%%%%%%%%%%%%%%%%%%%%% 28 | [val1,indx1] = max(sumKbeta(K,gamma1)*alpha1,[],2); 29 | acc(1) = mean(indx1==Y); 30 | 31 | %%%%---Radius-Incorporated MK-ELM--%%%%%%%%%%% 32 | [gamma2,alpha2,obj2] = mkMulticlassRadiusELM(K,C,Y,qnorm); 33 | %%%%----Test-----%%%%%%%%%%%%%%%%%%%%%% 34 | [val2,indx2] = max(sumKbeta(K,gamma2)*alpha2,[],2); 35 | acc(2) = mean(indx2==Y); -------------------------------------------------------------------------------- /MKELM/mkMulticlassELM.m: -------------------------------------------------------------------------------- 1 | function [gamma,alpha,obj] = mkMulticlassELM(K,C,Y,qnorm) 2 | 3 | numKer = size(K,3); 4 | numTrn = size(K,1); 5 | classIndx = unique(Y); 6 | numClass = length(classIndx); 7 | %%% YF coding class information. 8 | YF = zeros(numTrn,numClass); 9 | for i =1:numTrn 10 | for ic =1:numClass 11 | if Y(i)==classIndx(ic) 12 | YF(i,ic) = 1; 13 | end 14 | end 15 | end 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | gamma0 = ones(numKer,1)*numKer^(-1/qnorm); 18 | flag =1; 19 | iter =1; 20 | objold = inf; 21 | maxIter = 500; 22 | while flag 23 | KC = sumKbeta(K,gamma0); 24 | %%%%%% alpha step %%%%%%%%%%% 25 | alpha = (KC+eye(numTrn)/C)\YF; 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | tmp0 = 0; 28 | for ic =1:numClass 29 | tmp0 = tmp0 + 0.5*alpha(:,ic)'*(KC+eye(numTrn)/C)*alpha(:,ic); 30 | end 31 | obj(iter) = tmp0; 32 | tmp = zeros(numKer,numClass); 33 | for ik =1:numKer 34 | for ic =1:numClass 35 | tmp(ik,ic) = gamma0(ik)^2*(alpha(:,ic)'*K(:,:,ik)*alpha(:,ic)); 36 | end 37 | end 38 | tmp1 = sum(tmp,2); 39 | gamma = (tmp1.^(1/(1+qnorm)))/(sum(tmp1.^(qnorm/(1+qnorm))))^(1/qnorm); 40 | if (max(abs(gamma-gamma0))<1e-4)|| (abs(obj(iter)-objold)/obj(iter))<1e-4 || (iter>maxIter) 41 | flag =0; 42 | end 43 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 44 | gamma0 = gamma; 45 | objold = obj(iter); 46 | iter = iter +1; 47 | end -------------------------------------------------------------------------------- /MKELM/mkMulticlassRadiusELM.m: -------------------------------------------------------------------------------- 1 | function [gamma,alpha,obj] = mkMulticlassRadiusELM(K,C,Y,qnorm) 2 | 3 | numKer = size(K,3); 4 | numTrn = size(K,1); 5 | 6 | [radiusp]= basicRadius(K); 7 | 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | classIndx = unique(Y); 10 | numClass = length(classIndx); 11 | %%% YF coding class information. 12 | YF = zeros(numTrn,numClass); 13 | for i =1:numTrn 14 | for ic =1:numClass 15 | if Y(i)==classIndx(ic) 16 | YF(i,ic) = 1; 17 | end 18 | end 19 | end 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | gamma0 = ones(numKer,1)./(radiusp*numKer).^qnorm; 22 | 23 | flag =1; 24 | iter =1; 25 | objold = inf; 26 | maxIter = 500; 27 | while flag 28 | KC = sumKbeta(K,gamma0); 29 | %%%%%% alpha step %%%%%%%%%%% 30 | alpha = (KC+eye(numTrn)/C)\YF; 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | tmp0 = 0; 33 | for ic =1:numClass 34 | tmp0 = tmp0 + 0.5*alpha(:,ic)'*(KC+eye(numTrn)/C)*alpha(:,ic); 35 | end 36 | obj(iter) = tmp0; 37 | 38 | tmp = zeros(numKer,numClass); 39 | for ik =1:numKer 40 | for ic =1:numClass 41 | tmp(ik,ic) = gamma0(ik)^2*(alpha(:,ic)'*K(:,:,ik)*alpha(:,ic)); 42 | end 43 | end 44 | tmp1 = (sum(tmp,2)); 45 | 46 | gamma = (tmp1.^(1/(qnorm+1)))./(radiusp.^(1/(qnorm+1))*sum((radiusp.^(1/(qnorm+1))).*(tmp1.^(qnorm/(qnorm+1))))^(1/qnorm)); 47 | %%% gamma = tmp1./(sqrt(radiusp)*sum(tmp1.*sqrt(radiusp))); 48 | if (max(abs(gamma-gamma0))<1e-4)|| (abs(obj(iter)-objold)/obj(iter))<1e-4 || (iter>maxIter) 49 | flag =0; 50 | end 51 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 52 | gamma0 = gamma; 53 | objold = obj(iter); 54 | iter = iter +1; 55 | end 56 | -------------------------------------------------------------------------------- /MKELM/multiclassELM.m: -------------------------------------------------------------------------------- 1 | function [alpha] = multiclassELM(K,C,Y) 2 | 3 | classIndx = unique(Y); 4 | numClass = length(classIndx); 5 | numTrn = size(K,1); 6 | %%% YF coding class information. 7 | YF = zeros(numTrn,numClass); 8 | for i =1:numTrn 9 | for c =1:numClass 10 | if Y(i)==classIndx(c) 11 | YF(i,c) = 1; 12 | end 13 | end 14 | end 15 | %%%% alpha should be numTrn*numClass 16 | alpha = (K+eye(numTrn)/C)\YF; -------------------------------------------------------------------------------- /MKELM/mymonqp.m: -------------------------------------------------------------------------------- 1 | function [xnew, lambda, pos,mu] = mymonqp(H,c,A,b,C) 2 | % function [xnew, lambda, pos] = monqp(H,c,A,b,C,l,verbose,X,ps,xinit) 3 | % 4 | % min 1/2 x' H x - c' x 5 | % x 6 | % contrainte A' x = b 7 | % 8 | % et 0 <= x_i <= C_i 9 | % 10 | % Cr?dits : J.P. Yvon (INSA de Rennes) pour l'algorithme 11 | % O. Bodard (Clermont Ferrand) pour le debugage on line 12 | % 13 | % S CANU - scanu@insa-rouen.fr 14 | % Mai 2001 15 | %-------------------------------------------------------------------------- 16 | % verifications 17 | %-------------------------------------------------------------------------- 18 | [n,d] = size(H); 19 | [nl,nc] = size(c); 20 | [nlc,ncc] = size(A); 21 | [nlb,ncb] = size(b); 22 | if d ~= n 23 | error('H must be a squre matrix n by n'); 24 | end 25 | if nl ~= n 26 | error('H and c must have the same number of row'); 27 | end 28 | 29 | if nlc ~= n 30 | error('H and A must have the same number of row'); 31 | end 32 | if nc ~= 1 33 | error('c must be a row vector'); 34 | end 35 | if ncb ~= 1 36 | error('b must be a row vector'); 37 | end 38 | if ncc ~= nlb 39 | error('A'' and b must have the same number of row'); 40 | end 41 | l = 1e-8; 42 | verbose = 0; 43 | C=ones(nl,1)*C; % vectorizing the UpperBound Constraint 44 | xinit=[]; 45 | 46 | fid = 1; %default value, curent matlab window 47 | %-------------------------------------------------------------------------- 48 | 49 | 50 | %-------------------------------------------------------------------------- 51 | % I N I T I A L I S A T I O N 52 | %-------------------------------------------------------------------------- 53 | 54 | OO = zeros(ncc); 55 | H = H+l*eye(length(H)); % preconditionning 56 | xnew = -1*ones(size(C));ness = 0; 57 | ind=1; 58 | if isempty(xinit) 59 | 60 | while (( sum (xnew < 0)) >0 | ( sum(xnew >C(ind)) > 0)) & ness < 100 %% 03/01/2002 61 | ind = randperm(n); 62 | ind = sort(ind(1:ncc)'); 63 | aux=[H(ind,ind) A(ind,:);A(ind,:)' OO]; 64 | aux= aux+l*eye(size(aux)); 65 | if rcond(aux)>1e-12 66 | newsol = aux\[c(ind) ; b]; 67 | xnew = newsol(1:length(ind)); 68 | ness = ness+1; 69 | else 70 | ness=101; 71 | break; 72 | end; 73 | end; 74 | %keyboard 75 | if ness < 100 76 | x = xnew; 77 | lambda = newsol(length(ind)+1:length(ind)+ncc); 78 | else 79 | % Brute Force Initialisation 80 | ind = [1]; 81 | x = C(ind)/2.*ones(size(ind,1),1); 82 | lambda=ones(ncc,1); 83 | 84 | % 85 | % ind = [1;nl]; 86 | % x = C(ind)/2.*ones(size(ind,1),1); 87 | 88 | 89 | end 90 | indsuptot = []; 91 | else % start with a predefined x 92 | indsuptot=find(xinit==C); 93 | indsup=indsuptot; 94 | ind=find(xinit>0 & xinit ~=C) ; 95 | x = xinit(ind); 96 | lambda=ones(ncc,1); 97 | 98 | end; 99 | % Modification for QP without equality constraints 100 | if sum(A==0) 101 | ncc=0; 102 | end 103 | [U,testchol] = chol(H); % Test definite positiveness of H 104 | %-------------------------------------------------------------------------- 105 | % M A I N L O O P 106 | %-------------------------------------------------------------------------- 107 | Jold = 10000000000000000000; 108 | %C = Jold; % for the cost function 109 | if verbose ~= 0 110 | disp(' Cost Delta Cost #support #up saturate'); 111 | nbverbose = 0; 112 | end 113 | 114 | nbiter=0; 115 | STOP = 0; 116 | nbitermax=20*n; 117 | while STOP ~= 1 118 | 119 | nbiter=nbiter+1; 120 | indd = zeros(n,1);indd(ind)=ind;nsup=length(ind);indd(indsuptot)=-1; 121 | if verbose ~= 0 122 | 123 | [J,yx] = cout(H,x,b,C,indd,c,A,b,lambda); 124 | 125 | nbverbose = nbverbose+1; 126 | if nbverbose == 20 127 | disp(' Cost Delta Cost #support #up saturate'); 128 | nbverbose = 0; 129 | end 130 | if Jold == 0 131 | fprintf(fid,'| %11.4e | %8.4f | %6.0f | %6.0f |\n',[J (Jold-J) nsup length(indsuptot)]); 132 | elseif (Jold-J)>0 133 | fprintf(fid,'| %11.4e | %8.4f | %6.0f | %6.0f |\n',[J min((Jold-J)/abs(Jold),99.9999) nsup length(indsuptot)]); 134 | else 135 | fprintf(fid,'| %11.4e | %8.4f | %6.0f | %6.0f | bad mouve \n',[J max((Jold-J)/abs(Jold),-99.9999) nsup length(indsuptot)]); 136 | 137 | end 138 | Jold = J; 139 | 140 | end 141 | 142 | 143 | 144 | 145 | 146 | % nouvele resolution du syst?me 147 | 148 | % newsol = [H(ind,ind)+l*eye(length(ind)) A(ind,:);A(ind,:)' OO]\[c(ind) ; b]; 149 | % xnew = newsol(1:length(ind)); 150 | % lambda = newsol(length(ind)+1:length(newsol)); 151 | 152 | ce = c(ind); 153 | be = b; 154 | 155 | % if (isempty(indsuptot)==0) % if NOT empty 156 | % keyboard 157 | % % ce= ce - C*(sum(H(ind,indsuptot),2)+sum(H(indsuptot,ind),1)');% min x'Hx + c'x 158 | % ce= ce - C*(sum(H(ind,indsuptot),2));% min x'Hx + c'x 159 | % be= be - C*sum(A(indsuptot,:),1)'; % with Ax=b 160 | % end 161 | 162 | 163 | %03/01/2003 164 | if (isempty(indsuptot)==0) % if NOT empty 165 | 166 | % 167 | % on remplace tout les x qui sont indsuptot par C 168 | % 169 | Cmat= ones(length(ind),1)*(C(indsuptot)'); 170 | if size(ce)~= size(sum( Cmat.*H(ind,indsuptot),2)) 171 | keyboard; 172 | end; 173 | ce= ce - sum( Cmat.*H(ind,indsuptot),2);% min x'Hx + c'x 174 | Cmat= C(indsuptot)*ones(1,size(A,2)); 175 | be= be - sum(Cmat.*A(indsuptot,:),1)'; % with Ax=b 176 | 177 | end 178 | % keyboard 179 | % auxH=H(ind,ind); 180 | % [U,testchol] = chol(auxH); % 181 | At=A(ind,:)'; 182 | Ae=A(ind,:); 183 | 184 | 185 | if testchol==0 186 | auxH=H(ind,ind); 187 | [U,testchol] = chol(auxH); % It would be better to use an updated choleski 188 | %------------------------------------------------------------------ 189 | % if length(ind)>5 190 | % keyboard 191 | % if firstchol 192 | % Ub=chol(auxH)'; 193 | % firstchol=0; 194 | % else 195 | % 196 | % if directioncholupdate==1 197 | % Ubr = updatechol(Ub,indexcholupdate-1,H(varcholupdate,:),directioncholupdate); 198 | % else 199 | % Ubr = updatechol(Ub,indexcholupdate,[],directioncholupdate); 200 | % end; 201 | % 202 | % max(max(abs(Ub-U))) 203 | % end; 204 | % end 205 | %------------------------------------------------------------------ 206 | 207 | M = At*(U\(U'\Ae)); 208 | d = U\(U'\ce); 209 | d = (At*d - be); % second membre (homage au gars OlgaZZZZZZ qui nous a bien aid?) 210 | % On appelle le gc fabuleux de mister OlgaZZZ Hoduc 211 | % lambdastart = rand([m,1]); 212 | % [lambda] = gradconj(lambdastart,M*M,M*d,MaxIterZZZ,tol,1000); 213 | if rcond(M) 0 | sum(xnew > C(ind)) > 0) & length(ind) > ncc % 03/01/2002 AR 243 | % cette condition est utile pour le 244 | % semi param 245 | % on projette dans le domaine admissible et on sature la contrainte associ?e 246 | %------------------------------------------------------------------------- 247 | d = (xnew - x)+l; % projection direction 248 | indad = find(xnew < 0); 249 | indsup = find(xnew > C(ind) ); %% 03/01/2002 250 | [tI indmin] = min(-x(indad)./d(indad)); 251 | [tS indS] = min((C(ind(indsup))-x(indsup))./d(indsup)); % pas de descente 252 | if isempty(tI) , tI = tS + 1; end; 253 | if isempty(tS) , tS = tI + 1; end; 254 | t = min(tI,tS); 255 | 256 | x = x + t*d; % projection into the admissible set 257 | 258 | if t == tI 259 | 260 | varcholupdate=ind(indad(indmin)); 261 | indexcholupdate=indad(indmin); 262 | directioncholupdate=-1; % remove 263 | 264 | ind(indad(indmin)) = []; % the associate variable is set to 0 265 | x(indad(indmin)) = []; % the associate variable is set to 0 266 | 267 | 268 | 269 | else 270 | indexcholupdate=indsup(indS); 271 | varcholupdate=ind(indsup(indS)); 272 | directioncholupdate=-1; % remove 273 | 274 | indsuptot = [indsuptot ; ind(indsup(indS))]; 275 | ind(indsup(indS))= []; 276 | x(indsup(indS))= []; 277 | 278 | 279 | 280 | end 281 | 282 | else 283 | xt = zeros(n,1); % keyboard; 284 | xt(ind) = xnew; % keyboard; 285 | xt(indsuptot) = C(indsuptot); indold=ind; % keyboard; %% 03/01/2002 286 | 287 | mu = H*xt - c + A*lambda; % calcul des multiplicateurs de lagrange associ?es aux contraintes 288 | 289 | indsat = 1:n; % on ne regarde que les contraintes satur?es 290 | indsat([ind ; indsuptot]) = []; 291 | 292 | [mm mpos]=min(mu(indsat)); 293 | [mmS mposS]=min(-mu(indsuptot)); %keyboard 294 | 295 | if ((~isempty(mm) & (mm < -sqrt(eps))) | (~isempty(mmS) & (mmS < -sqrt(eps)))) & nbiter< nbitermax 296 | if isempty(indsuptot) | (mm < mmS) % il faut rajouter une variable 297 | ind = sort([ind ; indsat(mpos)]); % on elimine une contrainte de type x=0 298 | x = xt(ind); 299 | indexcholupdate=find(ind==indsat(mpos)); 300 | varcholupdate=indsat(mpos); 301 | directioncholupdate=1; % remove 302 | else 303 | ind = sort([ind ; indsuptot(mposS)]); % on elimine la contrainte sup si necessaire 304 | x = xt(ind); % on elimine une contrainte de type x=C 305 | indexcholupdate=find(ind==indsuptot(mposS)); 306 | varcholupdate=indsuptot(mposS); 307 | indsuptot(mposS)=[]; 308 | directioncholupdate=1; % remove 309 | end 310 | else 311 | STOP = 1; 312 | pos=sort([ind ; indsuptot]); 313 | xt = zeros(n,1); 314 | xt(ind) = xnew; 315 | xt(indsuptot) = C(indsuptot); 316 | indout = 1:n; 317 | indout(pos)=[]; 318 | xnew = xt; 319 | xnew(indout)=[]; 320 | end 321 | 322 | end 323 | end 324 | -------------------------------------------------------------------------------- /MKELM/sumKbeta.m: -------------------------------------------------------------------------------- 1 | function Kaux=sumKbeta(K,beta) 2 | 3 | % Usage 4 | % Kaux=sumKbeta(K,beta) 5 | % 6 | % K is usually a 3D matrix where K(:,:,i) is 7 | % the K_i gram matrix 8 | % 9 | % K can also be a (n*(n-1)/2) x nbkernel matrix build 10 | % by build_efficientkernel and is a struct 11 | 12 | if ~isstruct(K) 13 | ind=find(beta); 14 | Kaux=zeros(size(K(:,:,1))); 15 | N=length(ind); 16 | for j=1:N 17 | Kaux=Kaux+ beta(ind(j))*K(:,:,ind(j)); 18 | end 19 | else 20 | if size(beta,1)>1; 21 | beta=beta'; 22 | end; 23 | if isa(K.data,'single'); 24 | Kaux=devectorize_single(K.data*beta'); 25 | else 26 | Kaux=devectorize(K.data*beta'); 27 | end; 28 | end; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Multi-Kernel-Extreme-Learning-Machine 2 | Matlab code for "Multiple kernel extreme learning machine" 3 | 4 | 主运行文件是mkELM_DEMO.m,测试数据集是heart 5 | --------------------------------------------------------------------------------