Suppose, I have the following matrix,
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 1
3 4 5 6 7 8 1 2
4 5 6 7 8 1 2 3
1 8 7 6 5 4 3 2
2 7 6 5 4 3 2 9
3 6 5 4 3 2 9 8
4 5 4 3 2 9 8 7
I want to create an array of 4 matrices, classified according to the column # 1.
For instance, the output should be like the following,
[
2 3 4 5 6 7 8
8 7 6 5 4 3 2
3 4 5 6 7 8 1
7 6 5 4 3 2 9
4 5 6 7 8 1 2
6 5 4 3 2 9 8
5 6 7 8 1 2 3
5 4 3 2 9 8 7
]
My target is to apply this Parzen function to each of them.
Is it something like the following?
function [retval] = bayes (train, test)
classCounts = rows(unique(train(:,1)));
pdfmx = ones(rows(test), classCounts);
variance = 0.25;
pdf = parzen(train(:,2:end), test(:,2:end), variance);
for cl=1:classCounts
clidx = train(:,1) == cl;
mu(:,cl) = train(clidx,2:end);
end
retval = mu;
endfunction
This code is generating the following error,
>> bayes(mat, mat)
error: bayes: A(I,J,...) = X: dimensions mismatch
error: called from
bayes at line 11 column 12
>>