% read data set
data = load('housing.mat');
%% parameter
seed = 3;
split = 0.7;
lambda = 0.1;
sigma = 2;
class_col = 14;
[train,y_train,test,y_test]= ...
    split_train_test(data.housing,seed,split,class_col);

% train KernelReg:
alpha = learnKernelReg(train, y_train,lambda,@rbf,sigma);


% loss of test
Yeval = classKernelReg(alpha,train,@rbf,sigma,test);
lossTest = (Yeval - y_test).^2;
squaredLoss = sum(lossTest)/length(Yeval);
disp(['loss of test data: ' num2str(squaredLoss)]);

% loss of train
YtrainEval = classKernelReg(alpha,train,@rbf,sigma,train);
lossTrain = (YtrainEval - y_train).^2;
squaredLossTrain = sum(lossTrain)/numel(y_train);
disp(['loss of train data: ' num2str(squaredLossTrain)]);
