22 THROW(
"error NaN value for: " << name[0]);
25 std::cerr <<
"example with a wierd name. What is '";
33 size_t num = *(
size_t*)c;
36 size_t total =
sizeof(
wclass) * num;
37 if (cache.
buf_read(c, (
int)total) < total)
39 std::cout <<
"error in demarshal of cost data" << std::endl;
42 for (
size_t i = 0; i < num; i++)
46 ld->
costs.push_back(temp);
57 size_t total =
sizeof(size_t);
58 if (cache.
buf_read(c, (
int)total) < total)
69 *(
size_t*)c = ld->
costs.size();
71 for (
unsigned int i = 0; i < ld->
costs.size(); i++)
96 if (ld->
costs.size() == 0)
98 for (
unsigned int i = 0; i < ld->
costs.size(); i++)
99 if (FLT_MAX != ld->
costs[i].x)
108 ld->
costs.delete_v();
127 if (words.
size() == 1)
138 if (eq_shared || eq_label)
143 std::cerr <<
"shared feature vectors should not have costs on: " << words[0] << std::endl;
146 wclass f = {-FLT_MAX, 0, 0., 0.};
147 ld->
costs.push_back(f);
153 std::cerr <<
"label feature vectors should have exactly one cost on: " << words[0] << std::endl;
157 ld->
costs.push_back(f);
165 for (
unsigned int i = 0; i < words.
size(); i++)
171 THROW(
" invalid cost: specification -- no names on: " << words[i]);
183 ld->
costs.push_back(f);
197 if (ec_seq !=
nullptr)
199 num_current_features = 0;
201 for (
auto& ecc : *ec_seq) num_current_features += ecc->num_features;
204 std::string label_buf;
206 label_buf =
" unknown";
208 label_buf =
" known";
210 if (action_scores || all.
sd->
ldict)
212 std::ostringstream pred_buf;
223 pred_buf << ec.
pred.
a_s[0].action;
246 float chosen_loss = FLT_MAX;
248 for (
auto& cl : ld.
costs)
250 if (cl.class_index == pred)
255 if (chosen_loss == FLT_MAX)
256 std::cerr <<
"warning: csoaa predicted an invalid class. Are all multi-class labels in the {1..k} range?" 259 loss = (chosen_loss - min) * ec.
weight;
277 std::stringstream outputStringStream;
278 for (
unsigned int i = 0; i < ld.
costs.size(); i++)
282 outputStringStream <<
' ';
300 if (costs.
size() == 0)
302 for (
size_t j = 0; j < costs.
size(); j++)
303 if (costs[j].x != FLT_MAX)
311 if (costs.
size() != 1)
313 if (costs[0].class_index != 0)
315 if (costs[0].x != -FLT_MAX)
ACTION_SCORE::action_scores a_s
void copy_array(v_array< T > &dst, const v_array< T > &src)
v_array< int > final_prediction_sink
v_array< action_score > action_scores
void cache_label(void *v, io_buf &cache)
size_t read_cached_label(shared_data *, void *v, io_buf &cache)
bool ec_is_example_header(example const &ec)
void copy_label(void *dst, void *src)
float loss(cbify &data, uint32_t label, uint32_t final_prediction)
void delete_label(void *v)
v_array< substring > parse_name
bool example_is_test(example &ec)
float float_of_substring(substring s)
char * bufcache_label(label *ld, char *c)
void finish_example(vw &all, example &ec)
void tokenize(char delim, substring s, ContainerT &ret, bool allow_empty=false)
void print_update(bool holdout_set_off, size_t current_pass, float label, float prediction, size_t num_features, bool progress_add, float progress_arg)
void(* print_text)(int, std::string, v_array< char >)
void default_label(void *v)
void finish_example(vw &, example &)
void name_value(substring &s, v_array< substring > &name, float &v)
void parse_label(parser *p, shared_data *sd, void *v, v_array< substring > &words)
void update(bool test_example, bool labeled_example, float loss, float weight, size_t num_features)
void buf_write(char *&pointer, size_t n)
std::vector< example * > multi_ex
char * bufread_label(label *ld, char *c, io_buf &cache)
VW_STD14_CONSTEXPR uint64_t hashstring(substring s, uint64_t h)
bool substring_equal(const substring &a, const substring &b)
uint64_t get(substring &s)
void print_update(vw &all, bool is_test, example &ec, multi_ex *ec_seq, bool action_scores, uint32_t prediction)
static constexpr int col_current_predict
double weighted_examples()
void output_example(vw &all, example &ec)
void(* print)(int, float, float, v_array< char >)
size_t buf_read(char *&pointer, size_t n)