Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Langford <jl@hunch.net>2014-01-29 02:28:32 +0400
committerJohn Langford <jl@hunch.net>2014-01-29 02:28:32 +0400
commit2fb8eca0a0d2a8ba5e8438145b5639486cc4c933 (patch)
tree6ebf73e8d06d551776f5235857eb7b5fe48f3609 /vowpalwabbit/cb.h
parent1a9eae25b5fc861af1f6714b3ad61822bcf4726f (diff)
baseline bag and cover approaches working
Diffstat (limited to 'vowpalwabbit/cb.h')
-rw-r--r--vowpalwabbit/cb.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/vowpalwabbit/cb.h b/vowpalwabbit/cb.h
index 38418b6a..066410b1 100644
--- a/vowpalwabbit/cb.h
+++ b/vowpalwabbit/cb.h
@@ -49,6 +49,34 @@ namespace CB {
copy_label,
sizeof(label)};
+ template <bool is_learn>
+ float get_cost_pred(vw& all, cb_class* known_cost, example& ec, uint32_t index, uint32_t base)
+ {
+ CB::label* ld = (CB::label*)ec.ld;
+
+ label_data simple_temp;
+ simple_temp.initial = 0.;
+ if (known_cost != NULL && index == known_cost->action)
+ {
+ simple_temp.label = known_cost->cost;
+ simple_temp.weight = 1.;
+ }
+ else
+ {
+ simple_temp.label = FLT_MAX;
+ simple_temp.weight = 0.;
+ }
+
+ ec.ld = &simple_temp;
+
+ if (is_learn)
+ all.scorer->learn(ec, index-1+base);
+ else
+ all.scorer->predict(ec, index-1+base);
+ ec.ld = ld;
+
+ return ec.final_prediction;
+ }
}
#endif