Vowpal Wabbit
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
shared_data Struct Reference

#include <global_data.h>

Public Member Functions

double weighted_examples ()
 
void update (bool test_example, bool labeled_example, float loss, float weight, size_t num_features)
 
void update_dump_interval (bool progress_add, float progress_arg)
 
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_update (bool holdout_set_off, size_t current_pass, uint32_t label, uint32_t prediction, size_t num_features, bool progress_add, float progress_arg)
 
void print_update (bool holdout_set_off, size_t current_pass, const std::string &label, uint32_t prediction, size_t num_features, bool progress_add, float progress_arg)
 
void print_update (bool holdout_set_off, size_t current_pass, const std::string &label, const std::string &prediction, size_t num_features, bool progress_add, float progress_arg)
 

Public Attributes

size_t queries
 
uint64_t example_number
 
uint64_t total_features
 
double t
 
double weighted_labeled_examples
 
double old_weighted_labeled_examples
 
double weighted_unlabeled_examples
 
double weighted_labels
 
double sum_loss
 
double sum_loss_since_last_dump
 
float dump_interval
 
double gravity
 
double contraction
 
float min_label
 
float max_label
 
namedlabelsldict
 
double weighted_holdout_examples
 
double weighted_holdout_examples_since_last_dump
 
double holdout_sum_loss_since_last_dump
 
double holdout_sum_loss
 
double holdout_best_loss
 
double weighted_holdout_examples_since_last_pass
 
double holdout_sum_loss_since_last_pass
 
size_t holdout_best_pass
 
bool report_multiclass_log_loss
 
double multiclass_log_loss
 
double holdout_multiclass_log_loss
 
bool is_more_than_two_labels_observed
 
float first_observed_label
 
float second_observed_label
 

Static Public Attributes

static constexpr int col_avg_loss = 8
 
static constexpr int prec_avg_loss = 6
 
static constexpr int col_since_last = 8
 
static constexpr int prec_since_last = 6
 
static constexpr int col_example_counter = 12
 
static constexpr int col_example_weight = col_example_counter + 2
 
static constexpr int prec_example_weight = 1
 
static constexpr int col_current_label = 8
 
static constexpr int prec_current_label = 4
 
static constexpr int col_current_predict = 8
 
static constexpr int prec_current_predict = 4
 
static constexpr int col_current_features = 8
 

Detailed Description

Definition at line 133 of file global_data.h.

Member Function Documentation

◆ print_update() [1/4]

void shared_data::print_update ( bool  holdout_set_off,
size_t  current_pass,
float  label,
float  prediction,
size_t  num_features,
bool  progress_add,
float  progress_arg 
)
inline

Definition at line 225 of file global_data.h.

References CB::print_update().

Referenced by MULTICLASS::direct_print_update(), MULTICLASS::print_label_pred(), no_label::print_no_label_update(), MULTICLASS::print_probability(), MULTICLASS::print_score(), print_update(), MULTILABEL::print_update(), CB::print_update(), COST_SENSITIVE::print_update(), CCB::print_update(), CB_EXPLORE::print_update_cb_explore(), and return_example().

227  {
228  std::ostringstream label_buf, pred_buf;
229 
230  label_buf << std::setw(col_current_label) << std::setfill(' ');
231  if (label < FLT_MAX)
232  label_buf << std::setprecision(prec_current_label) << std::fixed << std::right << label;
233  else
234  label_buf << std::left << " unknown";
235 
236  pred_buf << std::setw(col_current_predict) << std::setprecision(prec_current_predict) << std::fixed << std::right
237  << std::setfill(' ') << prediction;
238 
239  print_update(
240  holdout_set_off, current_pass, label_buf.str(), pred_buf.str(), num_features, progress_add, progress_arg);
241  }
static constexpr int prec_current_label
Definition: global_data.h:183
static constexpr int col_current_label
Definition: global_data.h:182
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)
Definition: global_data.h:225
static constexpr int prec_current_predict
Definition: global_data.h:185
static constexpr int col_current_predict
Definition: global_data.h:184

◆ print_update() [2/4]

void shared_data::print_update ( bool  holdout_set_off,
size_t  current_pass,
uint32_t  label,
uint32_t  prediction,
size_t  num_features,
bool  progress_add,
float  progress_arg 
)
inline

Definition at line 243 of file global_data.h.

References CB::print_update().

245  {
246  std::ostringstream label_buf, pred_buf;
247 
248  label_buf << std::setw(col_current_label) << std::setfill(' ');
249  if (label < INT_MAX)
250  label_buf << std::right << label;
251  else
252  label_buf << std::left << " unknown";
253 
254  pred_buf << std::setw(col_current_predict) << std::right << std::setfill(' ') << prediction;
255 
256  print_update(
257  holdout_set_off, current_pass, label_buf.str(), pred_buf.str(), num_features, progress_add, progress_arg);
258  }
static constexpr int col_current_label
Definition: global_data.h:182
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)
Definition: global_data.h:225
static constexpr int col_current_predict
Definition: global_data.h:184

◆ print_update() [3/4]

void shared_data::print_update ( bool  holdout_set_off,
size_t  current_pass,
const std::string &  label,
uint32_t  prediction,
size_t  num_features,
bool  progress_add,
float  progress_arg 
)
inline

Definition at line 260 of file global_data.h.

References CB::print_update().

262  {
263  std::ostringstream pred_buf;
264 
265  pred_buf << std::setw(col_current_predict) << std::right << std::setfill(' ') << prediction;
266 
267  print_update(holdout_set_off, current_pass, label, pred_buf.str(), num_features, progress_add, progress_arg);
268  }
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)
Definition: global_data.h:225
static constexpr int col_current_predict
Definition: global_data.h:184

◆ print_update() [4/4]

void shared_data::print_update ( bool  holdout_set_off,
size_t  current_pass,
const std::string &  label,
const std::string &  prediction,
size_t  num_features,
bool  progress_add,
float  progress_arg 
)
inline

Definition at line 270 of file global_data.h.

272  {
273  std::streamsize saved_w = std::cerr.width();
274  std::streamsize saved_prec = std::cerr.precision();
275  std::ostream::fmtflags saved_f = std::cerr.flags();
276  bool holding_out = false;
277 
278  if (!holdout_set_off && current_pass >= 1)
279  {
280  if (holdout_sum_loss == 0. && weighted_holdout_examples == 0.)
281  std::cerr << std::setw(col_avg_loss) << std::left << " unknown";
282  else
283  std::cerr << std::setw(col_avg_loss) << std::setprecision(prec_avg_loss) << std::fixed << std::right
285 
286  std::cerr << " ";
287 
289  std::cerr << std::setw(col_since_last) << std::left << " unknown";
290  else
291  std::cerr << std::setw(col_since_last) << std::setprecision(prec_since_last) << std::fixed << std::right
293 
296 
297  holding_out = true;
298  }
299  else
300  {
301  std::cerr << std::setw(col_avg_loss) << std::setprecision(prec_avg_loss) << std::right << std::fixed;
302  if (weighted_labeled_examples > 0.)
303  std::cerr << (sum_loss / weighted_labeled_examples);
304  else
305  std::cerr << "n.a.";
306  std::cerr << " " << std::setw(col_since_last) << std::setprecision(prec_avg_loss) << std::right << std::fixed;
308  std::cerr << "n.a.";
309  else
311  }
312  std::cerr << " " << std::setw(col_example_counter) << std::right << example_number << " "
313  << std::setw(col_example_weight) << std::setprecision(prec_example_weight) << std::right
314  << weighted_examples() << " " << std::setw(col_current_label) << std::right << label << " "
315  << std::setw(col_current_predict) << std::right << prediction << " " << std::setw(col_current_features)
316  << std::right << num_features;
317 
318  if (holding_out)
319  std::cerr << " h";
320 
321  std::cerr << std::endl;
322  std::cerr.flush();
323 
324  std::cerr.width(saved_w);
325  std::cerr.precision(saved_prec);
326  std::cerr.setf(saved_f);
327 
328  update_dump_interval(progress_add, progress_arg);
329  }
static constexpr int col_current_features
Definition: global_data.h:186
double sum_loss
Definition: global_data.h:145
static constexpr int prec_avg_loss
Definition: global_data.h:176
static constexpr int col_current_label
Definition: global_data.h:182
static constexpr int col_avg_loss
Definition: global_data.h:175
static constexpr int col_since_last
Definition: global_data.h:177
static constexpr int prec_example_weight
Definition: global_data.h:181
double sum_loss_since_last_dump
Definition: global_data.h:146
static constexpr int col_example_weight
Definition: global_data.h:180
double old_weighted_labeled_examples
Definition: global_data.h:142
double weighted_holdout_examples
Definition: global_data.h:156
double holdout_sum_loss
Definition: global_data.h:159
static constexpr int col_example_counter
Definition: global_data.h:179
uint64_t example_number
Definition: global_data.h:137
static constexpr int prec_since_last
Definition: global_data.h:178
double weighted_labeled_examples
Definition: global_data.h:141
double weighted_holdout_examples_since_last_dump
Definition: global_data.h:157
double holdout_sum_loss_since_last_dump
Definition: global_data.h:158
static constexpr int col_current_predict
Definition: global_data.h:184
double weighted_examples()
Definition: global_data.h:188
void update_dump_interval(bool progress_add, float progress_arg)
Definition: global_data.h:215

◆ update()

void shared_data::update ( bool  test_example,
bool  labeled_example,
float  loss,
float  weight,
size_t  num_features 
)
inline

Definition at line 190 of file global_data.h.

References loss().

Referenced by MULTICLASS::finish_example(), MWT::finish_example(), finish_example_scores(), output_and_account_confidence_example(), output_and_account_example(), no_label::output_and_account_no_label_example(), EXPLORE_EVAL::output_example(), VW::cb_explore_adf::cb_explore_adf_base< ExploreType >::output_example(), CB_ALGS::output_example(), MULTILABEL::output_example(), output_example(), CB_EXPLORE::output_example(), COST_SENSITIVE::output_example(), CCB::output_example(), return_example(), and Search::train_single_example().

191  {
192  t += weight;
193  if (test_example && labeled_example)
194  {
195  weighted_holdout_examples += weight; // test weight seen
200  holdout_sum_loss_since_last_pass += loss; // since last pass
201  }
202  else
203  {
204  if (labeled_example)
206  else
208  sum_loss += loss;
210  total_features += num_features;
211  example_number++;
212  }
213  }
double sum_loss
Definition: global_data.h:145
constexpr bool test_example(example &ec) noexcept
Definition: bfgs.cc:147
double holdout_sum_loss_since_last_pass
Definition: global_data.h:163
double weighted_unlabeled_examples
Definition: global_data.h:143
float loss(cbify &data, uint32_t label, uint32_t final_prediction)
Definition: cbify.cc:60
double sum_loss_since_last_dump
Definition: global_data.h:146
double weighted_holdout_examples
Definition: global_data.h:156
double weighted_holdout_examples_since_last_pass
Definition: global_data.h:162
double holdout_sum_loss
Definition: global_data.h:159
float weight
Definition: global_data.h:51
uint64_t example_number
Definition: global_data.h:137
double weighted_labeled_examples
Definition: global_data.h:141
double weighted_holdout_examples_since_last_dump
Definition: global_data.h:157
double holdout_sum_loss_since_last_dump
Definition: global_data.h:158
uint64_t total_features
Definition: global_data.h:138

◆ update_dump_interval()

void shared_data::update_dump_interval ( bool  progress_add,
float  progress_arg 
)
inline

Definition at line 215 of file global_data.h.

Referenced by finish_example(), and Search::print_update().

216  {
219  if (progress_add)
220  dump_interval = (float)weighted_examples() + progress_arg;
221  else
222  dump_interval = (float)weighted_examples() * progress_arg;
223  }
double sum_loss_since_last_dump
Definition: global_data.h:146
double old_weighted_labeled_examples
Definition: global_data.h:142
double weighted_labeled_examples
Definition: global_data.h:141
double weighted_examples()
Definition: global_data.h:188
float dump_interval
Definition: global_data.h:147

◆ weighted_examples()

double shared_data::weighted_examples ( )
inline

Member Data Documentation

◆ col_avg_loss

constexpr int shared_data::col_avg_loss = 8
static

Definition at line 175 of file global_data.h.

Referenced by setup().

◆ col_current_features

constexpr int shared_data::col_current_features = 8
static

Definition at line 186 of file global_data.h.

Referenced by setup().

◆ col_current_label

constexpr int shared_data::col_current_label = 8
static

Definition at line 182 of file global_data.h.

Referenced by init_driver(), CCB::print_update(), and setup().

◆ col_current_predict

constexpr int shared_data::col_current_predict = 8
static

◆ col_example_counter

constexpr int shared_data::col_example_counter = 12
static

Definition at line 179 of file global_data.h.

Referenced by init_driver(), print_ex(), and setup().

◆ col_example_weight

constexpr int shared_data::col_example_weight = col_example_counter + 2
static

Definition at line 180 of file global_data.h.

Referenced by init_driver(), and setup().

◆ col_since_last

constexpr int shared_data::col_since_last = 8
static

Definition at line 177 of file global_data.h.

Referenced by setup().

◆ contraction

double shared_data::contraction

◆ dump_interval

float shared_data::dump_interval

◆ example_number

uint64_t shared_data::example_number

◆ first_observed_label

float shared_data::first_observed_label

Definition at line 171 of file global_data.h.

Referenced by count_label(), and get_best_constant().

◆ gravity

double shared_data::gravity

◆ holdout_best_loss

double shared_data::holdout_best_loss

◆ holdout_best_pass

size_t shared_data::holdout_best_pass

Definition at line 164 of file global_data.h.

Referenced by summarize_holdout_set().

◆ holdout_multiclass_log_loss

double shared_data::holdout_multiclass_log_loss

Definition at line 168 of file global_data.h.

Referenced by VW::finish(), finish_example_scores(), and CSOAA::output_example_seq().

◆ holdout_sum_loss

double shared_data::holdout_sum_loss

Definition at line 159 of file global_data.h.

Referenced by Search::print_update().

◆ holdout_sum_loss_since_last_dump

double shared_data::holdout_sum_loss_since_last_dump

Definition at line 158 of file global_data.h.

Referenced by Search::print_update().

◆ holdout_sum_loss_since_last_pass

double shared_data::holdout_sum_loss_since_last_pass

Definition at line 163 of file global_data.h.

Referenced by process_pass(), and summarize_holdout_set().

◆ is_more_than_two_labels_observed

bool shared_data::is_more_than_two_labels_observed

Definition at line 170 of file global_data.h.

Referenced by count_label(), and get_best_constant().

◆ ldict

namedlabels* shared_data::ldict

◆ max_label

float shared_data::max_label

◆ min_label

float shared_data::min_label

◆ multiclass_log_loss

double shared_data::multiclass_log_loss

Definition at line 167 of file global_data.h.

Referenced by VW::finish(), finish_example_scores(), and CSOAA::output_example_seq().

◆ old_weighted_labeled_examples

double shared_data::old_weighted_labeled_examples

Definition at line 142 of file global_data.h.

Referenced by Search::print_update(), and GD::save_load_online_state().

◆ prec_avg_loss

constexpr int shared_data::prec_avg_loss = 6
static

Definition at line 176 of file global_data.h.

◆ prec_current_label

constexpr int shared_data::prec_current_label = 4
static

Definition at line 183 of file global_data.h.

◆ prec_current_predict

constexpr int shared_data::prec_current_predict = 4
static

Definition at line 185 of file global_data.h.

◆ prec_example_weight

constexpr int shared_data::prec_example_weight = 1
static

Definition at line 181 of file global_data.h.

◆ prec_since_last

constexpr int shared_data::prec_since_last = 6
static

Definition at line 178 of file global_data.h.

◆ queries

size_t shared_data::queries

◆ report_multiclass_log_loss

bool shared_data::report_multiclass_log_loss

Definition at line 166 of file global_data.h.

Referenced by CSOAA::csldf_setup(), VW::finish(), and oaa_setup().

◆ second_observed_label

float shared_data::second_observed_label

Definition at line 172 of file global_data.h.

Referenced by count_label(), and get_best_constant().

◆ sum_loss

double shared_data::sum_loss

◆ sum_loss_since_last_dump

double shared_data::sum_loss_since_last_dump

◆ t

double shared_data::t

◆ total_features

uint64_t shared_data::total_features

◆ weighted_holdout_examples

double shared_data::weighted_holdout_examples

Definition at line 156 of file global_data.h.

Referenced by GD::get_scale(), and Search::print_update().

◆ weighted_holdout_examples_since_last_dump

double shared_data::weighted_holdout_examples_since_last_dump

Definition at line 157 of file global_data.h.

Referenced by Search::print_update().

◆ weighted_holdout_examples_since_last_pass

double shared_data::weighted_holdout_examples_since_last_pass

Definition at line 162 of file global_data.h.

Referenced by process_pass(), and summarize_holdout_set().

◆ weighted_labeled_examples

double shared_data::weighted_labeled_examples

◆ weighted_labels

double shared_data::weighted_labels

◆ weighted_unlabeled_examples

double shared_data::weighted_unlabeled_examples

The documentation for this struct was generated from the following file: