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

Applying our classifier


Now we put the pedal to the metal. Can we classify gender by height, weight, and BMI? We will get our data from the Kaggle competition at https://www.kaggle.com/c/pf2012-diabetes/data.

We'll be using the SyncPatient and SyncTranscript data. You can look up the details regarding these datasets in the associated data dictionary. The examples that follow are placed in the data files, in a directory named data. The files have also been renamed from SyncPatient.csv and SyncTranscript.csv to training_SyncPatient.csv and training_SyncTranscript.csv respectively.

Our first step will be to create a harness that will let us explore our data to make sure that it seems reasonable. Before we do this, we should create a new method on our Naïve Bayes class that can show us what the internal data looks like. This is the code that should be added to your Naïve Bayes class:

def _calculate_model_parameters(self):
  class_metrics = {}
  for class_label, data in self._classifications.items...