added more comments to the kcentroid example

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402498
This commit is contained in:
Davis King 2008-09-06 14:50:36 +00:00
parent b5578687c8
commit e295d55527

View File

@ -46,8 +46,23 @@ int main()
// smaller values give better results but cause the algorithm to run slower. You just have // smaller values give better results but cause the algorithm to run slower. You just have
// to play with it to decide what balance of speed and accuracy is right for your problem. // to play with it to decide what balance of speed and accuracy is right for your problem.
// Here we have set it to 0.01. // Here we have set it to 0.01.
//
// Also, since we are using the radial basis kernel we have to pick the RBF width parameter.
// Here we have it set to 0.1. But in general, a reasonable way of picking this value is
// to start with some initial guess and to just run the algorithm. Then print out
// test.dictionary_size() to see how many support vectors the kcentroid object is using.
// And a good rule of thumb is that you should have somewhere in the range of 10-100
// support vectors. So if you aren't in that range then you can change the RBF parameter.
// Making it smaller will decrease the dictionary size and making it bigger will increase
// the dictionary size.
//
// So what I often do is I set the kcentroid's second parameter to 0.01 or 0.001. Then
// I find an RBF kernel parameter that gives me the number of support vectors that I
// feel is appropriate for the problem I'm trying to solve. Again, this just comes down
// to playing with it and getting a feel for how things work.
kcentroid<kernel_type> test(kernel_type(0.1),0.01); kcentroid<kernel_type> test(kernel_type(0.1),0.01);
// now we train our object on a few samples of the sinc function. // now we train our object on a few samples of the sinc function.
sample_type m; sample_type m;
for (double x = -15; x <= 8; x += 1) for (double x = -15; x <= 8; x += 1)