API References
This function performs the multi-armed bandit (mab) problem by Thompson Sampling, UCB-Upper confidence Bound, and randomized sampling
import thompson as mab
- df = mab.example_data()
out = mab.thompson(df, <optional>) out = mab.UCB(df, <optional>) out = mab.UCB_random(df, <optional>) fig = mab.plot(out, <optional>)
df : [pd.DataFrame], Contains samples[rows] x features[columns]
Dictionary containing keys with results and others to make the plot.
SEE ALSO
- thompson.thompson.UCB(df, verbose=3)
- Parameters
df ([pd.DataFrame], Contains samples[rows] x features[columns]) –
verbose ([INT] Print messages to screen.) – 0: NONE 1: ERROR 2: WARNING 3: INFO (default) 4: DEBUG 5: TRACE
- Return type
Dictionary containing keys with results and others to make the plot.
- thompson.thompson.UCB_random(df, verbose=3)
- Parameters
df ([pd.DataFrame], Contains samples[rows] x features[columns]) –
verbose ([INT] Print messages to screen.) – 0: NONE 1: ERROR 2: WARNING 3: INFO (default) 4: DEBUG 5: TRACE
- Return type
Dictionary containing keys with results and others to make the plot.
- thompson.thompson.import_example(data='ads', url=None, sep=',')
Import example dataset from github source.
Import one of the few datasets from github source or specify your own download url link.
- Parameters
data (str) – Name of datasets: ‘ads’
url (str) – url link to to dataset.
verbose (int, optional) – Print progress to screen. The default is 3. 0: None, 1: ERROR, 2: WARN, 3: INFO (default), 4: DEBUG, 5: TRACE
- Returns
Dataset containing mixed features.
- Return type
pd.DataFrame()
- thompson.thompson.makefig_UCB(out, width=15, height=10)
- thompson.thompson.makefig_UCB_random(out, width=15, height=10)
- thompson.thompson.makefig_thompson(out, width=15, height=10)
- thompson.thompson.plot(out, width=15, height=10)
- Parameters
out ([dict], Output from thompson, ucb or usb_random.) –
width ([Int], Width of the figure. default is 30.) –
height ([Int], Width of the figure. default is 10.) –
- Return type
None.
- thompson.thompson.thompson(df, verbose=3)
- Parameters
df ([pd.DataFrame], Contains samples[rows] x features[columns]) –
verbose ([INT] Print messages to screen.) – 0: NONE 1: ERROR 2: WARNING 3: INFO (default) 4: DEBUG 5: TRACE
- Return type
Dictionary containing keys with results and others to make the plot.
- thompson.thompson.wget(url, writepath)