Vowpal Wabbit
Classes | Functions
active.h File Reference
#include <memory>

Go to the source code of this file.

Classes

struct  active
 

Functions

LEARNER::base_learneractive_setup (VW::config::options_i &options, vw &all)
 

Function Documentation

◆ active_setup()

LEARNER::base_learner* active_setup ( VW::config::options_i options,
vw all 
)

Definition at line 133 of file active.cc.

References vw::active, VW::config::option_group_definition::add(), VW::config::options_i::add_and_parse(), LEARNER::as_singleline(), vw::get_random_state(), LEARNER::init_learner(), LEARNER::make_base(), VW::config::make_option(), return_active_example(), LEARNER::learner< T, E >::set_finish_example(), setup_base(), THROW, and VW::config::options_i::was_supplied().

Referenced by parse_reductions().

134 {
135  auto data = scoped_calloc_or_throw<active>();
136 
137  bool active_option = false;
138  bool simulation = false;
139  option_group_definition new_options("Active Learning");
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"))
142  .add(make_option("mellowness", data->active_c0)
143  .default_value(8.f)
144  .help("active learning mellowness parameter c_0. Default 8"));
145  options.add_and_parse(new_options);
146 
147  if (!active_option)
148  return nullptr;
149 
150  data->all = &all;
151  data->_random_state = all.get_random_state();
152 
153  if (options.was_supplied("lda"))
154  THROW("error: you can't combine lda and active learning");
155 
156  auto base = as_singleline(setup_base(options, all));
157 
158  // Create new learner
160  if (options.was_supplied("simulation"))
161  l = &init_learner(data, base, predict_or_learn_simulation<true>, predict_or_learn_simulation<false>);
162  else
163  {
164  all.active = true;
165  l = &init_learner(data, base, predict_or_learn_active<true>, predict_or_learn_active<false>);
167  }
168 
169  return make_base(*l);
170 }
void return_active_example(vw &all, active &a, example &ec)
Definition: active.cc:127
base_learner * make_base(learner< T, E > &base)
Definition: learner.h:462
virtual void add_and_parse(const option_group_definition &group)=0
std::shared_ptr< rand_state > get_random_state()
Definition: global_data.h:553
single_learner * as_singleline(learner< T, E > *l)
Definition: learner.h:476
void set_finish_example(void(*f)(vw &all, T &, E &))
Definition: learner.h:307
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)
Definition: learner.h:369
bool active
Definition: global_data.h:489
virtual bool was_supplied(const std::string &key)=0
typed_option< T > make_option(std::string name, T &location)
Definition: options.h:80
LEARNER::base_learner * setup_base(options_i &options, vw &all)
Definition: parse_args.cc:1222
#define THROW(args)
Definition: vw_exception.h:181