22 multiline_learn_or_predict<is_learn>(base, examples, examples[0]->ft_offset);
25 uint32_t chosen_action = -1;
27 int labelled_action = -1;
29 auto it = std::find_if(examples.begin(), examples.end(), [](
example *item) {
return !item->l.cb.costs.empty(); });
30 if (it != examples.end())
32 labelled_action = std::distance(examples.begin(), it);
37 if (is_learn && labelled_action != -1)
41 for (
size_t i = 0; i < action_scores.size(); i++)
43 auto &a_s = action_scores[i];
44 if (a_s.action == static_cast<uint32_t>(labelled_action))
46 chosen_action =
static_cast<uint32_t
>(i);
53 bool tag_provided_seed =
false;
55 if (!examples[0]->tag.empty())
57 const std::string SEED_IDENTIFIER =
"seed=";
58 if (strncmp(examples[0]->tag.begin(), SEED_IDENTIFIER.c_str(), SEED_IDENTIFIER.size()) == 0 &&
59 examples[0]->tag.size() > SEED_IDENTIFIER.size())
61 substring tag_seed{examples[0]->tag.
begin() + 5, examples[0]->tag.begin() + examples[0]->tag.size()};
63 tag_provided_seed =
true;
74 if (!tag_provided_seed)
size_t substring_len(substring &s)
int sample_after_normalizing(uint64_t seed, It pdf_first, It pdf_last, uint32_t &chosen_index)
Sample an index from the provided pdf. If the pdf is not normalized it will be updated in-place...
v_array< action_score > action_scores
VW_STD14_CONSTEXPR uint64_t uniform_hash(const void *key, size_t len, uint64_t seed)
score_iterator begin_scores(action_scores &a_s)
score_iterator end_scores(action_scores &a_s)
std::shared_ptr< rand_state > _random_state
int swap_chosen(ActionIt action_first, ActionIt action_last, uint32_t chosen_index)
Swap the first value with the chosen index.