Skip to content

Commit

Permalink
Merge pull request #319 from frx/streaming_vw
Browse files Browse the repository at this point in the history
Made VW output more exact.
  • Loading branch information
Soeren Sonnenburg committed Aug 28, 2011
2 parents 973318c + 1b08079 commit 2f0a2c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/shogun/classifier/vw/VowpalWabbit.cpp
Expand Up @@ -222,6 +222,7 @@ void CVowpalWabbit::init(CStreamingVwFeatures* feat)
quiet = false;
no_training = false;
dump_interval = exp(1.);
sum_loss_since_last_dump = 0.;
reg_name = NULL;
reg_dump_text = true;
save_predictions = false;
Expand Down Expand Up @@ -309,6 +310,7 @@ void CVowpalWabbit::output_example(VwExample* &example)
{
if (!quiet)
{
sum_loss_since_last_dump += example->loss;
if (env->weighted_examples + example->ld->weight > dump_interval)
{
print_update(example);
Expand All @@ -328,14 +330,16 @@ void CVowpalWabbit::output_example(VwExample* &example)

void CVowpalWabbit::print_update(VwExample* &ex)
{
SG_SPRINT("%-10.6f %-10.6f %8lld %8.1f %8.4f %8.4f %8lu\n",
env->sum_loss/env->weighted_examples,
0.0,
env->example_number,
env->weighted_examples,
SG_SPRINT("%-10.6f %-10.6f %8lld %8.1f %8.4f %8.4f %8lu\n",
(env->sum_loss + ex->loss)/(env->weighted_examples + ex->ld->weight),
sum_loss_since_last_dump/(env->weighted_examples + ex->ld->weight - old_weighted_examples),
env->example_number + 1,
env->weighted_examples + ex->ld->weight,
ex->ld->label,
ex->final_prediction,
(long unsigned int)ex->num_features);
sum_loss_since_last_dump = 0.0;
old_weighted_examples = env->weighted_examples + ex->ld->weight;
}


Expand Down
6 changes: 4 additions & 2 deletions src/shogun/classifier/vw/VowpalWabbit.h
Expand Up @@ -280,16 +280,18 @@ class CVowpalWabbit: public COnlineLinearMachine

/// Multiplication factor for number of examples to dump after
float32_t dump_interval;
/// Sum of loss since last printed update
float32_t sum_loss_since_last_dump;
/// Number of weighted examples in previous dump
float64_t old_weighted_examples;

/// Name of file to save regressor to
char* reg_name;

/// Whether to save regressor as readable text or not
bool reg_dump_text;

/// Whether to save predictions or not
bool save_predictions;

/// Descriptor of prediction file
int32_t prediction_fd;
};
Expand Down

0 comments on commit 2f0a2c8

Please sign in to comment.