dualsparsegeneralfeatureslm3test2.m.svn-base

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

SVN-BASE
39
字号
%A script to see if we can improve upon a linear SVM using SMA/SMC
clear;
rand('state',22); 
dataSet = 'linear-synthetic3';
csvFileName = sprintf('%s.data', dataSet); ;

[X, y, numExamples, numFeatures] = readCsvData(csvFileName);
y = sign(y); 

X = centerData(X);
X = normalise(X);

numExamples = min(1000, numExamples);
[X, y] = sampleData(X, y, numExamples); 

[trainX, trainY, testX, testY] = splitData(X, y, 2/3); 

T = 100; 

subspaceMethod.name = 'dualSparseGeneralFeaturesLM3'; 
subspaceMethod.params.dualSparseMeasureFunction = 'sparseAlignments';
subspaceMethod.params.iterations = T; 
subspaceMethod.params.cacheSize = 500; 
subspaceMethod.params.chunkSize = 500; 
subspaceMethod.params.kernelFunctionName = {'linearKernel'};
subspaceMethod.params.normalise = 1;

classifier.name = 'primalLibSVM'; 
classifier.params.kernel = 'linear';
classifier.params.C = 10;  
classifier.params.weightClasses = 0;

evaluationFunc = 'accuracy'; 


tic
[trainPerformance, testPerformance, subspaceInfo, classifierInfo] = subspaceClassify(trainX, trainY, testX, testY,  subspaceMethod, classifier, evaluationFunc); 
[trainPerformance, testPerformance, subspaceInfo, classifierInfo] = subspaceClassify(trainX, trainY, testX, testY,  0, classifier, evaluationFunc); 

⌨️ 快捷键说明

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