Question

Let Xp and X be the positive and negative training data, respectively, as Xp = (1 4 3 6 4 0 1 1 6 3 8 6 6 2 2 3) and X = (10 8 0 1 0 1 8 10 7 8 1 1). 1. (5 points) Compute the class-specific means of data matrices Xp and X. Your code needs to return the mean as a column vector. 2. (5 points) Compute the class-specific covariance matrices for the data matrices Xp and X. 3. (5 points) Compute the between-class scattering matrix S. 4. (5 points) Compute the within-class scattering matrix Sw. 5. (10 points) Write your own code to compute the LDA projection by solving the generalized eigenvalue decomposition problem. [use function numpy.linalg.eig] 6. (10 points) Write your own code to compute the LDA projection for the data given in the problem setting. You should see that the second eigenvalue is zero. 7. (20 points) Collect all previous steps, write a function with the name mybLDA_train to perform binary LDA, which takes inputs of two data matrices X and X assuming column data, and return the optimal LDA projection direction as a unit vector. 8. (20 points) Write a function with the name mybLDA_classify which takes a data matrix X and a projection direction v, returns a row vector r that has size as the number of rows in X, and r_i = +1 if the i-th column of X is from the class as in X, and r_i = -1 if the i-th column in X is from the class as in X. 9. (20 points) Run your function, mybLDA_train, on the data given in the problem setting. Use your function mybLDA_classify to classify the following data set X = (1.3 2.4 6.7 2.2 3.4 3.2 8.1 7.6 2.1 1.1 0.5 7.4) and return the classification results. CSI436/536 Homework 4 Machine Learning

          Let Xp and X be the positive and negative training data, respectively, as
Xp = (1 4 3 6 4 0 1 1
6 3 8 6 6 2 2 3) and X = (10 8 0 1 0 1
8 10 7 8 1 1).

1. (5 points) Compute the class-specific means of data matrices Xp and X. Your code needs to return the mean as a column vector.
2. (5 points) Compute the class-specific covariance matrices for the data matrices Xp and X.
3. (5 points) Compute the between-class scattering matrix S.
4. (5 points) Compute the within-class scattering matrix Sw.
5. (10 points) Write your own code to compute the LDA projection by solving the generalized eigenvalue decomposition problem. [use function numpy.linalg.eig]
6. (10 points) Write your own code to compute the LDA projection for the data given in the problem setting. You should see that the second eigenvalue is zero.
7. (20 points) Collect all previous steps, write a function with the name mybLDA_train to perform binary LDA, which takes inputs of two data matrices X and X assuming column data, and return the optimal LDA projection direction as a unit vector.
8. (20 points) Write a function with the name mybLDA_classify which takes a data matrix X and a projection direction v, returns a row vector r that has size as the number of rows in X, and r_i = +1 if the i-th column of X is from the class as in X, and r_i = -1 if the i-th column in X is from the class as in X.
9. (20 points) Run your function, mybLDA_train, on the data given in the problem setting. Use your function mybLDA_classify to classify the following data set X = (1.3 2.4 6.7 2.2 3.4 3.2 8.1 7.6 2.1 1.1 0.5 7.4) and return the classification results.

CSI436/536
Homework 4
Machine Learning
        
Show more…
let xp and x be the positive and negative training data respectively as 4 2 2 xp1 4 3 6 4 0 1 1 6 3 8 6 6 2 2 3 and x10 8 0 1 0 1 8 10 7 8 1 1 15 points compute the class specific means of d 04262

Added by Ruth S.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Let Xp and X be the positive and negative training data, respectively, as Xp = (1 4 3 6 4 0 1 1 6 3 8 6 6 2 2 3) and X = (10 8 0 1 0 1 8 10 7 8 1 1). 1. (5 points) Compute the class-specific means of data matrices Xp and X. Your code needs to return the mean as a column vector. 2. (5 points) Compute the class-specific covariance matrices for the data matrices Xp and X. 3. (5 points) Compute the between-class scattering matrix S. 4. (5 points) Compute the within-class scattering matrix Sw. 5. (10 points) Write your own code to compute the LDA projection by solving the generalized eigenvalue decomposition problem. [use function numpy.linalg.eig] 6. (10 points) Write your own code to compute the LDA projection for the data given in the problem setting. You should see that the second eigenvalue is zero. 7. (20 points) Collect all previous steps, write a function with the name mybLDA_train to perform binary LDA, which takes inputs of two data matrices X and X assuming column data, and return the optimal LDA projection direction as a unit vector. 8. (20 points) Write a function with the name mybLDA_classify which takes a data matrix X and a projection direction v, returns a row vector r that has size as the number of rows in X, and r_i = +1 if the i-th column of X is from the class as in X, and r_i = -1 if the i-th column in X is from the class as in X. 9. (20 points) Run your function, mybLDA_train, on the data given in the problem setting. Use your function mybLDA_classify to classify the following data set X = (1.3 2.4 6.7 2.2 3.4 3.2 8.1 7.6 2.1 1.1 0.5 7.4) and return the classification results. CSI436/536 Homework 4 Machine Learning
Close icon
Play audio
Feedback
Powered by NumerAI
Danielle Fairburn David Collins
Kathleen Carty verified

Sri K and 99 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
problem-l-linear-regression-and-cradient-learning-30-points-in-class-derived-lincar-regression-and-various-learning-algorithms-based-on-gradient-descent-in-addition-to-the-least-square-objec-67243

Problem 1: Linear Regression and Gradient Learning [30 points] In class, we derived linear regression and various learning algorithms based on gradient descent. In addition to the least square objective, we also learned its probabilistic perspective where each observation is assumed to have Gaussian noise. The noise of each example is an independent and identically distributed sample from a normal distribution. In this problem, you are supposed to deal with the following regression model that includes two linear features and one quadratic feature: y = ̈́0 + ̈́1x1 + ̈́2x2 + ̈́3x1^2 + ̄̄ where ̄̄ ~ N(0, ́^2). Your goal is to develop a gradient descent learning algorithm that will estimate the best parameters ̈́ = {̈́0, ̈́1, ̈́2, ̈́3}. Given the definition of noise, derive the corresponding mean and variance parameters of the normal distribution for y|x1, x2; ̈́. Also, write down its probability density function. You are provided with training observations D = {(x1(i), x2(i), y(i)) | 1 ≤ i ≤ m}. Derive the conditional log-likelihood that will be later maximized to make D most likely. If you omit the constant term that does not relate to the parameters, what will be the objective function J(̈́) that you are going to perform Maximum Likelihood Estimation? Does it look similar to the Least Square objective for this problem? Compute the gradient of J(̈́) with respect to each parameter. (Hint: You should evaluate the partial derivatives of J(̈́) with respect to each ̈́j, for 0 ≤ j ≤ 3) [Coding] Develop two learning algorithms from scratch: batch and stochastic gradient descent for this problem on the Auto dataset given in the Problem in Homework. Compare and contrast the performance among your batch gradient, stochastic gradient, and R's built-in function call: lm. Are the two best input features for predicting the output mpg the same across different algorithms? (Hint: At least your stochastic gradient algorithm must learn parameters comparable to the result from calling the R's built-in function. Otherwise, try to tune the learning rate ́.)

Sri K.

problem-1-we-say-that-p-is-projection-matric-if-pt-p-and-p2-p-if-p-is-a-projection-show-that-i-_-pis-also-a-projection-show-that-the-projections-p-and-i-_-p-satisfy-pi-_-p-0-let-a-be-any-mat-57317

Problem 1. We say that P is a projection matrix if PT = P and P^2 = P. (a) If P is a projection, show that I - P is also a projection. (b) Show that the projections P and I - P satisfy P(I - P) = 0. (c) Let A be any matrix of shape m x n so that AT A is square of shape n x n. Assuming that the inverse (AT A)^-1 exists, show that P = A(AT A)^-1AT is a projection matrix. [We saw in class that this matrix projects onto the column space of A.] (d) In the special case that A is square and invertible, show that P = A(AT A)^-1AT = I. What does this mean? Problem 2. Consider the plane x + 2y + 2z = 0 with normal vector a = (1, 2, 2). (a) Use the formula from 1(c) to find the 3 x 3 matrix P that projects onto the line ta. [Hint: Just let A = a.] (b) Use the matrix P to project the vector b = (1, -1, 1) onto the line. (c) Find two vectors in the plane x + 2y + 2z = 0 and then use the formula from 1(c) to find the 3 x 3 matrix Q that projects onto the plane. [Hint: Let A be the 3 x 2 matrix whose columns are the two vectors that you found.] (d) Use the matrix Q to project the vector b = (1, -1, 1) onto the plane. (e) Finally, check that P + Q = I. Does this surprise you? Problem 3. Shortcut. Let a = (1, 2, -1, 1) and consider the following hyperplane in R^4: a^Tx = 1x1 + 2x2 - 1x3 + 1x4 = 0. (a) Use 1(c) to compute the matrix P that projects onto the line ta. (b) We could also use 1(c) to compute the matrix Q that projects onto the hyperplane, but this would take too long. Instead, use the shortcut formula Q = I - P. (c) Project the point (1, 2, 3, 4) onto the hyperplane.

Adi S.

2-adapted-from-boyd-41-we-saw-in-class-that-the-k-means-algorithm-relies-on-two-observations-1-that-the-best-assignment-with-fixed-representative-vectors-is-to-assign-every-data-vector-to-th-74879

(adapted from Boyd 4.1). We saw in class that the k-means algorithm relies on two observations: (1) that the best assignment with fixed representative vectors is to assign every data vector to the cluster with the nearest representative and (2) that the best choice for representative vectors given a fixed cluster assignment is to choose the mean vector for each cluster. Here, are are going to prove the second point, which we did not show in class. To do this, we will deal with minimizing our clustering objective for a single cluster, with representative vector z, and assigned vectors x1, x2, x3, . . . , xL. We want to show that the optimal choice is z = x, where x = (1/L)(x1 + x2 + + xL) is a vector that is the mean of all vectors in the cluster. (a) For a vector xi, show that ||xi - z||^2 = ||(xi - x) - (z - x)||^2 (b) We can define the clustering objective for just this cluster as Jclust = Σ ||xi - z||^2. We can mimimize each cluster separately for this step of the k-means algorithm, so we want to choose z to minimize this. Show that: Jclust = Σ ||xi - z||^2 = [Σ ||xi - x||^2 - 2(xi - x)^T(z - x)] + L||z - x||^2 Hints: Use your answer from part (a), recall that u · v = u^T v, and pay careful attention to what does and does not depend on the index of summation, i. (c) Show that Σ(xi - x)^T(z - x) = [Σ(xi - x)^T](z - x) = 0 Hints: Pay attention to the term in brackets, remember the definition of x, and remember that the transpose is linear, so (u + v)^T = u^T + v^T (d) Combine b and c to show that Jclust = [Σ ||xi - x||^2] + L||z - x||^2. The vector z only shows up in one place in this problem. We want to find z to minimize Jclust. Explain why this happens when z = x.

Sri K.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,259 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,525 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,862 solutions

*

Transcript

-
00:01 So here we are considering about the linear regression model.
00:05 So from here, firstly we have to, from here in this question, firstly, we need to define the problem to solve the data.
00:14 Then from defining the problem, we have to derive the data for a lagrangian regression matter.
00:21 And after that, we have to compute the gradient of the regression model with respect to the each parameter...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever