资源简介
多分类核Fisher判别分析法,里面我给了一个例子,用的是鸢尾花数据集,四维三类,降到二维,核函数有高斯核,线性核,多项式核等,需要自取
代码片段和文件信息
function [mappedDataw] = 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 kTrain
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 28219 2017-03-18 09:50 GDA\2维linear.tif
文件 28219 2017-03-18 09:54 GDA\2维poly.tif
文件 28219 2017-03-18 09:51 GDA\2维rbf.tif
文件 5786 2017-03-24 21:06 GDA\gda.m
文件 388 2017-04-09 19:53 GDA\iris.m
文件 6038 2016-04-07 13:10 GDA\kernel.m
文件 25878 2017-03-11 08:23 GDA\UCI-iris数据集.xlsx
目录 0 2017-04-09 19:53 GDA
----------- --------- ---------- ----- ----
122747 8
评论
共有 条评论