rtbgym.envs.simulator.base.BaseSimulator#

class rtbgym.envs.simulator.base.BaseSimulator[source]#

Base class to calculate the outcome probability and stochastically determine auction result.

Imported as: rtbgym.envs.simulator.BaseSimulator

Methods

calc_and_sample_outcome(timestep, ad_ids, ...)

Simulate bidding auction for given queries.

generate_auction(search_volume)

Sample ad and user pair for each auction.

map_idx_to_features(ad_ids, user_ids)

Map the ad and the user index into feature vectors.

abstract generate_auction(search_volume)[source]#

Sample ad and user pair for each auction.

Parameters:

search_volume (int, default=None (> 0)) – Total number of auctions to generate.

Returns:

  • ad_ids (ndarray of shape (search_volume, )) – IDs of the ads.

  • user_ids (ndarray of shape (search_volume, )) – IDs of the users.

Return type:

Tuple[ndarray]

abstract map_idx_to_features(ad_ids, user_ids)[source]#

Map the ad and the user index into feature vectors.

Parameters:
  • ad_ids (array-like of shape (search_volume, )) – IDs of the ads. (search_volume is determined in RL environment.)

  • user_ids (array-like of shape (search_volume, )) – IDs of the users. (search_volume is determined in RL environment.)

Returns:

  • ad_feature_vector (ndarray of shape (search_volume/n_samples, ad_feature_dim)) – Ad feature vector for each auction.

  • user_feature_vector (ndarray of shape (search_volume/n_samples, user_feature_dim)) – User feature vector for each auction.

Return type:

ndarray

abstract calc_and_sample_outcome(timestep, ad_ids, user_ids, bid_prices)[source]#

Simulate bidding auction for given queries.

Parameters:
  • timestep (int (> 0)) – Timestep in the RL environment.

  • ad_ids (array-like of shape (search_volume, )) – IDs of the ads.

  • user_ids (array-like of shape (search_volume, )) – IDs of the users.

  • bid_prices (array-like of shape(search_volume, )) – Bid price for each action.

Returns:

  • costs (ndarray of shape (search_volume, )) – Cost raised (i.e., second price) for each auction.

  • impressions (ndarray of shape (search_volume, )) – Binary indicator of whether impression occurred or not for each auction.

  • clicks (ndarray of shape (search_volume, )) – Binary indicator of whether click occurred or not for each auction.

  • conversions (ndarray of shape (search_volume, )) – Binary indicator of whether conversion occurred or not for each auction.

Return type:

Tuple[ndarray]

Methods