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

Generating data


Now that we've gone through the process of searching for the right model, let's talk about what the model's true parameters were and how they line up with the parameters our regression generated.

This is the code that was used to generate the data:

import numpy as np

variable_a = np.random.uniform(-100, 100, 30)
variable_b = np.random.uniform(-5, 5, 30)
variable_c = np.random.uniform(0, 37, 30)
variable_d = np.random.uniform(121, 213, 30)
variable_e = np.random.uniform(-1000, 100, 30)
variable_f = np.random.uniform(-100, 100, 30)
variable_g = np.random.uniform(-25, 75, 30)
variable_h = np.random.uniform(1, 27, 30)

independent_variables = zip(variable_a, variable_b, variable_c, variable_d, variable_e, variable_f, variable_g, variable_h)
dependent_variables = [3*x[0] - 2*x[1] - .25*x[4] + 5.75*x[1]*x[2] + np.random.normal(0, 50) for x in  independent_variables]

full_dataset = [x[0] + (x[1],) for x in zip(independent_variables, dependent_variables)]

import csv
with open('generated_data...