Skip to Main Content
Test-Driven Machine Learning
book

Test-Driven Machine Learning

by Justin Bozonier
November 2015
Intermediate to advanced content levelIntermediate to advanced
190 pages
4h 11m
English
Packt Publishing
Content preview from Test-Driven Machine Learning

A bootstrapping bandit

Now, let's move to implement a simple approach that will use what we've been exploring. A bootstrapping bandit requires no math knowledge at all. It just requires us to sample from the data that we've encountered. Due to this simplicity, we can start from here. Let's start with the simplest test, as follows:

import rpm_bandit

def given_a_single_treatment_test():
  bandit = rpmbandit.RPMBandit(['A'])
  chosen_treatment = bandit.choose_treatment()
  assert chosen_treatment == 'A', 'Should choose the only available option.'

Okay, it's pretty standard at this point. The code that I've written to make this pass is also pretty standard now:

class RPMBandit: def __init__(self, treatments): self._treatments = treatments def choose_treatment(self): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning in Action

Machine Learning in Action

Peter Harrington

Publisher Resources

ISBN: 9781784399085Supplemental Content