-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogression_policy_quickstart.py
More file actions
50 lines (41 loc) · 1.35 KB
/
progression_policy_quickstart.py
File metadata and controls
50 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Rank learning items by progression reward, not only correctness.
Run with:
PYTHONPATH=src python examples/progression_policy_quickstart.py
"""
from __future__ import annotations
from orchid_ranker.learning_policy import ProgressionValuePolicy
class DemoTracer:
def predict_many(self, user_id, item_ids):
del user_id
values = {
"easy-review": 0.96,
"right-stretch": 0.72,
"too-hard": 0.30,
}
return {item_id: values[item_id] for item_id in item_ids}
def observe(self, user_id, item_id, correct):
del user_id, item_id, correct
return None
def main() -> None:
policy = ProgressionValuePolicy(
DemoTracer(),
difficulty_by_item={
"easy-review": 0.15,
"right-stretch": 0.65,
"too-hard": 0.90,
},
concept_by_item={
"easy-review": "fractions",
"right-stretch": "fractions",
"too-hard": "ratios",
},
)
ranked = policy.rank("learner-1", ["easy-review", "right-stretch", "too-hard"], top_k=3)
for rec in ranked:
print(
f"{rec.item_id}: score={rec.score:.3f} "
f"p_correct={rec.p_correct:.2f} difficulty={rec.difficulty:.2f}"
)
print("Progression policy quickstart complete")
if __name__ == "__main__":
main()