banditml/offline-policy-evaluation
banditml/offline-policy-evaluation has 221 GitHub stars and 25 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-24 05:23 UTC. Last push 2023-02-11.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
Implementations and examples of common offline policy evaluation methods in Python.
개발 도구README.md
OriginalOffline policy evaluation
Implementations and examples of common offline policy evaluation methods in Python. For more information on offline policy evaluation see this tutorial.
Installation
pip install offline-evaluation
Usage
from ope.methods import doubly_robust
Get some historical logs generated by a previous policy:
df = pd.DataFrame([
{"context": {"p_fraud": 0.08}, "action": "blocked", "action_prob": 0.90, "reward": 0},
{"context": {"p_fraud": 0.03}, "action": "allowed", "action_prob": 0.90, "reward": 20},
{"context": {"p_fraud": 0.02}, "action": "allowed", "action_prob": 0.90, "reward": 10},
{"context": {"p_fraud": 0.01}, "action": "allowed", "action_prob": 0.90, "reward": 20},
{"context": {"p_fraud": 0.09}, "action": "allowed", "action_prob": 0.10, "reward": -20},
{"context": {"p_fraud": 0.40}, "action": "allowed", "action_prob": 0.10, "reward": -10},
])
Define a function that computes P(action | context) under the new policy:
def action_probabilities(context):
epsilon = 0.10
if context["p_fraud"] > 0.10:
return {"allowed": epsilon, "blocked": 1 - epsilon}
return {"allowed": 1 - epsilon, "blocked": epsilon}
Conduct the evaluation:
doubly_robust.evaluate(df, action_probabilities)
> {'expected_reward_logging_policy': 3.33, 'expected_reward_new_policy': -28.47}
This means the new policy is significantly worse than the logging policy. Instead of A/B testing this new policy online, it would be better to test some other policies offline first.
See examples for more detailed tutorials.
Supported methods
- Inverse propensity scoring
- Direct method
- Doubly robust (paper)
관련 프로젝트 살펴보기
불러오는 중…