Skip to content

Commit

Permalink
bugfix: cb_adf is not including some examples in stats calculation (#…
Browse files Browse the repository at this point in the history
…1686)

* bugfix:  cb_adf is not including examples without shared features in stats calculations and output_example

* Added RunTest for cb_adf without shared features
  • Loading branch information
rajan-chari authored and JohnLangford committed Dec 11, 2018
1 parent 887f251 commit f085178
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/RunTests
Original file line number Diff line number Diff line change
Expand Up @@ -1632,3 +1632,7 @@ echo "1 | feature:1" | {VW} -a --initial_weight 0.1 --initial_t 0.3
# Test 174 cbify adf, regcbopt
{VW} --cbify 10 --cb_explore_adf --cb_type mtr --regcbopt --mellowness 0.01 -d train-sets/multiclass
train-sets/ref/cbify_regcbopt.stderr
# Test 175 cb_adf, sharedfeatures
{VW} --dsjson --cb_adf -d train-sets/no_shared_features.json
train-sets/ref/no_shared_features.stderr
1 change: 1 addition & 0 deletions test/train-sets/no_shared_features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_label_cost":0,"_label_probability":0.333333343,"_label_Action":2,"_labelIndex":1,"o":[{"EventId":"f5547244f88543d1bcad0e3416fbd592","v":{"reward":0.0,"value4":0.0,"value1":0.0,"value2":1400.0,"value3":0.0}}],"Timestamp":"2018-11-22T02:31:39.1440000Z","Version":"1","EventId":"f5547244f88543d1bcad0e3416fbd592","a":[2,1,3],"c":{"_multi":[{"name3":{"name4":4.65312243,"name2":1.0}},{"name3":{"name":4.65312243,"name2":1.0}},{"name3":{"name5":4.65312243}}]},"p":[0.333333343,0.333333343,0.333333343],"VWState":{"m":"N/A"}}
17 changes: 17 additions & 0 deletions test/train-sets/ref/no_shared_features.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Num weight bits = 18
learning rate = 0.5
initial_t = 0
power_t = 0.5
using no cache
Reading datafile = train-sets/no_shared_features.json
num sources = 1
average since example example current current current
loss last counter weight label predict features
0.000000 0.000000 1 1.0 known 0:0... 8

finished run
number of examples = 1
weighted example sum = 1.000000
weighted label sum = 0.000000
average loss = 0.000000
total feature number = 8
2 changes: 1 addition & 1 deletion vowpalwabbit/cb_adf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ bool update_statistics(vw& all, cb_adf& c, example& ec, multi_ex* ec_seq)

void output_example(vw& all, cb_adf& c, example& ec, multi_ex* ec_seq)
{
if (example_is_newline(ec) || (CB::ec_is_example_header(ec) && ec_seq->size() == 1)) return;
if (example_is_newline_not_header(ec)) return;

bool labeled_example = update_statistics(all, c, ec, ec_seq);

Expand Down

0 comments on commit f085178

Please sign in to comment.