16 namespace cb_explore_adf
35 template <
bool is_learn>
44 template <
bool is_learn>
48 LEARNER::multiline_learn_or_predict<is_learn>(base, examples, examples[0]->ft_offset);
52 uint32_t num_actions = (uint32_t)preds.
size();
57 for (
size_t i = 0; i < num_actions; i++) preds[i].score = prob;
60 for (
size_t i = 0; i < tied_actions; ++i) preds[i].score += (1.
f -
_epsilon) / tied_actions;
69 bool cb_explore_adf_option =
false;
71 bool first_only =
false;
77 .help(
"Online explore-exploit for a contextual bandit problem with multiline action dependent features"))
78 .
add(
make_option(
"epsilon", epsilon).keep().help(
"epsilon-greedy exploration"))
79 .
add(
make_option(
"first_only", first_only).keep().help(
"Only explore the first action in a tie-breaking event"));
87 if (!cb_explore_adf_option || !use_greedy)
93 options.
insert(
"cb_adf",
"");
98 size_t problem_multiplier = 1;
108 auto data = scoped_calloc_or_throw<explore_type>(epsilon, first_only);
void predict_or_learn_impl(LEARNER::multi_learner &base, multi_ex &examples)
LEARNER::base_learner * setup(VW::config::options_i &options, vw &all)
void(* delete_prediction)(void *)
void finish_multiline_example(vw &all, cbify &, multi_ex &ec_seq)
label_type::label_type_t label_type
base_learner * make_base(learner< T, E > &base)
virtual void add_and_parse(const option_group_definition &group)=0
size_t fill_tied(v_array< ACTION_SCORE::action_score > &preds)
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)
void delete_action_scores(void *v)
virtual bool was_supplied(const std::string &key)=0
void predict(LEARNER::multi_learner &base, multi_ex &examples)
~cb_explore_adf_greedy()=default
virtual void insert(const std::string &key, const std::string &value)=0
option_group_definition & add(T &&op)
std::vector< example * > multi_ex
cb_explore_adf_greedy(float epsilon, bool first_only)
typed_option< T > make_option(std::string name, T &location)
void learn(LEARNER::multi_learner &base, multi_ex &examples)
LEARNER::base_learner * setup_base(options_i &options, vw &all)
void predict(bfgs &b, base_learner &, example &ec)
void learn(bfgs &b, base_learner &base, example &ec)
multi_learner * as_multiline(learner< T, E > *l)