35 #ifndef SHARK_ALGORITHMS_RANKINGSVMTRAINER_H 36 #define SHARK_ALGORITHMS_RANKINGSVMTRAINER_H 70 template <
class InputType,
class CacheType =
float>
94 : base_type(kernel, C, false, unconstrained)
99 {
return "RankingSvmTrainer"; }
110 std::vector<std::pair<std::size_t, std::size_t>> pairs;
111 for (std::size_t i=0; i<n; i++) {
112 for (std::size_t j=0; j<i; j++) {
113 pairs.push_back(std::make_pair(j, i));
116 train(
function, dataset, pairs);
127 std::vector<std::pair<std::size_t, std::size_t>> pairs;
133 if (yi < yj) pairs.push_back(std::make_pair(i, j));
134 else if (yi > yj) pairs.push_back(std::make_pair(j, i));
155 trainInternal(
function, dataset, pairs, matrix);
160 trainInternal(
function, dataset, pairs, matrix);
165 template <
typename MatrixType>
177 RealVector alpha = problem.getUnpermutedAlpha();
180 for (std::size_t i=0; i<alpha.size(); i++)
183 coeff(pairs[i].first) -= a;
184 coeff(pairs[i].second) += a;
186 blas::column(
function.alpha(),0) = coeff;