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

Beginning the development

We start with the standard simplistic tests that will serve to get the basic wiring up for our classifier. First, the test:

import NaiveBayes

def no_observations_test():
  classifier = NaiveBayes.Classifier()
  classification = classifier.classify(observation=23.2)
  assert classification is None, "Should not classify observations without training examples."

And then the code:

class Classifier:
  def classify(self, observation):
    pass

As the next step to approach a solution, let's try the case where we've only observed the data from a single class:

def given_an_observation_for_a_single_class_test(): classifier = NaiveBayes.Classifier() classifier.train(classification='a class', observation=0) classification = classifier.classify(observation=23.2) ...
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