C1_W1_Assignment Problem 2

When I submit the assignment, the grades page gives me this error on question 2:
"Unexpected error occurred during function check. We expected function 'compute_class_freqs' to return type <class 'list'>. Please check that this function is defined properly."
However, my code passes all the tests, and returns <class ‘list’> when I debug with type().
For context, this function is intended to return the positive and negative frequencies of each class in labels.
Here’s my code:

(Solution code removed, as posting it publicly is against the honour code of this community, regardless if it is correct or not. You can share the errors you get)

1 Like

Hi @coffee_dan,

If you are still facing this problem, then please send me your code in a private message so that I can check it out.

Regards,
Samuel

1 Like

Hi @coffee_dan,

After looking at your code, firstly, do not change code where it is not expected. Like, in your case, you were changing the return statement. Instead of doing that, try to correct your code.

Next, the doc string tells that the returns need to be of np.array type. But the way you have implemented your solution, your negative_frequencies returns as list (needs to be an array like positive_frequencies )

Screenshot 2023-11-17 at 2.34.30 PM

That is the issue. Both of these need to be arrays before they are retuned in the last line.

Hope this helps,
Mubsi

1 Like

It’s fixed, thank you so much!

1 Like