How do I get the raw predictions (-r) from Vowpal Wabbit when running in daemon mode?

506 views Asked by At

Using the below, I'm able to get both the raw predictions and the final predictions as a file:

cat train.vw.txt | vw -c -k --passes 30 --ngram 5 -b 28 --l1 0.00000001 --l2 0.0000001 --loss_function=logistic -f model.vw --compressed --oaa 3

cat test.vw.txt | vw -t -i model.vw --link=logistic -r raw.txt -p predictions.txt

However, I'm unable to get the raw predictions when I run VW as a daemon:

vw -t -i model.vw --daemon --port 26542 --link=logistic

Do I have a pass in a specific argument or parameter to get the raw predictions? I prefer the raw predictions, not the final predictions. Thanks

4

There are 4 answers

6
arielf On BEST ANSWER

On systems supporting /dev/stdout (and /dev/stderr), you may try this:

vw -t -i model.vw --daemon --port 26542 --link=logistic -r /dev/stdout

The daemon will write raw predictions into standard output which in this case end up in the same place as localhost port 26542.

The relative order of lines is guaranteed because the code dealing with different prints within each example (e.g non-raw vs raw) is always serial.

1
Martin Popel On

--raw_predictions is a kind of hack (the semantic depends on the reductions used) and it is not supported in --daemon mode. (Something like --output_probabilities would be useful and not difficult to implement and it would work in daemon mode, but so far no one had time to implement it.)

As a workaround, you can run VW in a pipe, so it reads stdin and writes the probabilities to stdout:

cat test.data | vw -t -i model.vw --link=logistic -r /dev/stdout | script.sh

0
Andrey Segrenev On

According to https://github.com/VowpalWabbit/vowpal_wabbit/issues/1118 you can try adding --scores option in command line: vw --scores -t -i model.vw --daemon --port 26542

It helped me with my oaa model.

0
Martin Popel On

Since November 2015, the easiest way how to obtain probabilities is to use --oaa=N --loss_function=logistic --probabilities -p probs.txt. (Or if you need label-dependent features: --csoaa_ldf=mc --loss_function=logistic --probabilities -p probs.txt.)

--probabilities work with --daemon as well. There should be no more need for using --raw_predictions.