Vowpal Wabbit
|
#include <float.h>
#include "reductions.h"
#include "cb_algs.h"
#include "rand48.h"
#include "bs.h"
#include "vw.h"
#include "hash.h"
#include "explore.h"
#include "vw_exception.h"
#include <vector>
#include <memory>
Go to the source code of this file.
Classes | |
struct | warm_cb |
Macros | |
#define | WARM_START 1 |
#define | INTERACTION 2 |
#define | SKIP 3 |
#define | SUPERVISED_WS 1 |
#define | BANDIT_WS 2 |
#define | UAR 1 |
#define | CIRCULAR 2 |
#define | OVERWRITE 3 |
#define | ABS_CENTRAL 1 |
#define | ABS_CENTRAL_ZEROONE 2 |
#define | MINIMAX_CENTRAL 3 |
#define | MINIMAX_CENTRAL_ZEROONE 4 |
Functions | |
float | loss (warm_cb &data, uint32_t label, uint32_t final_prediction) |
float | loss_cs (warm_cb &data, v_array< COST_SENSITIVE::wclass > &costs, uint32_t final_prediction) |
template<class T > | |
uint32_t | find_min (std::vector< T > arr) |
void | finish (warm_cb &data) |
void | copy_example_to_adf (warm_cb &data, example &ec) |
float | minimax_lambda (float epsilon) |
void | setup_lambdas (warm_cb &data) |
uint32_t | generate_uar_action (warm_cb &data) |
uint32_t | corrupt_action (warm_cb &data, uint32_t action, int ec_type) |
bool | ind_update (warm_cb &data, int ec_type) |
float | compute_weight_multiplier (warm_cb &data, size_t i, int ec_type) |
uint32_t | predict_sublearner_adf (warm_cb &data, multi_learner &base, example &ec, uint32_t i) |
void | accumu_costs_iv_adf (warm_cb &data, multi_learner &base, example &ec) |
template<bool use_cs> | |
void | add_to_vali (warm_cb &data, example &ec) |
uint32_t | predict_sup_adf (warm_cb &data, multi_learner &base, example &ec) |
template<bool use_cs> | |
void | learn_sup_adf (warm_cb &data, example &ec, int ec_type) |
template<bool use_cs> | |
void | predict_or_learn_sup_adf (warm_cb &data, multi_learner &base, example &ec, int ec_type) |
uint32_t | predict_bandit_adf (warm_cb &data, multi_learner &base, example &ec) |
void | learn_bandit_adf (warm_cb &data, multi_learner &base, example &ec, int ec_type) |
template<bool use_cs> | |
void | predict_or_learn_bandit_adf (warm_cb &data, multi_learner &base, example &ec, int ec_type) |
void | accumu_var_adf (warm_cb &data, multi_learner &base, example &ec) |
template<bool is_learn, bool use_cs> | |
void | predict_or_learn_adf (warm_cb &data, multi_learner &base, example &ec) |
void | init_adf_data (warm_cb &data, const uint32_t num_actions) |
base_learner * | warm_cb_setup (options_i &options, vw &all) |
#define ABS_CENTRAL 1 |
Definition at line 30 of file warm_cb.cc.
Referenced by setup_lambdas(), and warm_cb_setup().
#define ABS_CENTRAL_ZEROONE 2 |
Definition at line 31 of file warm_cb.cc.
Referenced by setup_lambdas().
#define BANDIT_WS 2 |
Definition at line 24 of file warm_cb.cc.
Referenced by init_adf_data(), and predict_or_learn_adf().
#define CIRCULAR 2 |
Definition at line 27 of file warm_cb.cc.
#define INTERACTION 2 |
Definition at line 20 of file warm_cb.cc.
Referenced by predict_or_learn_adf(), and predict_or_learn_bandit_adf().
#define MINIMAX_CENTRAL 3 |
Definition at line 32 of file warm_cb.cc.
#define MINIMAX_CENTRAL_ZEROONE 4 |
Definition at line 33 of file warm_cb.cc.
Referenced by setup_lambdas().
#define OVERWRITE 3 |
Definition at line 28 of file warm_cb.cc.
Referenced by corrupt_action().
#define SKIP 3 |
Definition at line 21 of file warm_cb.cc.
#define SUPERVISED_WS 1 |
Definition at line 23 of file warm_cb.cc.
Referenced by init_adf_data(), and predict_or_learn_adf().
#define UAR 1 |
Definition at line 26 of file warm_cb.cc.
Referenced by corrupt_action(), and warm_cb_setup().
#define WARM_START 1 |
Definition at line 19 of file warm_cb.cc.
Referenced by compute_weight_multiplier(), corrupt_action(), ind_update(), and predict_or_learn_adf().
void accumu_costs_iv_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec | ||
) |
Definition at line 310 of file warm_cb.cc.
References CB::cb_class::action, warm_cb::choices_lambda, warm_cb::cl_adf, CB::cb_class::cost, warm_cb::cumulative_costs, predict_sublearner_adf(), and CB::cb_class::probability.
Referenced by predict_or_learn_bandit_adf().
void accumu_var_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec | ||
) |
Definition at line 459 of file warm_cb.cc.
References a, warm_cb::a_s_adf, warm_cb::cumu_var, warm_cb::num_actions, and predict_sup_adf().
Referenced by predict_or_learn_adf().
Definition at line 324 of file warm_cb.cc.
References VW::alloc_examples(), VW::copy_example_data(), CB::copy_label(), COST_SENSITIVE::cs_label, MULTICLASS::mc_label, and warm_cb::ws_vali.
float compute_weight_multiplier | ( | warm_cb & | data, |
size_t | i, | ||
int | ec_type | ||
) |
Definition at line 287 of file warm_cb.cc.
References warm_cb::inter_period, warm_cb::lambdas, WARM_START, and warm_cb::ws_train_size.
Referenced by learn_bandit_adf(), and learn_sup_adf().
Definition at line 165 of file warm_cb.cc.
References a, warm_cb::all, CB::cb_label, VW::copy_example_data(), label_parser::default_label, warm_cb::ecs, CB_ALGS::example_is_newline_not_header(), parameters::mask(), warm_cb::num_actions, parameters::stride_shift(), label_parser::test_label, and vw::weights.
Referenced by learn_bandit_adf(), learn_sup_adf(), predict_bandit_adf(), and predict_sublearner_adf().
uint32_t corrupt_action | ( | warm_cb & | data, |
uint32_t | action, | ||
int | ec_type | ||
) |
Definition at line 252 of file warm_cb.cc.
References warm_cb::_random_state, warm_cb::cor_prob_ws, warm_cb::cor_type_ws, generate_uar_action(), warm_cb::num_actions, OVERWRITE, warm_cb::overwrite_label, UAR, and WARM_START.
Referenced by predict_or_learn_adf().
uint32_t find_min | ( | std::vector< T > | arr | ) |
Definition at line 136 of file warm_cb.cc.
Referenced by finish(), predict_bandit_adf(), and predict_sup_adf().
void finish | ( | warm_cb & | data | ) |
Definition at line 152 of file warm_cb.cc.
References warm_cb::all, warm_cb::choices_lambda, warm_cb::cumu_var, warm_cb::cumulative_costs, warm_cb::epsilon, find_min(), warm_cb::inter_iter, warm_cb::lambdas, warm_cb::num_actions, and vw::quiet.
Referenced by warm_cb_setup().
uint32_t generate_uar_action | ( | warm_cb & | data | ) |
Definition at line 240 of file warm_cb.cc.
References warm_cb::_random_state, and warm_cb::num_actions.
Referenced by corrupt_action().
bool ind_update | ( | warm_cb & | data, |
int | ec_type | ||
) |
Definition at line 279 of file warm_cb.cc.
References warm_cb::upd_inter, warm_cb::upd_ws, and WARM_START.
Referenced by predict_or_learn_bandit_adf(), and predict_or_learn_sup_adf().
void init_adf_data | ( | warm_cb & | data, |
const uint32_t | num_actions | ||
) |
Definition at line 517 of file warm_cb.cc.
References a, VW::alloc_examples(), BANDIT_WS, CB::cb_label, warm_cb::cbls, warm_cb::choices_lambda, COST_SENSITIVE::label::costs, COST_SENSITIVE::cs_label, warm_cb::csls, warm_cb::cumu_var, warm_cb::cumulative_costs, label_parser::default_label, warm_cb::ecs, warm_cb::inter_iter, warm_cb::num_actions, setup_lambdas(), warm_cb::sim_bandit, SUPERVISED_WS, warm_cb::ws_iter, warm_cb::ws_period, warm_cb::ws_train_size, warm_cb::ws_type, and warm_cb::ws_vali_size.
Referenced by warm_cb_setup().
void learn_bandit_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec, | ||
int | ec_type | ||
) |
Definition at line 410 of file warm_cb.cc.
References a, warm_cb::choices_lambda, warm_cb::cl_adf, compute_weight_multiplier(), copy_example_to_adf(), warm_cb::ecs, LEARNER::learner< T, E >::learn(), and warm_cb::num_actions.
Referenced by predict_or_learn_bandit_adf().
Definition at line 344 of file warm_cb.cc.
References a, warm_cb::all, LEARNER::as_multiline(), warm_cb::cbls, warm_cb::choices_lambda, compute_weight_multiplier(), copy_example_to_adf(), vw::cost_sensitive, CB::label::costs, COST_SENSITIVE::label::costs, polylabel::cs, warm_cb::csls, warm_cb::ecs, example::l, MULTICLASS::label_t::label, LEARNER::learner< T, E >::learn(), loss(), loss_cs(), polylabel::multi, and warm_cb::num_actions.
float loss | ( | warm_cb & | data, |
uint32_t | label, | ||
uint32_t | final_prediction | ||
) |
Definition at line 113 of file warm_cb.cc.
References warm_cb::loss0, and warm_cb::loss1.
Referenced by learn_sup_adf(), and predict_or_learn_bandit_adf().
float loss_cs | ( | warm_cb & | data, |
v_array< COST_SENSITIVE::wclass > & | costs, | ||
uint32_t | final_prediction | ||
) |
Definition at line 121 of file warm_cb.cc.
References warm_cb::loss0, and warm_cb::loss1.
Referenced by learn_sup_adf(), and predict_or_learn_bandit_adf().
float minimax_lambda | ( | float | epsilon | ) |
Definition at line 200 of file warm_cb.cc.
Referenced by setup_lambdas().
uint32_t predict_bandit_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec | ||
) |
Definition at line 391 of file warm_cb.cc.
References warm_cb::a_s_adf, warm_cb::app_seed, ACTION_SCORE::begin_scores(), copy_example_to_adf(), warm_cb::cumulative_costs, warm_cb::ecs, ACTION_SCORE::end_scores(), warm_cb::example_counter, find_min(), LEARNER::learner< T, E >::predict(), exploration::sample_after_normalizing(), and THROW.
Referenced by predict_or_learn_bandit_adf().
void predict_or_learn_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec | ||
) |
Definition at line 472 of file warm_cb.cc.
References accumu_var_adf(), BANDIT_WS, corrupt_action(), polylabel::cs, warm_cb::cs_label, warm_cb::inter_iter, warm_cb::inter_period, INTERACTION, example::l, MULTICLASS::label_t::label, warm_cb::mc_label, polylabel::multi, polyprediction::multiclass, example::pred, SUPERVISED_WS, WARM_START, example::weight, warm_cb::ws_iter, warm_cb::ws_period, and warm_cb::ws_type.
void predict_or_learn_bandit_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec, | ||
int | ec_type | ||
) |
Definition at line 433 of file warm_cb.cc.
References warm_cb::a_s_adf, accumu_costs_iv_adf(), warm_cb::cl_adf, COST_SENSITIVE::label::costs, polylabel::cs, ind_update(), INTERACTION, example::l, MULTICLASS::label_t::label, learn_bandit_adf(), loss(), loss_cs(), polylabel::multi, polyprediction::multiclass, example::pred, predict_bandit_adf(), and THROW.
void predict_or_learn_sup_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec, | ||
int | ec_type | ||
) |
Definition at line 381 of file warm_cb.cc.
References ind_update(), and predict_sup_adf().
uint32_t predict_sublearner_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec, | ||
uint32_t | i | ||
) |
Definition at line 303 of file warm_cb.cc.
References copy_example_to_adf(), warm_cb::ecs, and LEARNER::learner< T, E >::predict().
Referenced by accumu_costs_iv_adf(), and predict_sup_adf().
uint32_t predict_sup_adf | ( | warm_cb & | data, |
multi_learner & | base, | ||
example & | ec | ||
) |
Definition at line 337 of file warm_cb.cc.
References warm_cb::cumulative_costs, find_min(), and predict_sublearner_adf().
Referenced by accumu_var_adf(), and predict_or_learn_sup_adf().
void setup_lambdas | ( | warm_cb & | data | ) |
Definition at line 202 of file warm_cb.cc.
References ABS_CENTRAL, ABS_CENTRAL_ZEROONE, warm_cb::choices_lambda, warm_cb::epsilon, f, warm_cb::lambda_scheme, warm_cb::lambdas, MINIMAX_CENTRAL_ZEROONE, minimax_lambda(), warm_cb::upd_inter, and warm_cb::upd_ws.
Referenced by init_adf_data().
base_learner* warm_cb_setup | ( | options_i & | options, |
vw & | all | ||
) |
Definition at line 552 of file warm_cb.cc.
References ABS_CENTRAL, VW::config::option_group_definition::add(), add(), VW::config::options_i::add_and_parse(), LEARNER::as_multiline(), vw::delete_prediction, f, finish(), vw::get_random_state(), init_adf_data(), LEARNER::init_cost_sensitive_learner(), LEARNER::init_multiclass_learner(), VW::config::options_i::insert(), LEARNER::make_base(), VW::config::make_option(), vw::p, LEARNER::learner< T, E >::set_finish(), setup_base(), THROW, prediction_type::to_string(), UAR, uniform_hash(), and VW::config::options_i::was_supplied().
Referenced by parse_reductions().