⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dualsparsegeneralfeatureslm3.m.svn-base

📁 a function inside machine learning
💻 SVN-BASE
字号:
function  [newTrainX, newTestX, subspaceInfo] = dualSparseGeneralFeaturesLM3(trainX, trainY, testX, params)
%A function to compute general features in the dual space without
%requiring the kernel matrix to be entirely in memory. Designed for datasets
%with a large number of examples. Uses a random subset of the kernel matrix
%columns at each iteration to find the dual projection direction. 
%
%Inputs 
%   trainX - training examples 
%   trainY - training labels 
%   testX - test examples 
%   params - struct of parameters 
%Outputs 
%   newTrainX - new training examples 
%   newTestX - new test examples 
%   subspaceInfo - struct containing some meta-data 

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


if size(trainX, 2) ~= size(testX, 2) 
    error('Train and test sets must have same number of features\n'); 
end 

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

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


paramsX.X.kernel.name = char(params.kernelFunctionName); 
paramsX.X.kernel.params = params; 

params.X.kernel = paramsX.X.kernel;

[subspaceInfo, trainInfo] = dualSparseGeneralFeaturesLM3Train(trainData, params);
[testInfo, projectionInfo] = dualSparseGeneralFeaturesProject(trainData, testData, subspaceInfo, paramsX);

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

subspaceInfo.projectionInfo = projectionInfo; 
subspaceInfo.X = rmfield(subspaceInfo.X, 'Q'); 

⌨️ 快捷键说明

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