RTB Benchmarking API Documentation

rtb.bidding module

Bidding module

class rtb.bidding.BidSimulator(data, bidding_strategy)[source]

Bases: object

Simulates given bidding strategy on a dataset

Methods

__init__(data, bidding_strategy)[source]

Initialize bidding simulator.

Parameters:

data : pandas.DataFrame

Historical data containing features for model predicti n, bidding price, winning price, impressions and click indicators.

bidding_strategy : func

Function that retuns bid given prospenity to click and data row

__weakref__

list of weak references to the object (if defined)

static cpc(total_spendings, num_of_clicks)[source]

Calculate Cost Per Click

static cpm(total_spendings, num_of_impressions)[source]

Calculate Cost Per Mille - total cost advertiser pays for 1000 impressions.

static ctr(num_of_clicks, num_of_impressions)[source]

Claculate Click Through Rate - frequency of clicks on ads.

static metrics_report(run_results)[source]

Generate metric let g:pymode_lint = 0u Parameters ———- run_results : RunResults

Returns:

cpc : float

Cost Per Click.

ctr : float

Click Through Rate.

cpm : float

Cost Per Mille.

run(ctr_model=None)[source]

Run bidding simulator

Parameters:

ctr_model : sklearn-like model

Binary classifier for click prospenity

Returns:

bids : list

Bids for each entry in the data

class rtb.bidding.EffectiveCPCBiddingStrategy(data)[source]

Bases: rtb.bidding.GoalBiddingStrategy

Bid based on prospenity and CPC calculated from training data

Methods

__init__(data)[source]

Create bidding strategy

Parameters:

data : pd.DataFrame

Historical data

class rtb.bidding.FlatBiddingStrategy(bid)[source]

Bases: object

Constant bid

Methods

__call__(prospenity, row)[source]

Execute bidding strategy

Parameters:

prospenity : float

prospenity to click

row : dict-like

data row with features, pricing, impression and click data

Returns:

bid_price : float

__init__(bid)[source]

Create flat bidding strategy

Parameters:

bid : float

Bid value

__weakref__

list of weak references to the object (if defined)

class rtb.bidding.GoalBiddingStrategy(bid)[source]

Bases: object

Bid based on prospenity

Methods

__call__(prospenity, row)[source]

Execute bidding strategy

Parameters:

prospenity : float

prospenity to click

row : dict-like

data row with features, pricing, impression and click data

Returns:

bid_price : float

__init__(bid)[source]

Create bidding strategy

Parameters:

bid : float

Bid value

__weakref__

list of weak references to the object (if defined)

class rtb.bidding.RandomBiddingStrategy(bid)[source]

Bases: object

Random strategy that places random pertribations of a base bid

Methods

__call__(prospenity, row)[source]

Execute bidding strategy

Parameters:

prospenity : float

prospenity to click

row : dict-like

data row with features, pricing, impression and click data

Returns:

bid_price : float

__init__(bid)[source]

Create random bidding strategy

Parameters:

bid : float

Bid value

__weakref__

list of weak references to the object (if defined)

class rtb.bidding.RunResults(total_clicks, total_impressions, total_ad_spend)

Bases: tuple

Attributes

Methods

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, total_clicks, total_impressions, total_ad_spend)

Create new instance of RunResults(total_clicks, total_impressions, total_ad_spend)

__repr__()

Return a nicely formatted representation string

_asdict()

Return a new OrderedDict which maps field names to their values.

classmethod _make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)

Make a new RunResults object from a sequence or iterable

_replace(_self, **kwds)

Return a new RunResults object replacing specified fields with new values

total_ad_spend

Alias for field number 2

total_clicks

Alias for field number 0

total_impressions

Alias for field number 1

rtb.data_reader module

Data reading modules

class rtb.data_reader.ClicksReader(data_path)[source]

Bases: rtb.data_reader.DataReader

IPinYou RTB clicks dataset loader. Expecting data from 2 or 3 competition (with additional columns)

Methods

class rtb.data_reader.DataReader(data_path)[source]

Bases: object

Sequential data reader with ability to specify it’s own row parsing funtion.

Methods

__init__(data_path)[source]

Create data reader for IPinYou RTB dataset.

Parameters:

data_path : str

Path to data file.

row_transformers : list of func

Functions that parse row of data and return feature array. Each transformer will be applied sequentially like t3(t2(t1(row)))

post_processor : func

Post processing function that takes transformed data list as input

__metaclass__

alias of ABCMeta

__weakref__

list of weak references to the object (if defined)

_post_processor(data)[source]

Perform data post processing.

Returns:

result

Post processed data.

_row_transformer(row)[source]

Transform data row.

Returns:

row

Transformed row.

read_data(limit=None, verbose=False)[source]

Read data from files and perform row transformations and post processing

Parameters:

limit : int

Limit data loading to limit lines

verbose : bool

Print progress

class rtb.data_reader.ImpressionsReader(data_path)[source]

Bases: rtb.data_reader.DataReader

IPinYou RTB impressions Dataset loader. Expecting data from 2 or 3 competition (with additional columns)

Methods