function scores = kp_predict(alphas, b, d, X, Y, tst_data) % alphas, b: sample weights and bias term for classification % d: degree of polynomial kernel ^d % X,Y: training data and label % tst_data: test data for prediction % scores: the perdiction scores. N = size(X,1); %TO DO: calculate the predictions [tst_size, ~] = size(tst_data); scores = zeros(tst_size, 1); for t = 1 : tst_size xt = tst_data(t, :); sum = 0; for i = 1 : N ai = alphas(i); yi = Y(i); xi = X(i, :); sum = sum + ai * yi * dot(xi, xt) ^ d; end sum = sum + b; scores(t) = sign(sum); end %********************************