Computing assignment - machine learning

Assignment Help Mathematics
Reference no: EM13873895

You must upload both your code (to Assignment 6 scripts/codes) and your report (to Assignment 6 computing report). The assignment is due at 11:00pm. I have set the due time in Canvas to 11:05pm and if Canvas indicates that you submitted late, you will be given 0 on the assignment. Your computing report must be exactly 1 page. There will be a penalty given if your report is longer than one page.

• Please read the Guidelines for Assignments first.

• Keep in mind that Canvas discussions are open forums.

• Acknowledge any collaborations and assistance from colleagues/TAs/instructor.

A. Computing Assignment - Machine Learning

Required submission: 1 page PDF document and scripts/codes uploaded to Canvas. The purpose of this assignment is to teach your computer to distinguish between red and blue points in 2D. This is an example of linear discriminant analysis. For further information about this topic, look at the book "Elements of Statistical Learning" by Hastie et. al which is available online for free. In class we have spent considerable time on polynomial interpolation where the interpolating polynomial exactly equals the underlying data at each of the nodes. In the case where the data is noisy or the system is overdetermined, the method of least squares is used instead. Here is a basic reference on least squares data fitting: https : //en.wikipedia.org/wiki/Least squares. You are recommended to perform the following tasks in the given order and generate the required plots or numbers as you go. The associated, partially completed Matlab script is on the computing assignment page and is called linear discriminant.m. There is also a data file called dataset.mat which contains two long matrices training set and test set. All of these files must be placed in the same folder. The idea is to train your computer using the training set and then use the test set to see how well it has learned its lesson.

Description of the Data Sets 1. Each dataset has three columns.

2. The training set has 2000 rows (i.e. 2000 red and blue points) and the test set has 200 points.

3. Let X = training set(:, [1 2]) (i.e. the first two columns of the training set) and let y = training set(:, [3]).

4. Each row of the matrix X is the location of a point in 2D where the first column is the x-coordinate and the second column is the y-coordinate.

5. Each entry in y corresponds to a row of X and is either 0 or 1. If the value is 1 then we say that point is blue and if it is 0 then we say it is red. 1

The provided script for this assignment loads both datasets and assembles the X and y matrices for you and also generates a plot of the coloured points in 2D. Run the script to see Figure 1.

Training dataset consisting of red and blue points

 

827_44.png

Figure 1: Visualizing the set of blue and red points in the training dataset. The Training of the computer 1. Now define a matrix A so that A = [ones(2000, 1), X].

2. Note that A is a 2000 × 3 matrix and y is a 2000 × 1 vector (check using the size function in MATLAB).

3. The objective is to find a 3 × 1 vector β, so that Aβ = y.

4. A unique solution is not possible since this system is overdetermined.

5. Therfore, find an approximate solution ˆβ so that RSS(ˆβ) := ky - Xˆβk 2 2 has the minimum value. To do this, modify the script to compute the vector ˆβ using the normal equations (AT A) ˆβ = AT y, and report the value of RSS( ˆβ) in your report.

6. The RSS stands for Residual Sum of Squares. It gives you an idea of how good ˆβ is at predicting a value in y given the corresponding row in A.

After you complete the previous step uncomment the section of the script titled "plot the discriminant". This generates a new plot of the dataset along with a black line given by the equation

βˆ 1 + βˆ 2x + βˆ 3y = 1/2, where ˆβ = [βˆ 1, βˆ 2, βˆ 3] T . (0.1)

Explain, just by looking at the figure, what this line is saying about the red and blue points. Include the figure and your explanation in your report.

2 The Testing of how well the computer learned

1. Use ˆβ to predict whether a certain point is red or blue from the test dataset.

2. Let z = test set(:, [3]) which is a vector of size 200 × 1 and B = [ones(200,1),test set(:,[1 2])] which is a 200 × 3 matrix similar to A. Now modify the script to compute v = Bˆβ and evaluate the vector zˆ so that zˆj = ( + 1 if vj ≥ 1/2 0 if vj < 1/2 for j = 1, · · · , 200.

3. In MATLAB, output zˆ and z side by side (do not include in your report). How is ˆz predicting the values in z?

4. Compute the error of the prediction using

Err(βˆ) = 1 200 X 200 j=1 |zj - zˆj |.

Report this value in your report. Also, generate a plot of the test dataset where the points are colored according to the prediction z along with the discriminant ˆ line defined in equation (0.1) above. 


Attachment:- dataset.mat

Attachment:- linear_discriminant.m

Reference no: EM13873895

Questions Cloud

The number of complex lies in the third quadrant : If the number of complex lies in the third quadrant, then where do the conjugation is located in?
Which equation represents this scenario : Matt scored 8 more points than Ted in the basketball game, and their scores together made up a quarter of the team's total scoring, which was 112. Which equation represents this scenario?
Write a complex number in trigonometric form : Write a complex number in trigonometric form, using the degree measure for the argument:-5sqrt(2)+5i sqrt(2)
The total services provided by the hospital : The total services provided by the hospital to all patients during the year amounted to $ 19 million at the to $19 million at the hospital established billing rates.
Computing assignment - machine learning : You must upload both your code (to Assignment 6 scripts/codes) and your report (to Assignment 6 computing report). The assignment is due at 11:00pm. I have set the due time in Canvas to 11:05pm and if Canvas indicates that you submitted late, you wil..
Preparing a preliminary income statement : It is March 2011, and you have just been hired by the Tallas Company to be its accountant.
How should the hospital report that receipt of cash : What are the components of the net position section of a governmental hospital balance sheet? A county hospital receives $ 1 million from the county, General Fund to help cover the hospital, annual operating deficit. How should the hospital report ..
How should these gains be reported in the hospital : During the year ended December 31, 2012, a not for profit hospital had both unrealized and realized gains on investments made with its unrestricted net assets. How should these gains be reported in the hospital, statement of operations for the yea..
Which of the following is the most likely description : Which of the following is the most likely description of the resources reported by Kappa Hospital on its balance sheet as assets limited as to use?

Reviews

Write a Review

Mathematics Questions & Answers

  List price and discount

A car dealer, at a year-end clearance sale, reduces the list price of last year's models by 15%. If a certain model has a discounted price of $8000, what was the list price? How much can be saved by purchasing last year's model?

  Find the number of revolutions made by a wheel with a radius

find the number of revolutions made by a wheel with a radius of 5ft that traveled 633ft use 3.14 for pie round answer to nearest tenth of revolution.

  Find the dimensions of the court

the perimeter of a basketball court is 292 ft. The length is 40ft longer than the width. find the dimensions of the court.

  Total amount of tobacco produced in the

Open the file US Tobacco, which contains data on the total amount of tobacco produced in the US. a. Make a scatter graph of the data with trendline. Copy and paste your graph here.

  Calculation of annual demand

A drug company believes that the annual demand for a drug will follow a normal random variable with a mean of 900 pounds and a standard deviation of 60 pounds.

  How should this be done in order to minimize the sum

A 380 in. piece of wire is divided into two pieces and each piece is bent into a square. How should this be done in order to minimize the sum of the areas of the two squares?

  Calculate the present value of annuity

Calculate the present value of this annuity at an annual effective interest rate of 8%.

  Application of calculus-optimization problem

Application of Calculus-Optimization problem - Show that the shortage length of such a rope occurs when θ 1  = θ 2

  Write the generator matrix

Write the generator matrix. Show by example that your code will detect 1 error, 2 errors, and 3 errors. Give an example where 4 errors are made in transmitting a message word, but your code does not detect any errors.

  Solve the inequality graphically and graph the solution

where t is the time, in seconds, after the ball is thrown. Find the value(s) of t for which the height of the ball is 48 feet.  Find the exact solution(s).

  How many times is the velocity of the object equal to 0

The position of an object attached to a spring is given by the formula: y(t)=(1/6)cos(5t)-(1/4)sin(5t), where t is time in seconds. In the first 4 seconds, how many times is the velocity of the object equal to 0?

  With what speed does that ball hit the ground

A ball is thrown straight downward with initial speed of 40 ft/s from the top of a 555 ft. building. How long does it take to read the ground and with what speed does that ball hit the ground?

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