dualgeneralfeatures.m.svn-base

来自「a function inside machine learning」· SVN-BASE 代码 · 共 46 行

SVN-BASE
46
字号
function [newTrainX, newTestX, subspaceInfo] = dualGeneralFeatures(trainX, trainY, testX, params)
%Compute the dual general features, based on the General Feature Extraction Framework, 
%on a set of training examples and labels and compute corresponding examples 
%projected onto the directions specified by the featureDirection function. A test 
%matrix of examples can also be supplied for the subspace projection. 
%
% inputs
% trainK is an (l x k) kernel matrix of training data 
% trainY is (l x m) containing the corresponding output vectors
% testK is an (l x l2) kernel matrix between training and test examples 
% T gives the number of iterations to be performed
% featureDirection is a string specifying a function which computes a
%   projection direction on centered matrices trainX and trainY at each
%   iteration
% dualFeatures is a string specifying a function which computes a
%   matrix Z to compute the new features by K*Z; 
%
% outputs
% newTrainK is the new training kernel matrix
% newTrainK is the new test kernel matrix
% b is the matrix of dual feature directions as columns

if (nargin ~= 4)
    fprintf('%s\n', help(sprintf('%s', mfilename)));
    error('Incorrect number of inputs - see above usage instructions.');
end

trainData = data; 
trainData = addDataField(trainData, 'X', trainX, 'examples'); 
trainData = addDataField(trainData, 'Y', trainY, 'labels'); 

testData = data; 
testData= addDataField(testData, 'X', testX, 'examples'); 

[subspaceInfo, trainInfo] = dualGeneralFeaturesTrain(trainData, params);
[testInfo, projectionInfo] = dualGeneralFeaturesProject(trainData, testData, subspaceInfo, params);

trainData = clearAllFields(trainData); 
testData = clearAllFields(testData); 

newTrainX = getDataFieldValue(trainInfo.data, 'X'); 
newTestX = getDataFieldValue(testInfo.data, 'X'); 

trainInfo.data = clearAllFields(trainInfo.data); 
testInfo.data = clearAllFields(testInfo.data); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?