Line | |
---|
1 | // $Id: PolynomialKernelFunction.cc 524 2006-02-23 15:55:33Z peter $ |
---|
2 | |
---|
3 | |
---|
4 | #include <c++_tools/classifier/PolynomialKernelFunction.h> |
---|
5 | |
---|
6 | #include <c++_tools/gslapi/matrix.h> |
---|
7 | #include <c++_tools/gslapi/vector.h> |
---|
8 | #include <c++_tools/statistics/AveragerPairWeighted.h> |
---|
9 | |
---|
10 | #include <cmath> |
---|
11 | |
---|
12 | |
---|
13 | namespace theplu { |
---|
14 | namespace classifier { |
---|
15 | |
---|
16 | PolynomialKernelFunction::PolynomialKernelFunction(int order) |
---|
17 | : KernelFunction(), order_(order) |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | double PolynomialKernelFunction::operator()(const gslapi::vector& a1, |
---|
22 | const gslapi::vector& a2, |
---|
23 | const gslapi::vector& w1, |
---|
24 | const gslapi::vector& w2) const |
---|
25 | { |
---|
26 | statistics::AveragerPairWeighted averager; |
---|
27 | averager.add(a1,a2,w1,w2); |
---|
28 | |
---|
29 | // a1.size() term to make it coherent with no weight case |
---|
30 | if(order_>1) |
---|
31 | return pow(1+averager.sum_xy()/averager.sum_w()*a1.size(),order_); |
---|
32 | return averager.sum_xy()/averager.sum_w()*a1.size(); |
---|
33 | } |
---|
34 | |
---|
35 | }} // of namespace cpptools and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.