rtbgym.envs.simulator.function.ClickThroughRate#
- class rtbgym.envs.simulator.function.ClickThroughRate(n_ads, n_users, ad_feature_dim, user_feature_dim, step_per_episode, random_state=None)[source]#
Class to calculate ground-truth CTR (i.e., click per impression).
Imported as:
rtbgym.envs.simulator.ClickThroughRateNote
We define two coefficient, context coefficient (coef) and time coefficient (time_coef). First, the value is calculated linearly from context vector and coef by inner product. Then, we multiply the value with time_coef and gain (ground-truth) CTR.
- In short, CTR is calculated as follows.
CTR = (context @ coef) * time_coef, where @ denotes inner product.
Tip
Use
BaseClickAndConversionRateto define a custom ClickThroughRate.- Parameters:
n_ads (int (> 0)) – Number of ads. (This is for API consistency)
n_users (int (> 0)) – Number of users. (This is for API consistency)
ad_feature_dim (int (> 0)) – Dimension of the ad feature vectors.
user_feature_dim (int (> 0)) – Dimension of the user feature vectors.
step_per_episode (int (> 0)) – Length of the CTR trend cycle.
random_state (int, default=None (>= 0)) – Random state.
- Attributes:
- random_state
Methods
calc_prob(ad_ids, user_ids, ...)Calculate CTR (i.e., click per impression).
sample_outcome(ad_ids, user_ids, ...)Stochastically determine whether click occurs in impression=True case.
- calc_prob(ad_ids, user_ids, ad_feature_vector, user_feature_vector, timestep)[source]#
Calculate CTR (i.e., click per impression).
Note
- CTR is calculated using both context coefficient (coef) and time coefficient (time_coef).
CTR = (context @ coef) * time_coef, where @ denotes inner product.
- Parameters:
ad_ids (array-like of shape (search_volume/n_samples, )) – Ad ids used for each auction. (not used, but for API consistency)
user_ids (array-like of shape (search_volume/n_samples, )) – User ids used for each auction. (not used, but for API consistency)
ad_feature_vector (array-like of shape (search_volume/n_samples, ad_feature_dim)) – Ad feature vector for each auction.
user_feature_vector (array-like of shape (search_volume/n_samples, user_feature_dim)) – User feature vector for each auction.
timestep ({int, array-like of shape (n_samples, )}) – Timestep in the RL environment.
- Returns:
ctrs – Ground-truth CTR (i.e., click per impression) for each auction.
- Return type:
ndarray of shape (search_volume/n_samples, )
- sample_outcome(ad_ids, user_ids, ad_feature_vector, user_feature_vector, timestep)[source]#
Stochastically determine whether click occurs in impression=True case.
- Parameters:
ad_ids (array-like of shape (search_volume/n_samples, )) – Ad ids used for each auction. (not used, but for API consistency)
user_ids (array-like of shape (search_volume/n_samples, )) – User ids used for each auction. (not used, but for API consistency)
ad_feature_vector (array-like of shape (search_volume/n_samples, ad_feature_dim)) – Ad feature vector for each auction.
user_feature_vector (array-like of shape (search_volume/n_samples, user_feature_dim)) – User feature vector for each auction.
timestep ({int, array-like of shape (n_samples, )}) – Timestep in the RL environment.
- Returns:
clicks – Whether click occurs when impression=True.
- Return type:
array-like of shape (search_volume/n_samples, )
Methods