VW 9.8.0 CCB Multi line input format that includes included action ids, action cost and probabilities

82 Views Asked by At

I'm running into some confusion around the multi line example format and ccb; Using Python (vw 9.8.0), when starting vw with --cb_explore_adf and using learn with examples (b) or (c), below, I get cb_adf: badly formatted example, only one cost can be known but found 2 errors, respectively. In example (a) where only action ids are provided (see: https://github.com/VowpalWabbit/vowpal_wabbit/wiki/Conditional-Contextual-Bandit) the same error is returned. What's the correct way to specify the chosen action, with cost, probability along with action ids to include? When I remove action ids to include the examples run but for my use case I need to specify action id sets and it would also be helpful to specify costs.

[Example A]
shared | s_1 s_2
action | a:1 b:1 c:1
action | a:0.5 b:2 c:1
action | a:0.5 
action | c:1
slot 0,1 tag1| d:7
slot 2,3 tag2|
[Example B]
shared | s_1 s_2
action | a:1 b:1 c:1
action | a:0.5 b:2 c:1
action | a:0.5 
action | c:1
slot 1:0:0.8 0,1 tag1| d:4
slot 2:0:0.2 2,3 tag2| d:7
[Example C]
ccb shared | s_1 s_2
ccb action | a:1 b:1 c:1
ccb action | a:0.5 b:2 c:1
ccb action | a:0.5 
ccb action | c:1
ccb slot | d:4
ccb slot 1:0.8,0:0.2 0,1,3 | d:7
1

There are 1 best solutions below

0
Kwame On BEST ANSWER

The argument string passed into vw.Workspace was not setting Input Label to CCB. The following code, largely copied from vw's Python unittests, achieves what I was looking for,

ccb_workspace = vowpalwabbit.Workspace(
    quiet=False,
    ccb_explore_adf=True
)

ccb_ex = """
ccb shared |User b
ccb action |Action d
ccb action |Action e
ccb action |Action f
ccb action |Action ff
ccb action |Action fff
ccb slot 4:1:0.2 0,1,3 |
"""
ccb_workspace.learn(ccb_ex)
ccb_workspace.finish()