-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added interface and module for ccb #37
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" Interface for implementation of conditional contextual bandits estimators """ | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import List | ||
|
||
class Estimator(ABC): | ||
""" Interface for implementation of conditional contextual bandits estimators """ | ||
|
||
@abstractmethod | ||
def add_example(self, p_log: List, r: List, p_pred: List, count: float) -> None: | ||
""" | ||
Args: | ||
p_log: List of probability of the logging policy | ||
r: List of reward for choosing an action in the given context | ||
p_pred: List of predicted probability of making decision | ||
count: weight | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
def get(self) -> float: | ||
""" Calculates the selected estimator | ||
|
||
Returns: | ||
The estimator value | ||
""" | ||
... | ||
|
||
class Interval(ABC): | ||
""" Interface for implementation of conditional contextual bandits estimators interval """ | ||
|
||
@abstractmethod | ||
def add_example(self, p_log: List, r: List, p_pred: List, count: float) -> None: | ||
""" | ||
Args: | ||
p_log: List of probability of the logging policy | ||
r: List of reward for choosing an action in the given context | ||
p_pred: List of predicted probability of making decision | ||
count: weight | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
def get(self, alpha: float) -> List: | ||
""" Calculates the CI | ||
Args: | ||
alpha: alpha value | ||
Returns: | ||
Returns the confidence interval as list[float] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will return [min_bound, max_bound] only for the first slot? description is a bit general here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is fine to be generic here since this is an interface. |
||
""" | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to rename
count
since it's a float?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should do it, but probably not in this PR: all other estimators still have it as count, so it is probably better to be consistent at this point.