15 b = (float)(c0 * (log(k + 1.) + 0.0001) / (k + 0.0001));
17 avg_loss = std::min(1.
f, std::max(0.
f, avg_loss));
19 sl = std::sqrt(avg_loss) + std::sqrt(avg_loss + g);
22 rs = (sl + std::sqrt(sl * sl + 4 * g)) / (2 * g);
28 float bias, avg_loss, weighted_queries;
34 avg_loss = (
float)(a.
all->
sd->
sum_loss / k + std::sqrt((1. + 0.5 * log(k)) / (weighted_queries + 0.0001)));
43 template <
bool is_learn>
52 float k = (float)all.
sd->
t;
53 float threshold = 0.f;
72 template <
bool is_learn>
92 ss << std::fixed << res;
96 ss <<
" " << std::fixed <<
weight;
98 ssize_t len = ss.str().size();
101 std::cerr <<
"write error: " << strerror(errno) << std::endl;
115 if (ld.
label == FLT_MAX)
135 auto data = scoped_calloc_or_throw<active>();
137 bool active_option =
false;
138 bool simulation =
false;
140 new_options.
add(
make_option(
"active", active_option).keep().help(
"enable active learning"))
141 .
add(
make_option(
"simulation", simulation).help(
"active learning simulation mode"))
144 .help(
"active learning mellowness parameter c_0. Default 8"));
154 THROW(
"error: you can't combine lda and active learning");
161 l = &
init_learner(data, base, predict_or_learn_simulation<true>, predict_or_learn_simulation<false>);
165 l = &
init_learner(data, base, predict_or_learn_active<true>, predict_or_learn_active<false>);
std::shared_ptr< rand_state > _random_state
void predict(E &ec, size_t i=0)
void return_active_example(vw &all, active &a, example &ec)
double weighted_unlabeled_examples
static ssize_t write_file_or_socket(int f, const void *buf, size_t nbytes)
void output_and_account_example(vw &all, active &a, example &ec)
float query_decision(active &a, float ec_revert_weight, float k)
v_array< int > final_prediction_sink
base_learner * make_base(learner< T, E > &base)
int print_tag(std::stringstream &ss, v_array< char > tag)
virtual void add_and_parse(const option_group_definition &group)=0
void active_print_result(int f, float res, float weight, v_array< char > tag)
void predict_or_learn_simulation(active &a, single_learner &base, example &ec)
std::shared_ptr< rand_state > get_random_state()
single_learner * as_singleline(learner< T, E > *l)
void print_update(vw &all, bool is_test, example &ec, multi_ex *ec_seq, bool action_scores)
base_learner * active_setup(options_i &options, vw &all)
void set_finish_example(void(*f)(vw &all, T &, E &))
learner< T, E > & init_learner(free_ptr< T > &dat, L *base, void(*learn)(T &, L &, E &), void(*predict)(T &, L &, E &), size_t ws, prediction_type::prediction_type_t pred_type)
float get_active_coin_bias(float k, float avg_loss, float g, float c0)
virtual bool was_supplied(const std::string &key)=0
void finish_example(vw &, example &)
void update(bool test_example, bool labeled_example, float loss, float weight, size_t num_features)
float sensitivity(example &ec, size_t i=0)
option_group_definition & add(T &&op)
typed_option< T > make_option(std::string name, T &location)
double weighted_labeled_examples
LEARNER::base_learner * setup_base(options_i &options, vw &all)
void predict_or_learn_active(active &a, single_learner &base, example &ec)
void learn(E &ec, size_t i=0)
void(* print)(int, float, float, v_array< char >)