Skip to content

Commit

Permalink
ready to push
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3 committed Sep 22, 2014
1 parent d2b96dd commit 6568385
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 303 deletions.
45 changes: 17 additions & 28 deletions python/pylibvw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,24 +359,13 @@ BOOST_PYTHON_MODULE(pylibvw) {
.def("get_topic_prediction", &VW::get_topic_prediction, "For LDA models, returns the topic prediction for the topic id given")
.def("get_feature_number", &VW::get_feature_number, "Returns the total number of features for this example")

// the following four are redundant with get_simplelabel_...
//.def("get_label", &VW::get_label, "Returns the label (simple_label only!) for this example")
//.def("get_importance", &VW::get_importance, "Returns the importance (simple_label only!) for this example")
//.def("get_initial", &VW::get_initial, "TODO")
//.def("get_prediction", &VW::get_prediction, "TODO")

.def("get_example_counter", &get_example_counter, "Returns the counter of total number of examples seen up to and including this one")
.def("get_ft_offset", &get_ft_offset, "Returns the feature offset for this example (used, eg, by multiclass classification to bulk offset all features)")
.def("get_partial_prediction", &get_partial_prediction, "Returns the partial prediction associated with this example")
.def("get_updated_prediction", &get_updated_prediction, "Returns the partial prediction as if we had updated it after learning")
.def("get_loss", &get_loss, "Returns the loss associated with this example")
.def("get_example_t", &get_example_t, "The total sum of importance weights up to and including this example")
.def("get_total_sum_feat_sq", &get_total_sum_feat_sq, "The total sum of feature-value squared for this example")
// .def_readwrite("revert_weight", &example::revert_weight)
// .def_readwrite("test_only", &example::test_only)
// .def_readwrite("end_pass", &example::end_pass)
// .def_readwrite("sorted", &example::sorted)
// .def_readwrite("in_use", &example::in_use)

.def("num_namespaces", &ex_num_namespaces, "The total number of namespaces associated with this example")
.def("namespace", &ex_namespace, "Get the namespace id for namespace i (for i = 0.. num_namespaces); specifically returns the ord() of the corresponding character id")
Expand Down Expand Up @@ -415,23 +404,23 @@ BOOST_PYTHON_MODULE(pylibvw) {
;

py::class_<Search::predictor, predictor_ptr>("predictor", py::no_init)
.def("set_input", &my_set_input, "TODO")
.def("set_input_ldf", &my_set_input_LDF, "TODO")
.def("add_oracle", &my_add_oracle, "TODO")
.def("add_oracles", &my_add_oracles, "TODO")
.def("add_allowed", &my_add_allowed, "TODO")
.def("add_alloweds", &my_add_alloweds, "TODO")
.def("add_condition", &my_add_condition, "TODO")
.def("add_condition_range", &my_add_condition_range, "TODO")
.def("set_oracle", &my_set_oracle, "TODO")
.def("set_oracles", &my_set_oracles, "TODO")
.def("set_allowed", &my_set_allowed, "TODO")
.def("set_alloweds", &my_set_alloweds, "TODO")
.def("set_condition", &my_set_condition, "TODO")
.def("set_condition_range", &my_set_condition_range, "TODO")
.def("set_learner_id", &my_set_learner_id, "TODO")
.def("set_tag", &my_set_tag, "TODO")
.def("predict", &Search::predictor::predict, "TODO")
.def("set_input", &my_set_input, "set the input (an example) for this predictor (non-LDF mode only)")
.def("set_input_ldf", &my_set_input_LDF, "set the inputs (a list of examples) for this predictor (LDF mode only)")
.def("add_oracle", &my_add_oracle, "add an action to the current list of oracle actions")
.def("add_oracles", &my_add_oracles, "add a list of actions to the current list of oracle actions")
.def("add_allowed", &my_add_allowed, "add an action to the current list of allowed actions")
.def("add_alloweds", &my_add_alloweds, "add a list of actions to the current list of allowed actions")
.def("add_condition", &my_add_condition, "add a (tag,char) pair to the list of variables on which to condition")
.def("add_condition_range", &my_add_condition_range, "given (tag,len,char), add (tag,char), (tag-1,char+1), ..., (tag-len,char+len) to the list of conditionings")
.def("set_oracle", &my_set_oracle, "set an action as the current list of oracle actions")
.def("set_oracles", &my_set_oracles, "set a list of actions as the current list of oracle actions")
.def("set_allowed", &my_set_allowed, "set an action as the current list of allowed actions")
.def("set_alloweds", &my_set_alloweds, "set a list of actions as the current list of allowed actions")
.def("set_condition", &my_set_condition, "set a (tag,char) pair as the list of variables on which to condition")
.def("set_condition_range", &my_set_condition_range, "given (tag,len,char), set (tag,char), (tag-1,char+1), ..., (tag-len,char+len) as the list of conditionings")
.def("set_learner_id", &my_set_learner_id, "select the learner with which to make this prediction")
.def("set_tag", &my_set_tag, "change the tag of this prediction")
.def("predict", &Search::predictor::predict, "make a prediction")
;

py::class_<Search::search, search_ptr>("search")
Expand Down
4 changes: 2 additions & 2 deletions test/RunTests
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ __DATA__
train-sets/ref/sequence_data.ldf.test.stderr
train-sets/ref/sequence_data.ldf.test.predict
# Test 48: search sequence SPAN labeling BIO, non-ldf train
{VW} -k -c -d train-sets/sequencespan_data --passes 20 --invariant --search_rollout oracle --search_alpha 1e-8 --search_task sequencespan --search 7 --holdout_off -f models/sequencespan_data.model
# Test 48: search sequence SPAN labeling BIO, non-ldf train, no rollouts
{VW} -k -c -d train-sets/sequencespan_data --passes 20 --invariant --search_rollout none --search_task sequencespan --search 7 --holdout_off -f models/sequencespan_data.model
train-sets/ref/sequencespan_data.nonldf.train.stderr
# Test 49: search sequence SPAN labeling BIO, non-ldf test
Expand Down
1 change: 0 additions & 1 deletion test/train-sets/ref/sequence_data.ldf.test-beam1.predict

This file was deleted.

24 changes: 0 additions & 24 deletions test/train-sets/ref/sequence_data.ldf.test-beam1.stderr

This file was deleted.

21 changes: 0 additions & 21 deletions test/train-sets/ref/sequence_data.ldf.test-beam20.predict

This file was deleted.

23 changes: 0 additions & 23 deletions test/train-sets/ref/sequence_data.ldf.test-beam20.stderr

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions test/train-sets/ref/sequence_data.nonldf.test-beam1.stderr

This file was deleted.

21 changes: 0 additions & 21 deletions test/train-sets/ref/sequence_data.nonldf.test-beam20.predict

This file was deleted.

23 changes: 0 additions & 23 deletions test/train-sets/ref/sequence_data.nonldf.test-beam20.stderr

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions test/train-sets/ref/sequencespan_data.nonldf.test-beam1.stderr

This file was deleted.

This file was deleted.

7 changes: 4 additions & 3 deletions test/train-sets/ref/sequencespan_data.nonldf.train.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ learning rate = 10
initial_t = 1
power_t = 0.5
decay_learning_rate = 1
no rollout!
creating cache_file = train-sets/sequencespan_data.cache
Reading datafile = train-sets/sequencespan_data
num sources = 1
average since instance current true current predicted cur cur predic cache examples
loss last counter output prefix output prefix pass pol made hits gener beta
6.000000 6.000000 1 [2 1 1 2 2 1 6 7 7 ..] [1 1 1 1 1 1 1 1 1 ..] 0 0 15 0 15 0.000000
8.500000 11.000000 2 [2 1 1 2 2 1 6 7 7 ..] [2 1 6 4 1 6 4 1 6 ..] 1 0 30 0 30 0.000000
6.000000 3.500000 4 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 3 0 60 0 60 0.000001
3.000000 0.000000 8 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 7 0 120 0 120 0.000001
1.500000 0.000000 16 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 15 0 240 0 240 0.000002
6.000000 3.500000 4 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 3 0 60 0 60 0.000000
3.000000 0.000000 8 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 7 0 120 0 120 0.000000
1.500000 0.000000 16 [2 1 1 2 2 1 6 7 7 ..] [2 1 1 2 2 1 6 7 7 ..] 15 0 240 0 240 0.000000

finished run
number of examples per pass = 1
Expand Down
2 changes: 1 addition & 1 deletion vowpalwabbit/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main(int argc, char *argv[])
}
cerr << endl << "weighted example sum = " << all->sd->weighted_examples;
cerr << endl << "weighted label sum = " << all->sd->weighted_labels;
if(all->holdout_set_off)
if(all->holdout_set_off || (all->sd->holdout_best_loss == FLT_MAX))
{
cerr << endl << "average loss = " << all->sd->sum_loss / all->sd->weighted_examples;
}
Expand Down
Loading

0 comments on commit 6568385

Please sign in to comment.