Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ect output #97

Closed
wants to merge 2 commits into from

2 participants

@luispedro

Previously, I don't think there was a way to get the results of the ECT scheme. The output format is a bit artificial (everyone has 0, except the winner who gets 1), but it exactly the same as oaa, so I chose it as you can then switch between the two very easily.

@JohnLangford
Owner
@luispedro

-p works fine, but -r gives no output on master:

echo "2 | foo
2 | foo" | ./vw --ect 2 -r /dev/stdout --quiet
@JohnLangford
Owner
@luispedro

It was mostly for symmetry with other methods. This way, you can swap --oaa for --ect and keep the same code to parse the output of vw.

I can understand the reasons for rejecting the patch as a non-improvement, though. Your call.

@JohnLangford
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 27, 2013
  1. @luispedro

    ENH Output label from ect

    luispedro authored
Commits on Jan 28, 2013
  1. @luispedro
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 2 deletions.
  1. +16 −2 vowpalwabbit/ect.cc
View
18 vowpalwabbit/ect.cc
@@ -355,7 +355,7 @@ namespace ECT
}
}
- void learn(void*a, void* d, example* ec)
+ void learn_with_output(void* a, void* d, example* ec, bool shouldOutput)
{
vw* all = (vw*)a;
ect* e=(ect*)d;
@@ -364,6 +364,16 @@ namespace ECT
if (mc->label == 0 || (mc->label > e->k && mc->label != (uint32_t)-1))
cout << "label is not in {1,"<< e->k << "} This won't work right." << endl;
size_t new_label = ect_predict(*all, *e, ec);
+ if (shouldOutput) {
+ stringstream out;
+ for (int k = 1; k <= e->k; ++k) {
+ out << k;
+ if (k == new_label) out << ":1";
+ else out << ":0";
+ if (k != e->k) out << ' ';
+ }
+ all->print_text(all->raw_prediction, out.str(), ec->tag);
+ }
ec->ld = mc;
if (mc->label != (uint32_t)-1 && all->training)
@@ -372,6 +382,10 @@ namespace ECT
*(OAA::prediction_t*)&(ec->final_prediction) = new_label;
}
+ void learn(void*a, void* d, example* ec)
+ {
+ learn_with_output(a, d, ec, false);
+ }
void finish(void* all, void* d)
{
@@ -402,7 +416,7 @@ namespace ECT
{
if ((ec = get_example(all->p)) != NULL)//semiblocking operation.
{
- learn(all, d, ec);
+ learn_with_output(all, d, ec, all->raw_prediction > 0);
OAA::output_example(*all, ec);
VW::finish_example(*all, ec);
}
Something went wrong with that request. Please try again.