Skip to content

Instantly share code, notes, and snippets.

@montenegrodr
Created November 14, 2016 12:51
Show Gist options
  • Save montenegrodr/f69c9637182f3f1bf5356c2b5c9b002e to your computer and use it in GitHub Desktop.
Save montenegrodr/f69c9637182f3f1bf5356c2b5c9b002e to your computer and use it in GitHub Desktop.
from vowpalwabbit import pyvw
def to_vw(clf, text, str_labels):
vw_example = str('{} |f {} '.format(str_labels, 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment