m = 100;
n = 5;
k = 6;
rng(5);

addpath minFunc

X = randn(m,n);
W = randn(n+1,k);

augX = [X, ones(m,1)];

cls = augX*W;

mx = max(cls');

mask = repmat(mx',1,k);

Y = cls == mask;

if min(sum(Y')) ~= 1 or max(sum(Y')) ~= 1
	die die die
end

Y = Y * [ 1:k]';

Y

new_W = train_svm(augX,Y,.01);


cls = augX*W;
mx = max(cls');
mask = repmat(mx',1,k);
pred_train_Y = cls == mask;
pred_train_Y = pred_train_Y * [1:k]';

'train acc'
mean(pred_train_Y == Y)


newX = randn(m,n);
new_augX = [newX, ones(m,1)];

cls = new_augX*W;
mx = max(cls');
mask = repmat(mx',1,k);
new_Y = cls == mask;
new_Y = new_Y * [1:k]';

cls = new_augX*new_W;
mx = max(cls');
mask = repmat(mx',1,k);
pred_Y = cls == mask;
pred_Y = pred_Y * [1:k]';

'test acc'
mean(new_Y == pred_Y)

save('comparison.mat')
