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

Starting from scratch

To begin with, let's start building an extremely simplistic bandit algorithm. The actual bandit class will have two methods: choose_treatment and log_payout. The first method will recommend the best treatment to choose, and log_payout will be used to report back on how effective the recommended treatment was.

The simplest way to approach this algorithm from a test-driven perspective is to start with a single treatment so that the algorithm only has one thing to recommend. The code for this test looks like the following:

from nose.tools import assert_equal import simple_bandit def given_a_single_treatment_test(): bandit = simple_bandit.SimpleBandit(['A']) chosen_treatment = bandit.choose_treatment() assert_equal(chosen_treatment, ...
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