blob: 75ffc84f2c3b6fc408d0a9f03e8f087609a9cfcd (
plain)
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
|
import numpy as np
from .tensor_store import UserState
def score_with_user(
base_score: float,
user_state: UserState,
v_m: np.ndarray, # [k]
beta_long: float,
beta_short: float,
) -> float:
"""
Personalized scoring:
s = base_score + (beta_long * z_long + beta_short * z_short) . v_m
Day2: beta_long = beta_short = 0 -> s == base_score
"""
z_eff = beta_long * user_state.z_long + beta_short * user_state.z_short
# dot product
# Ensure shapes match
if v_m.shape != z_eff.shape:
# Just in case of dimension mismatch
return float(base_score)
term = np.dot(z_eff, v_m)
return float(base_score + term)
|