function [dataset] = myPCA(dataset)

% this function applies the PCA transformation

% firstly standardize data
% columnStdDevs = std(dataset(:,1:(size(dataset,2)-1)));
% standardizedData = dataset(:,1:(size(dataset,2)-1)) ./ repmat(columnStdDevs,size(dataset,1),1); 

 % apply PCA to get coefficients
[coefs,scores] = princomp(dataset(:,1:(size(dataset,2)-1))); 

% replace actual values with coefficients
%scores, the principal component scores; that is, the representation of X in
%the principal component space. Rows of SCORE correspond to observations, columns to components.
dataset(:,1:(size(dataset,2)-1)) = scores;

% see if there is something wrong with the results
if (sum(isnan(sum(dataset))) ~= 0) || (sum(isinf(sum(dataset))) ~= 0)
    problem = 1
end

end