I am trying to use Vowpal Wabbit for one multi class classification task with 154 different class labels as follows:
- Trained VW model with large amount of data.
- 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.
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