37 #ifndef SHARK_ALGORITHMS_MCSVMLLWTRAINER_H 38 #define SHARK_ALGORITHMS_MCSVMLLWTRAINER_H 95 template <
class InputType,
class CacheType =
float>
111 : base_type(kernel, C, unconstrained)
116 {
return "McSvmLLWTrainer"; }
123 RealMatrix linear(ic, classes-1,1.0);
124 UIntVector
rho(classes-1);
125 for (
unsigned int p=0; p<classes-1; p++)
129 for (
unsigned int r=0, y=0; y<classes; y++)
131 for (
unsigned int p=0, pp=0; p<classes-1; p++, pp++, r++)
134 nu.
add(r, pp, (QpFloatType)-1.0);
139 QpFloatType mood = (
QpFloatType)(-1.0 / (
double)classes);
141 for (
unsigned int r=0, yv=0; yv<classes; yv++)
143 for (
unsigned int pv=0, ppv=0; pv<classes-1; pv++, ppv++)
145 if (ppv == yv) ppv++;
146 for (
unsigned int yw=0; yw<classes; yw++, r++)
151 unsigned int pw = ppv - (ppv > yw ? 1 : 0);
163 RealMatrix alpha(ic,classes-1);
164 RealVector bias(classes,0);
168 PrecomputedMatrixType matrix(&km);
180 alpha = problem.solution();
196 alpha = problem.solution();
202 for (std::size_t i=0; i<ic; i++)
204 unsigned int y = dataset.
element(i).label;
205 for (std::size_t c=0; c<classes; c++)
208 unsigned int r = (classes-1) * y;
209 for (std::size_t p=0; p<classes-1; p++, r++)
210 sum += nu(r, c) * alpha(i,p);
224 template <
class InputType>
235 {
return "LinearMcSvmLLWTrainer"; }
251 #define McSvmADSTrainer McSvmLLWTrainer 252 #define LinearMcSvmADSTrainer LinearMcSvmLLWTrainer