问题描述
我正在尝试将Vowpal Wabbit用于具有154种不同类别标签的一项多类别分类任务,如下所示:
I am trying to use Vowpal Wabbit for one multi class classification task with 154 different class labels as follows:
- 训练有素的大众模型,包含大量数据.
- 使用一个专用测试集测试了模型.
在这种情况下,我能够达到> 80%的结果,这很好.但是我目前正在研究的问题是:
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.
我尝试了所有我知道但失败的选择.谁能让我知道如何通过将一个数据点与VW命令一起传递而不是作为文件传递来创建实时方案.
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.
推荐答案
您可以将vw
用作守护程序:
You can use vw
as a daemon:
vw --daemon --port 54321 --quiet -i model_file -t --num_children 1
现在vw
加载模型并侦听端口54321(在localhost上).每次向localhost:54321
发送一行(以换行符结尾的ASCII 10)时,都会在同一个套接字上返回预测,例如:
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
这只是一个示例,通常您将编写一个程序,该程序将在循环中从套接字读取然后读取,而不是调用netcat
.
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
.
您还可以在常规输入/输出和预测模式下调用vw
:
You can also call vw
in regular input/output and prediction mode:
vw --quiet -i model_file -t -p /dev/stdout
并写入(通过stdin
)并从中读取(通过stdout
).关键在于,对于发送的每一行输入,您将以相同的顺序获得一行输出.您也可以一次发送N
行,然后回读N
响应.保证请求和响应的顺序相对顺序得以保留.
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.
这篇关于如何使用vowpal wabbit进行在线预测(流模式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!