Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose we are given a training dataset consisting of feature vectors x 1 , dots, x N i n R d and corresponding target values
Suppose we are given a training dataset consisting of feature vectors
dots, and corresponding target values dots,inR. The
vector can be written in more detail as
We would like to find a vector
such that
~~cdots for dots,
a For any given vector the mean squared error can be written
as
What is the matrix and what is the vector Explain why the
above formula computes the mean squared error.
b Let's compute using the chain rule. The function can be
expressed as
for certain functions and What are and Write down for
mulas for and What is What is gradL
c In single variable calculus, we learn to minimize functions by setting
the derivative equal to In multivariable calculus, we can attempt
to minimize by setting gradL and solving for Write down
the equation gradL and simplify. Do we know of a technique
that can be used to solve for
d Write Python code that uses the above approach to implement linear
regression from scratch using the California housing dataset. You can
use scikitlearn to load the dataset and split the dataset into training
and validation datasets. However, you should not use scikitlearn
to train your model. It's ok to use numpy to help with vector and
matrix operations.
e An alternative strategy to find a vector which minimizes
is to use the gradient descent algorithm. Write Python code
that trains a linear regression model from scratch using gradient de
scent. You can use scikitlearn to load the California housing dataset
and to split it into training and validation datasets, but you should
not use scikitlearn to train your model. Make a plot called a "con
vergence plot" that shows the value of after each iteration of
gradient descent. Try out different learning rates. Which learning
rate leads to the fastest convergence? How many iterations of gradi
ent descent do you need in order for the gradient descent iteration to
converge?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started