# C1_W4 Linear Algebra - Get Covariance Matrix

For the get_cov_matrix in Exercise 4 - Get Covariance Matrix, all the units tests ran successfully but when I submit the complete assignment, I get 0 points for it and the below error:

1 Like

There must be some way in which your code is not general, if it passes the tests in the notebook, but fails the grader. The error message gives a clue about the way you are indexing one of the matrices in your solution. Please take a look at that logic with the â€śnon-generalityâ€ť idea in mind.

1 Like

figured it out. Thanks.

2 Likes

Itâ€™s great news that you were able to find the solution just based on my hint. Nice work!

1 Like

I have the same issue. Can you please tell how you resolved it? Used X.T and X for dot product. Then divided by 54

1 Like

I am also having the same issue

1 Like

Are you sure your code passes the tests in the notebook? If so, then that means there is something about your code that is not â€śgeneralâ€ť: it works for one test case in the notebook, but it fails a different test case from the grader. So if that is the case, then please re-examine your code with that frame of mind. Looking for something hard-coded to match that particular test case that does not generalize.

1 Like

Instead of dividing directly by 54, use the numpy divide function. This should fix the issue.

1 Like

The difference between dividing with / or `np.divide` is probably not the real issue. The real issue is that 54 just happens to be the number for that particular test case. You need to use the â€śshapeâ€ť of the input matrix in order to get general code that will work with all input matrices, not just ones that happen to have 55 rows.

1 Like

Yeah, this might be the one. I am not sure as to which one fixed my issue as I did both the changes. Using the shape of the input matrix might be the one that fixed it. Thanks @paulinpaloalto .

1 Like

Well, maybe it doesnâ€™t matter, but if you really want to get clarity on this, thereâ€™s an obvious scientific experiment you can run: use `np.divide` with the hard-coded 54. I predict it will fail the grader.

Update: ok, I actually ran the experiment and my prediction was correct. Science!

1 Like

That is what I used from the beginning.

1 Like

Exercise 3
cannot reshape array of size 220 into shape (3,4)

Exercise 4