23 #include "jubatus/util/concurrent/lock.h"
25 #include "../common/exception.hpp"
31 namespace classifier {
53 string incorrect_label;
61 update(sfv, margin, variance, label, incorrect_label);
68 const string& pos_label,
69 const string& neg_label) {
70 util::concurrent::scoped_lock lk(
storage_->get_lock());
71 for (common::sfv_t::const_iterator it = sfv.begin(); it != sfv.end(); ++it) {
72 const string& feature = it->first;
73 float val = it->second;
81 float val_covariance_pos = val * pos_val.
v2;
82 float val_covariance_neg = val * neg_val.
v2;
90 + (1.f - margin) * val_covariance_pos
91 / (variance + 1.f / C),
93 / ((1.f / pos_val.
v2) + (2 * C + C * C * variance)
95 if (neg_label !=
"") {
101 - (1.f - margin) * val_covariance_neg
102 / (variance + 1.f / C),
104 / ((1.f / neg_val.
v2) + (2 * C + C * C * variance)
112 return string(
"normal_herd");
jubatus::util::lang::shared_ptr< jubatus::core::storage::storage_base > storage_ptr
classifier_config config_
void update(const common::sfv_t &sfv, float margin, float variance, const std::string &pos_label, const std::string &neg_label)
static void get_two(const T &t, const std::string &label1, const std::string &label2, U &u1, U &u2)
normal_herd(storage_ptr storage)
float calc_margin_and_variance(const common::sfv_t &sfv, const std::string &label, std::string &incorrect_label, float &variance) const
#define JUBATUS_EXCEPTION(e)
void check_touchable(const std::string &label)
std::vector< std::pair< std::string, float > > sfv_t
void touch(const std::string &label)
void train(const common::sfv_t &fv, const std::string &label)
std::vector< std::pair< std::string, val2_t > > feature_val2_t
float regularization_weight