matrixTrain = load('matrix.train');
function [matrixTrain , meanFeatIn, stdDevFeatIn] = mynorm_train(matrixTrain)
featureIn = matrixTrain(:,1:end-1);
featureOut = matrixTrain(:,end);
meanFeatIn = mean(featureIn,1);
stdDevFeatIn = std(featureIn,1,1);
meanFeatOut = mean(featureOut,1);
stdDevFeatOut = std(featureOut,1,1) ;
dlmwrite('normInfo',[meanFeatOut stdDevFeatOut],'delimiter','\t');
noSample = size(featureIn,1);
for i=1:noSample
featureIn(i,:) = (featureIn(i,:) - meanFeatIn) ./ stdDevFeatIn ;
featureOut(i,:) = (featureOut(i,:) - meanFeatOut) ./ stdDevFeatOut ;
end
matrixTrain = [ featureIn featureOut];
end
matrixTest = load('matrix.test');
function [matrixTest] = mynorm_train(matrixTest,meanFeatIn, stdDevFeatIn,meanFeatOut ,stdDevFeatOut )
noSample = size(matrixTest,1);
noInputFeat = size(matrixTest,2) - 1;
for i=1:noSample
matrixTest(i,1:noInputFeat) = (matrixTest(i,1:noInputFeat) - meanFeatIn ) ./ stdDevFeatIn ;
matrixTest(i,noInputFeat+1) = (matrixTest(i,noInputFeat+1) - meanFeatOut ) ./ stdDevFeatOut ;
end
Comments
Post a Comment