34 #ifndef SHARK_ALGORITHMS_TRAINERS_KERNELMEAN_H 35 #define SHARK_ALGORITHMS_TRAINERS_KERNELMEAN_H 53 template<
class InputType>
59 {
return "KernelMeanClassifier"; }
64 std::size_t patterns = dataset.numberOfElements();
65 std::size_t numClasses = normalization.size();
69 RealVector offset(numClasses,0.0);
70 RealMatrix alpha(patterns, numClasses,0.0);
74 for(
auto const& element: dataset.elements()){
76 unsigned int y = element.data.label;
77 double w = element.weight;
80 alpha(i,y) = w / normalization(y);
83 for(
auto element2: dataset.elements()){
84 if (element2.data.label != y)
87 offset(y) += w * element2.weight *
mpe_kernel->
eval(element.data.input, element2.data.input);
90 noalias(offset) /=
sqr(normalization);
94 noalias(column(model.
decisionFunction().alpha(),0)) = column(alpha,1) - column(alpha,0);