Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The shape of the input features: 4 4 2 , 1 0 ? , The shape of the output varaible: 4 4 2 , ?
"The shape of the input features:
"The shape of the output varaible:
# Load the diabetes dataset
"diabetes diabetes datasets.LoaddiabetesreturnXyTrue
"printThe shape of the input features: diabetesX shape In
"printThe shape of the output varaible: diabetes yshape
# Use only one feature
"diabetesXone diabetesX: npnewaxis,
"printdiabetesXone.shape
## Dataset split
In
"Now, we split the dataset into two parts: training set and test set.
In
training set: samples
test set: samples
"Assume that we have a hypothesis $$ theta theta x $
In
"Your tasks: In
In
IMPORTANT Do not just call the least square function from libraries, for example,
"scipy.optimize.leastsquares from scipy. Doing so will result in point. Using helping functions such as numpy.linalg.inv is okay. In
In
NOTE Notice that the loss function is meansquared error. In
pts derive the analytical expression of the gradient if the loss is defined as
theta $$
In
To check whether your computation is correct, consider using an API such as Scikit learn linearregression."
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