【问题标题】:Vowpal Wabbit python wrapper empty prediction fileVowpal Wabbit python 包装器空预测文件
【发布时间】:2017-03-27 14:06:21
【问题描述】:

从 pyvw 包装器调用时预测文件为空。 例如,我正在做类似的事情,

vw = pyvw.vw(" -i cb.model --cb_explore 50 --cover 10 -p prediction.txt")
ex = vw.example(" | label label2")
vw.predict(ex)
vw.finish()
ex.finish() 

这会创建 prediction.txt,但不会向其中写入任何内容。

非常感谢任何指导。

谢谢!

【问题讨论】:

  • 我认为 Python 包装器的目的是您不需要通过文件进行通信。您应该直接使用 API 调用提取预测。也就是说,如果您在参数中提供-p,我同意pyvw.vw 应该产生警告/异常。

标签: vowpalwabbit


【解决方案1】:

这个 sn-p 可能会对你有所帮助:

from vowpalwabbit import pyvw

def to_vw(clf, text, str_label):
    vw_example = str('{} |f {} '.format(str_label, text))
    return clf.example(vw_example)

clf = vw = pyvw.vw(
    loss_function='logistic', oaa=2,
    link='logistic', raw_predictions='output.txt'
)

ex = to_vw(clf, 'I like vowpal wabbit. But not that much.', '1')
clf.learn(ex)
clf.predict(ex, labelType=pyvw.pylibvw.vw.lMulticlass)

您应该将概率写入output.txt 文件。

【讨论】:

    猜你喜欢
    • 2015-02-19
    • 2016-04-20
    • 2016-01-05
    • 2015-11-16
    • 2014-09-10
    • 1970-01-01
    • 2014-03-12
    • 2023-03-27
    • 2014-08-29
    相关资源
    最近更新 更多