Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 2Gradient DescentDescription:In mathematics, gradient descent is a first-order iterative optimization algorithm for finding a local minimum of a differentiable function. The idea is to

Assignment 2Gradient DescentDescription:In mathematics, gradient descent is a first-order iterative optimization algorithm for finding a local minimum of a differentiable function. The idea is to take repeated steps in the opposite direction of the gradient (or approximate gradient) of the function at the current point because this is the direction of the steepest descent. Conversely, stepping in the direction of the gradient will lead to a local maximum of that function; the procedure is then known as gradient ascent. Gradient descentis commonly used inmachine learningandneural networksto minimize a cost/loss function. For this assignment, you are going to use graduate descent to optimize a linear regression model on the scikit-learnsdiabetesdataset.Purpose:Get familiar with the gradient descent algorithm.Make use of feature selection methods.Develop a linear regression modelfor a given task.Directions:For this assignment, you need to build a linear regression modelfrom scratchand optimizethe linear regression model using the gradient descentalgorithm. Below is a detailed instruction onwhat you may need to do.Dataset PreparationoYou need to load the dataset usingsklearn.datasets.load_diabetes.More information about the function can be found at: https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_diabetes.html#sklearn.datasets.load_diabetesoAfter loading the dataset, randomly shuffle the dataset to split the dataset to train/dev/test sets.Use the 70% of data for the train set, 15% for the dev set, and 15% for the test setMake sure that the labels and featuresare still matching after shuffling the data.You may want to use the random shuffle function provided by NumPy.Linear Regression DevelopmentoImplement a single-variable linear regression model from scratch.oUsea gradient descent algorithm to solve the optimal parameters for the linear regression model.The gradient descentalgorithm must beimplementedfrom scratch.No high-level libraries can be used. Using online referenceand tutorials are allowed.oThe dataset contains 10 features; however,for a single-variablelinear regression model, you may only use one feature. Thus, to build the linear regression model, you need to decide which feature to you. There are three approaches you may use:You may train 10 single-variablelinear regression models, one model for each feature, and select the one with the best performance on the dev set.You may run a feature selection algorithm to select a feature. There are plenty of feature selection algorithms available. Feel free to search on the internet and use a method atyour choice.You may use PCA for dimension reduction to reduce the number of features to 1. There are many python libraries that provide PCA algorithms you may use. In fact, scikit-learnalso has a PCA function. Feel free to search on the internet and choose one atyour choice.Test the ModeloTest the model using the test set.SubmissionYou need to submit a written report for this assignment. For this report, you need to: oExplain what you have doneoReport the best performance on the test set (in terms of MSE)oInclude your code as an appendixYou could save your Colab code as a PDF file and attach it to your report, or you could copy and paste your code into the report.If you want to copy/paste your code, make sure to maintain the appropriate indentation and make the code readable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago