function [success_ct, winner, dists] = SVMclassify(alph_data, test_alph_num, x_sz, y_sz)
close all;
[s alph_ct] = size(alph_data);
test_set = alph_data{test_alph_num};

if(test_alph_num == 1)
    example_data = {alph_data{2:alph_ct}};
elseif(test_alph_num == alph_ct)
    example_data = {alph_data{1:alph_ct-1}};
else
    example_data = {alph_data{1:test_alph_num-1} alph_data{test_alph_num+1:alph_ct}};
end

success_ct = 0;

examples = SVMExamples(example_data, x_sz, y_sz);
[s let_ct] = size(examples);
dists = zeros(let_ct);
winner = zeros(1, let_ct);
fprintf('Results\n');
for i=1:let_ct
    test_svm = convertToSVM(test_set{i}, x_sz, y_sz);
    for j=1:let_ct
        dists(i, j) = get_distance(test_svm, examples{j});
    end
    % get min dist of this row
    [m ind] = min(dists(i,:));
    winner(i) = ind;
    fprintf('%c --> %c\n', 'A'-1+i, 'A'-1+ind);
    if(i == ind)
        success_ct = success_ct + 1;
    end
end

fprintf('Success: %d/%d\n', success_ct, let_ct);

figure;
dists2 = [dists zeros(let_ct, 1)];
dists2 = [dists2; zeros(1, let_ct+1)];
pcolor(dists2);
title(sprintf('SVM Performance on alphabet %d', test_alph_num));
ylabel('Letter to be classified');
xlabel('Classification strength as this letter (dark blue = high)');
set(gca,'YTick',1:let_ct);
set(gca,'XTick',1:let_ct);
set(gca,'XTickLabel',[ones(let_ct,4)*' ' reshape('A':'Z', let_ct, 1)]);
set(gca,'YTickLabel',reshape('A':'Z', let_ct, 1));

end