Lab01 Linear Regression
Lab01 Linear Regression
Introduction
• Linear regression with one variable — Finding the best-fitting straight line through
points of a data set. (link)
Objectives
Tools/Software Requirement
Task Description
Now execute the following code snippet to create some sample data points, and visualization.
# imports
import numpy as np
import matplotlib.pyplot as plt
# generate random data-set
np.random.seed(0)
x = np.random.rand(100, 1)
y = 2 + 3 * x + np.random.rand(100, 1)
# plot
plt.scatter(x,y,s=10)
plt.xlabel('x')
m
RMSE=
1
∑√
m i=1
(hθ ( x (i) )− y(i) )
2
Compute the RMSE, and present the error rate. Also, print the values of the learnt parameters θ0
and θ1.
Finally, plot the linear hypothesis along with the training data, like this:
• Students are required to upload the solutions in Jupyter Notebook format (.ipynb) on
LMS.
• The file name must contain your name and CMS ID in the following format.
<Lab01_your CMS ID_your name.ipynb>