load Data/refinedData;
fullData = data;
numUsers = 2000;
numRatings = 200;
data = round(5*fullData(1:numUsers,1:numRatings));
numTestUsers = 10;
minNumRatings = 20;  % should be less than 60

N = size(data,1);
D = size(data,2)
maxRated = D-minNumRatings;

%The following indices are indices to users (rows) from the data;
temp=randperm(N);
testIndices=temp(1:numTestUsers);
trainIndices=temp(numTestUsers+1:end);
 
trainData = data(trainIndices,:);

iters = 15;
numVQs = 5;
numCompsPerVQ = 10;

cd ~dross/MCVQ
[A,G,M,W,Cost,var_m, var_g] = MCVQ(trainData,numVQs,numCompsPerVQ,iters); 

M = ones(numCompsPerVQ,numVQs,1);
cd ~/Pref/Code
[likeRand lossRand likeVoi lossVoi] = ...
    testVoi(data,numTestUsers,minNumRatings,A,G,M,W,...
    trainIndices,iters,numVQs,numCompsPerVQ,var_m, var_g);
