rtbgym.envs.simulator.function.ConversionRate#
- class rtbgym.envs.simulator.function.ConversionRate(n_ads, n_users, ad_feature_dim, user_feature_dim, step_per_episode, random_state=None)[source]#
Class to calculate ground-truth CVR (i.e., conversion per click).
Imported as:
rtbgym.envs.simulator.ConversionRateNote
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) CVR.
- In short, CVR is calculated as follows.
CVR = (context @ coef) * time_coef, where @ denotes inner product.
Tip
Use
BaseClickAndConversionRateto define a custom ConversionRate.- 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 CVR trend cycle.
random_state (int, default=None (>= 0)) – Random state.
- Attributes:
- random_state
Methods
calc_prob(ad_ids, user_ids, ...)Calculate CVR (i.e., conversion per click) using context vectors.
sample_outcome(ad_ids, user_ids, ...)Stochastically determine whether conversion occurs in click=True case.
- calc_prob(ad_ids, user_ids, ad_feature_vector, user_feature_vector, timestep)[source]#
Calculate CVR (i.e., conversion per click) using context vectors.
Note
- CVR is calculated using both context coefficient (coef) and time coefficient (time_coef).
CVR = (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:
cvrs – Ground-truth CVR (i.e., conversion per click) 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 conversion occurs in click=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:
conversions – Whether conversion occurs when click=True.
- Return type:
ndarray of shape (search_volume/n_samples, )
Methods