W1_Coding_Assignment (prob_of_X_given_C)

My notebook runs perfectly and all output matches with sample test output provided but when I submit the assignment it shows the following error.

There was a problem compiling the code from your notebook. Details:
name ‘prob_of_X_given_C’ is not defined

Any help regarding this is much appreciated, Thanks in advance

Hi @simplyjaga, can you send me your notebook via DM and I’ll take a look?

I’m facing the same issue. @a-zarta
What should I do to finish this project?

Hi @simplyjaga, it looks like several cells in your notebook are missing some important metadata for grading. To fix this you need to click on the View tab, Cell Toolbar and then Edit Metadata. This allows you to edit the metadata for every cell. Now go unto the cell and click the “Edit Metadata” button, this will show you a json, make sure to replace the contents with this:

  "tags": [
  "trusted": false

Check that all the code cells in the assignment have this metadata, otherwise the grader will just omit them. You could also restore back to a blank assignment (the instructions are in a reading item) and copy paste your answers in this fresh notebook.

Did you by any chance delete the original cells and created new ones for the graded functions? Or maybe you worked in your local and then uploaded the notebook (some jupyter environments have a tendency of overwritting metadata)? Please let me know so I can know the origin of this bug, which is very uncommon.

1 Like

Hi @fpcoutinho, you are facing the same error I just described in the earlier post but in your case this is only for the cell that has the prob_of_X_given_C function. Could you also let me know if by any chance you deleted the original cell and created a new one or maybe you worked in your local?

Yes I deleted some cells… How could I reset to the original notebook and try again?

I did what was recommended above and I’m facing another error:

You are submitting a version of the assignment that is behind the latest version.
The latest version is 1 and you are on version None.
To upgrade to the latest version follow the instructions in the reading item called ‘(Optional) Common Coursera Labs Operations’.
This item can be found before the assignment of the first week of the course.
This notebook should be up to date so create a copy of it in your drive, migrate your work to this newer version and submit again for grading.

I already tried to " Update lab to the latest version" with no success.

Thanks @a-zarta, I created new cells to code step by step, to see the output at the intermediary steps. So I might have deleted the original cell and used the newly created cells going forward.

I have been trying to understand the problem for the past 3 days. Huge Thanks for your time and help.

@fpcoutinho oh no, did you edited the metadata at a cell level or did you edit it for the whole notebook? That error message is due to a parameter at the notebook level that controls the current version of the assignment so that it is aligned with the latest grader version (we have this since sometimes coursera fails to show the latest version of the assignment). I believe in your case it it better to get a fresh copy of the notebook. If you want a fresh copy of the notebook you can do so by following this steps:

  • Click on the Jupyter logo in the upper left corner of the screen (this will take you to the jupyter filesystem)
  • There select the C3_W1_Assignment.ipynb file and click the shutdown button
  • Select it again and click the rename button and rename the file
  • Now click on Coursera’s Help button in the upper right corner of the screen and click the “Get Latest Version” button

This will bring you a blank C3_W1_Assignment.ipynb file, which you can add your changes to and then submit for grading.

@simplyjaga, happy to help! You can follow the previous steps to get a fresh notebook since updating metadata for several cells can be annoying.

I Have the same error one of them is “There was a problem compiling the code from your notebook. Details: name ‘prob_of_X_given_C’ is not defined” this is maybe related to uniform_generator function, any help please

I did this and now I’m certified haha thanks

@BADREDDINE_BALAJ read the messages above and try to follow the instructions

Nice job @fpcoutinho!

@BADREDDINE_BALAJ did you check the missing metadata stuff I mentioned earlier? I can take a look at your notebook if you are unsure what is causing the issue. Send it to me via a DM.

Can anyone helpme with the compute_training_params function and prob_of_X_given_C function?
C3_W1_Assignment.ipynb (148.6 KB)

@fpcoutinho and @a-zarta
Thanks it sloved

Thank you very much, it really helped

You are not suppose to share your assignments on public post like this :woman_facepalming:

It is against community guidelines.

Kindly remove your notebook assignment from your post comment.

Thanks for notified me, I removed it

Remove your assignment from the post. It is against community guidelines.

you solved it . if it is . show me the code please