How to use vowpal wabbit for online prediction (streaming mode)

冷暖自知 提交于 2019-12-08 00:48:32

You can use vw as a daemon:

vw --daemon --port 54321 --quiet -i model_file -t --num_children 1

Now vw loads the model and listens on port 54321 (on localhost). Every time you send a line (ending with a newline, ASCII 10) to localhost:54321 you'll get a prediction back on the same socket, for example:

echo " | your features here..." | netcat localhost 54321

This is just an example, normally you would write a program that will write and then read from the socket in a loop instead of calling netcat.

You can also call vw in regular input/output and prediction mode:

vw --quiet -i model_file -t -p /dev/stdout

And write to it (via stdin) and read from it (via stdout). The key is that you'll get one line of output for each line of input you send, in the same order. You can also send N lines at a time, and then read back N responses. The order relative order of requests vs responses is guaranteed to be preserved.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!