function [rank_feat, ind_feat] = RfeRanking(alpha_Y, supp_vect, in_parameters) % RfeRanking -- Feature ranking according to SVM's weights % % Usage: % % [rank_feat, ind_feat] = RfeRanking(alpha_Y, supp_vect, in_parameters) % % INPUTS: % % alpha_y : the AlphaY coefficients returned by SVMTrain() % % supp_vect : the SVs returned by SVMTrain() % % in_parameters : SVM's parameters (see SVMTrain() help) % % OUTPUTS: % % rank_feat : the features ranked according to their weights % % ind_feat : the index of each feature % G. Palermo (giuseppe.palermo@bo.infn.it) and M. Masotti (matteo.masotti@bo.infn.it) % Last Revision: 14 Oct 2004 % Checking the number of input arguments (min = 3) if nargin < 3 disp('Error: Incorrect number of input arguments'); help RfeRanking; return end % Number of support vectors (N_sv) and number of features (N_feat) [N_feat, N_sv] = size(supp_vect); % Computation of the matrix H H = ones(N_sv, N_sv); gamma = in_parameters(3); coefficient = in_parameters(4); degree = in_parameters(2); H = (gamma * (supp_vect' * supp_vect) + coefficient) .^ degree; % Calculate the first term in the sum (fixed term) DJ_1 = 0.5 * alpha_Y * H * alpha_Y'; % Calculate the second term in the sum (the term varies according to the eliminated feature) DJ_2 = ones(1,N_feat); K = ones(N_sv, N_sv); for i = 1:N_feat K = H - supp_vect(i,:)' * supp_vect(i,:); DJ_2(i) = 0.5 * alpha_Y * K * alpha_Y'; end % Calculate the weight of each feature DJ = DJ_1 + DJ_2; % Ranking considering the weight of each feature [rank_feat, ind_feat] = sort(DJ); % % Weights' plot % t = 1:N_feat; % plot(t,rank_feat);