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:   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 = &gt; ( x - m; ) ( x - mi )&quot; ( covariance matrix estimate for every class &quot;i &quot; )
XEDi
- &gt; x
Mi XEDi
Di are data points labeled as class i . &quot; ; is the number of datapoints in class i . &amp; 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 ) 2. 2 Between - class covariance matrix estimate ( 3 points )
Complete the function get 5 &amp; 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 &quot; )
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)

### 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