View the step-by-step solution to:

Exercise 2 ( 6 points) : Computing estimate of Covariance Matrices Now , we will compute the two d x d- dimensional matrices : The within-class and...

Hello, I'm trying to solve this exercise. The instructions are to develop a function to calculate the covariance as per the below specs:

q4.png


q5.png

q4.png

Exercise 2 ( 6 points) : Computing estimate of Covariance Matrices
Now , we will compute the two d x d- dimensional matrices : The within-class and the between -class estimates of covariance matrix .
2. 1 Within - class ( 3 points )
Complete the function get_ 5 W matrix ( X , Y ) that returns the within-class estimate of covariance matrix SW .
SW =
_ Si
where Si = > ( x - m; ) ( x - mi )" ( covariance matrix estimate for every class "i " )
XEDi
- > x
Mi XEDi
Di are data points labeled as class i . " ; is the number of datapoints in class i . & is the number of unique classes in the dataset . I is the number of features .
Note that* * and I'm; are vectors .
def get S W matrix ( X , Y ) :
5 W = up . zeros ( ( X . Shape [ 1 ] , X . shape [ 1 ] ) )
# #your code here*
return S W
SW = get S W matrix ( X , Y )

q5.png

2. 2 Between - class covariance matrix estimate ( 3 points )
Complete the function get 5 & matrix ( X , Y ) which returns the between-class estimate of covariance matrix SB
SB =
IN; ( m ; - 1 ) ( m ; - In )' ( covariance matrix estimate for every class " )
where in is the overall mean and mm ; and N; are the sample mean and sizes of the respective classes .
def get S B matrix ( X , Y ) :
# # #
# # # YOUR CODE HERE
# # #
return S E
S B = Bet S E matrix ( X , Y)

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question