23 #include "jubatus/util/concurrent/lock.h"
25 #include "../common/exception.hpp"
31 namespace classifier {
53 string incorrect_label;
57 float b = 1.f + 2 * C * margin;
58 float gamma = -b + std::sqrt(b * b - 8 * C * (margin - C * variance));
64 gamma /= 4 * C * variance;
65 update(sfv, gamma, label, incorrect_label);
71 const string& pos_label,
72 const string& neg_label) {
73 util::concurrent::scoped_lock lk(
storage_->get_lock());
74 for (common::sfv_t::const_iterator it = sfv.begin(); it != sfv.end(); ++it) {
75 const string& feature = it->first;
76 float val = it->second;
78 storage_->get2_nolock(feature, val2);
85 float covar_pos_step = 2.f * step_width * val * val * C;
86 float covar_neg_step = 2.f * step_width * val * val * C;
92 1.f / (1.f / pos_val.
v2 + covar_pos_step)));
93 if (neg_label !=
"") {
98 1.f / (1.f / neg_val.
v2 + covar_neg_step)));
105 return string(
"confidence_weighted");
jubatus::util::lang::shared_ptr< jubatus::core::storage::storage_base > storage_ptr
void train(const common::sfv_t &fv, const std::string &label)
static void get_two(const T &t, const std::string &label1, const std::string &label2, U &u1, U &u2)
classifier_config config_
void update(const common::sfv_t &fv, float step_weigth, const std::string &pos_label, const std::string &neg_label)
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)
confidence_weighted(storage_ptr storage)
std::vector< std::pair< std::string, val2_t > > feature_val2_t
float regularization_weight