Week 1 Assignment1 ex. 9


Filename: class_frequencies

Grader output : There was a problem grading your submission. Details: 0

Am I doing something wrong ?

Hi @Shubham_Oulkar! Make sure your implementation takes into account the case when there are no spams or no hams, the grader tests these two cases. A refactored version of the assignment will go live tomorrow that takes this into account in the expected output. Let me know if this helps or if I can help more :slight_smile:

Has anyone a clue on how to count the frequencies if the frequency is zero?
When you want to count frequency of 1 if it does not occur I get an key error.
Spent hours on the internet but could’t find a solution.

Try to find subcategories, use groupby, size/count and if conditions.

This seems to be more of a python challenge than mathematics.
I am able to get a series with the frequencies by using groupby. But I seem to get stuck on trying to find out if the value is ham or spam when one of them is empty

Found a way. Copy the for iterrows form exercise 8.
But still curious how you can manage it with groupby.

I did as said earlier above. Then in if else conditions I use values_count().count(), if values_count is 1 then check for what subcategory is present in column. if subcategory is 0 then append table with subcategory 1 with 0 counts and vise versa.