• 大小: 6KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: 其他
  • 标签: GDA  

资源简介

GeneralizedDiscriminantAnalysis

资源截图

代码片段和文件信息

function mappedData = gda(datatrainDatatrainLabelnDimoptions)

% GDA Performs Generalized Discriminant Analysis a non-linear feature
% dimensionality reduction technique.

% GDA is one of dimensionality reduction techniques which projects a data 
% matrix from a high-dimensional space into a low-dimensional space by 
% maximizing the ratio of between-class scatter to within-class scatter. 


% Inputs:
%       data:           p-dimensional matrix containing the high-dimensional data to be projected
%                       p:  number of dimensions in high-dimensional space
%
%       trainData:      pxn matrix containing the high-dimensional training data
%                       n:  number of training samples

%       trainLabel:     Row vector of length n containing the class labels for training data

%       nDim:           Numer of dimensions to be retained (nDim < c)
%                       Default:    c-1
%                       c:  number of classes

%       options:        Please see the kernel function (kernel.m).
%         

% Output:
%       mappedData:      nDim-dimensional projected data matrix


% Sample use:
% trainGda  =  gda(trainDatatrainDatatrainLabel);     % Project the training data matrix into a low-dimensional space
% testGda  =  gda(testDatatrainDatatrainLabel);       % Project the test data matrix into a low-dimensional space



%   Details can be found in Section 4.3 of:
%   
%   M. Haghighat S. Zonouz M. Abdel-Mottaleb “CloudID: Trustworthy 
%   cloud-based and cross-enterprise biometric identification“ 
%   Expert Systems with Applications vol. 42 no. 21 pp. 7905-7916 2015.



% (C) Mohammad Haghighat University of Miami
%       haghighat@ieee.org
%       PLEASE CITE THE ABOVE PAPER IF YOU USE THIS CODE.

% Thanks to Dr. Saeed Meshgini for his helps.



if(size(data1) ~= size(trainData1))
   error(‘DATA and TRAINDATA must be in the same space with equal dimensions.‘);
end

if(size(trainData2) ~= size(trainLabel2))
   error(‘The length of the TRAINLABEL must be equal to the number of columns in TRAINDATA.‘);
end

if (~exist(‘options‘‘var‘))
   options.KernelType=‘linear‘;
end


% Separate samples of each class in a cell array

c = max(trainLabel);
dataCell = cell(1c);
nSample = zeros(1c);
for i = 1:c
    ind = find(trainLabel==i);
    nSample(i) = length(ind);
    dataCell{1i} = trainData(:ind);
end
clear trainLabel


% Create class-specific kernel for the training data

kTrainCell = cell(cc);
for p = 1:c
    for q = 1:c
        Kpq = zeros(nSample(p)nSample(q));
        classP = dataCell{1p};
        classQ = dataCell{1q};
        for i = 1:nSample(p)
            for j = 1:nSample(q)
                Kpq(ij) = kernel(classP(:i)classQ(:j)options);
            end
        end
        kTrainCell{pq} = Kpq;
    end
end
kTrain = cell2mat(kTrainCell);
clear kTrainCell

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-08-21 15:55  mhaghighat-Generalized_Discriminant_Analysis-a447238\
     文件        1289  2015-08-21 15:55  mhaghighat-Generalized_Discriminant_Analysis-a447238\LICENSE.md
     文件         780  2015-08-21 15:55  mhaghighat-Generalized_Discriminant_Analysis-a447238\README.md
     文件        5784  2015-08-21 15:55  mhaghighat-Generalized_Discriminant_Analysis-a447238\gda.m
     文件        6038  2015-08-21 15:55  mhaghighat-Generalized_Discriminant_Analysis-a447238\kernel.m

评论

共有 条评论