Vowpal Wabbit
Public Member Functions | Public Attributes | Private Attributes | List of all members
CCBOutcomeList< audit > Class Template Reference

#include <parse_example_json.h>

Inheritance diagram for CCBOutcomeList< audit >:
BaseState< audit >

Public Member Functions

 CCBOutcomeList ()
 
BaseState< audit > * StartArray (Context< audit > &ctx) override
 
BaseState< audit > * StartObject (Context< audit > &ctx) override
 
BaseState< audit > * EndArray (Context< audit > &ctx, rapidjson::SizeType) override
 
- Public Member Functions inherited from BaseState< audit >
 BaseState (const char *pname)
 
virtual BaseState< audit > * Null (Context< audit > &ctx)
 
virtual BaseState< audit > * Bool (Context< audit > &ctx, bool b)
 
virtual BaseState< audit > * Float (Context< audit > &ctx, float v)
 
virtual BaseState< audit > * Uint (Context< audit > &ctx, unsigned v)
 
virtual BaseState< audit > * String (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * Key (Context< audit > &ctx, const char *str, rapidjson::SizeType len, bool)
 
virtual BaseState< audit > * EndObject (Context< audit > &ctx, rapidjson::SizeType)
 

Public Attributes

DecisionServiceInteractioninteractions
 
- Public Attributes inherited from BaseState< audit >
const char * name
 

Private Attributes

int slot_object_index = 0
 
std::vector< uint32_t > actions
 
std::vector< float > probs
 
float cost
 
BaseState< audit > * old_root
 

Detailed Description

template<bool audit>
class CCBOutcomeList< audit >

Definition at line 1004 of file parse_example_json.h.

Constructor & Destructor Documentation

◆ CCBOutcomeList()

template<bool audit>
CCBOutcomeList< audit >::CCBOutcomeList ( )
inline

Definition at line 1017 of file parse_example_json.h.

1017 : BaseState<audit>("CCBOutcomeList") {}

Member Function Documentation

◆ EndArray()

template<bool audit>
BaseState<audit>* CCBOutcomeList< audit >::EndArray ( Context< audit > &  ctx,
rapidjson::SizeType   
)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 1057 of file parse_example_json.h.

References DecisionServiceInteraction::actions, Context< audit >::decision_service_state, Context< audit >::examples, DecisionServiceInteraction::probabilities, Context< audit >::root_state, and CCB::slot.

1058  {
1059  // DSJson requires the interaction object to be filled. After reading all slot outcomes fill out the top actions.
1060  for (auto ex : *ctx.examples)
1061  {
1062  if (ex->l.conditional_contextual_bandit.type == CCB::example_type::slot)
1063  {
1064  if (ex->l.conditional_contextual_bandit.outcome)
1065  {
1066  interactions->actions.push_back(ex->l.conditional_contextual_bandit.outcome->probabilities[0].action);
1067  interactions->probabilities.push_back(ex->l.conditional_contextual_bandit.outcome->probabilities[0].score);
1068  }
1069  }
1070  }
1071 
1072  ctx.root_state = old_root;
1073  return &ctx.decision_service_state;
1074  }
BaseState< audit > * root_state
DecisionServiceInteraction * interactions
BaseState< audit > * old_root
v_array< example * > * examples
DecisionServiceState< audit > decision_service_state
std::vector< float > probabilities
std::vector< unsigned > actions

◆ StartArray()

template<bool audit>
BaseState<audit>* CCBOutcomeList< audit >::StartArray ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 1019 of file parse_example_json.h.

References Context< audit >::examples, Context< audit >::root_state, CCB::slot, and THROW.

1020  {
1021  slot_object_index = 0;
1022 
1023  // Find start index of slot objects by iterating until we find the first slot example.
1024  for (auto ex : *ctx.examples)
1025  {
1026  if (ex->l.conditional_contextual_bandit.type != CCB::example_type::slot)
1027  {
1029  }
1030  }
1031  old_root = ctx.root_state;
1032  ctx.root_state = this;
1033 
1034  if (slot_object_index == 0)
1035  {
1036  THROW("Badly formed ccb example. Shared example is required.")
1037  }
1038 
1039  return this;
1040  }
BaseState< audit > * root_state
BaseState< audit > * old_root
v_array< example * > * examples
#define THROW(args)
Definition: vw_exception.h:181

◆ StartObject()

template<bool audit>
BaseState<audit>* CCBOutcomeList< audit >::StartObject ( Context< audit > &  ctx)
inlineoverridevirtual

Reimplemented from BaseState< audit >.

Definition at line 1042 of file parse_example_json.h.

References Context< audit >::default_state, Context< audit >::ex, Context< audit >::examples, Context< audit >::label_index_state, and Context< audit >::PushNamespace().

1043  {
1044  // Set current example so that default state correctly sets the label.
1045  ctx.ex = (*ctx.examples)[slot_object_index];
1046  // The end object logic assumes shared example so we need to take one here.
1047  ctx.label_index_state.index = slot_object_index - 1;
1048 
1050 
1051  // Push a namespace so that default state can get back here when it reaches the end of the object.
1052  ctx.PushNamespace(" ", this);
1053 
1054  return &ctx.default_state;
1055  }
LabelIndexState< audit > label_index_state
example * ex
v_array< example * > * examples
DefaultState< audit > default_state
void PushNamespace(const char *ns, BaseState< audit > *return_state)

Member Data Documentation

◆ actions

template<bool audit>
std::vector<uint32_t> CCBOutcomeList< audit >::actions
private

Definition at line 1008 of file parse_example_json.h.

◆ cost

template<bool audit>
float CCBOutcomeList< audit >::cost
private

Definition at line 1010 of file parse_example_json.h.

◆ interactions

template<bool audit>
DecisionServiceInteraction* CCBOutcomeList< audit >::interactions

Definition at line 1015 of file parse_example_json.h.

◆ old_root

template<bool audit>
BaseState<audit>* CCBOutcomeList< audit >::old_root
private

Definition at line 1012 of file parse_example_json.h.

◆ probs

template<bool audit>
std::vector<float> CCBOutcomeList< audit >::probs
private

Definition at line 1009 of file parse_example_json.h.

◆ slot_object_index

template<bool audit>
int CCBOutcomeList< audit >::slot_object_index = 0
private

Definition at line 1006 of file parse_example_json.h.


The documentation for this class was generated from the following file: