Examine optimization techniques for classification

Assignment Help Python Programming
Reference no: EM133337507

Question

This question will examine optimization techniques for classification with logistic regression. Download the code file consisting of the assignment2 code and data CSV file. In the data file, the first, second, and third columns are called the inputs dataset and contain the input features. The fourth column is called the outputs dataset and contains the class number for each input sample.

Open the script assignment2.py the lr directory. This code performs gradient descent to optimize parameters (w) which minimizes the error. The parameters are initialized in the beginning. In the code, the data is loaded, and inputs and output arrays are extracted. Afterward, for 500 iterations, the predicted outputs are computed using the following formula for each iteration.

Z = WT. X
Y^= Sigmoid (Z)

Now, in order to optimize the parameters and train the model, complete the missing parts in the code under the comment blocks.

1- Compute the error: In the code, the error value is initialized to zero (e = 0). Compute the error values using the Logistic Regression Cost Function as follows and replace it with e:

Error = -1/m ∑i=1m [Yi log(Y^i)] + (1-Yi)log(1-Y^i))

Then append the computed error value to the error_all vector in order to save your error in all iterations.

2- Plot the error values during the iterations and explain why this plot is oscillating.

3- Create a Python script named assignment2_q2_3.py for the following.

Modify assignment2.py to run gradient descent with the learning rates n = 0: 5,0: 3, 0:1, 0: 05, 0:01.
Include in your report a single plot comparing error values versus iterations for these different learning rates.
Compare these results. What are the relative advantages of the different rates?

4- Create a Python script named assignment2_q2_4.py for the following.
Modify this code to do stochastic gradient descent. Use the parameters n = 0: 5, 0: 3, 0: 1,0: 05, 0: 01.

Attachment:- data.rar

Reference no: EM133337507

Questions Cloud

Relying on virtual teams for product development : For a variety of reasons, organizations are relying on virtual teams for product development.
What the essential components of symmetric cipher : What the essential components of a symmetric cipher? Why are the components considered to be essential?
Advantages of component-based design modeling approach : What are the advantages of the component-based design modeling approach, and how you would approach it in the design phase.
Industry certification benefit : How could this industry certification benefit you and help you reach your career goals? How do you think employers view certifications such as this one?
Examine optimization techniques for classification : Examine optimization techniques for classification with logistic regression. Download the code file consisting of the assignment2 code and data CSV file
Use wiped and inspected media : Why would it be important to use wiped and inspected media during an investigation? What utilities would be recommended for wiping a drive
Discuss proliferation of electronically stored : Discuss the proliferation of electronically stored and transmitted content in recent years. Are there any strategies you oppose, and if so, explain why?
Why would the alerting function be important : What value would aggregations and calculations provide that cannot be provided by the raw or processed logs themselves?
Why domain name system security extensions : What is the importance DNSSEC serves to security? Looking for a valid argument as to why Domain Name System Security Extensions, DNSSEC for short

Reviews

len3337507

2/13/2023 9:29:09 PM

Include in your report a new plot comparing error values versus iterations using stochastic gradient descent. Is stochastic gradient descent faster than gradient descent? Explain using your plots. Note: ONLY ANSWER QUESTION NO. 2 (60%) Submit the figures/explanations requested for question 2. 2. A .zip file of all your code, called code.zip.

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd