Preparing the dataset

Next, we will generate some random data points with 500 rows and 2 columns (x and y) and use them for training:

data = np.random.randn(500, 2)

As you can see, our data has two columns:

print data[0]

array([-0.08575873, 0.45157591])

The first column indicates the value:

print data[0,0]

-0.08575873243708057

The second column indicates the value:

print data[0,1]

0.4515759149158441

We know that the equation of a simple linear regression is expressed as follows:

Thus, we have two parameters, and . We store both of these parameters in an array called theta. First, we initialize theta with zeros, as follows:

theta = np.zeros(2)

The theta[0] function represents the value of , while the theta[1] function represents the value of :

print theta

array([0., 0.])
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset