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

爱⌒轻易说出口 提交于 2019-12-23 02:52:50

问题


I am trying to use Vowpal Wabbit for one multi class classification task with 154 different class labels as follows:

  1. Trained VW model with large amount of data.
  2. Tested the model with one dedicated test set.

In this scenario I was able to hit >80% result, which is good. But the problem which currently I am working on is:

I have to replicate the real time prediction scenario. In this case I have to pass one data point (i.e text line) at a time so that model can predict the value and output.

I have tried out all the options which I knew but failed. Can any of you let me know how to create a real time scenario by passing one data point along with VW command but not as a file.


回答1:


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.



来源:https://stackoverflow.com/questions/30882838/how-to-use-vowpal-wabbit-for-online-prediction-streaming-mode

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