Book Image

Test Driven Machine Learning

Book Image

Test Driven Machine Learning

Overview of this book

Table of Contents (16 chapters)
Test-Driven Machine Learning
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Perceptively Testing a Perceptron
Index

Starting at the highest level


There's a lot going on here. We can simplify it by just thinking about how to solve our high-level problem, and save the other solutions for later. Besides, we've already written the regression and classification algorithms. The worst case is that we may have to refactor them to work with the newer code that will use them. To begin with, we want to build a classifier that will identify the persuadables and sleeping dogs. Using this, we can optimize how we spend ad money to generate new business, and annoy as few of our customers as possible.

Here is one solid high-level test:

import nose.tools as nt

def given_a_sleeping_dog_test():
    classification_model = SimplisticClasses.PersuadableAndSleepingDogClassifier()
    regression_model = SimplisticClasses.AllCasesHaveSameProfitRegressionModel()
    customer = ('60602', 'male')
    ad_name = assign_ad_for(customer, classification_model, regression_model)
    nt.assert_equal(ad_name, 'control', "Should let sleeping...