Problem when trying to submit the last lab in the course

is anyone having this error when submitting the last lab in the “advanced Learning Algorithm” course on coursera:

Cell #11. Can’t compile the student’s code. Error: AssertionError(‘Wrong information gain. Expected 0.0 got: nan’)
Traceback (most recent call last):
File “/home/www/app/grading/exceptions.py”, line 112, in handle_solution_errors
yield {}
File “/home/www/app/grading/abstract.py”, line 393, in _grade
context = compiled_code.run(cell_index=cell.index)
File “/home/www/app/grading/submission/compiled_code.py”, line 195, in run
return list(self._code_items.values())[cell_num - 1].run()
File “/home/www/app/grading/submission/compiled_code.py”, line 54, in run
return import_module(self.import_statement, items)
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/tmp/student_solution_cells/cell_11.py”, line 23, in
compute_information_gain_test(compute_information_gain)
File “/tmp/public_tests.py”, line 106, in compute_information_gain_test
assert np.isclose(result, 0, atol=1e-6), f"Wrong information gain. Expected {0.0} got: {result}"
AssertionError: Wrong information gain. Expected 0.0 got: nan

I got everything correct in the lab. after every section I received " All tests passed." however still getting this error.

I submitted a report about it since like 4 days but didn’t get a reply yet.

I hope anyone can help me with that one.

Hello @Hamzah99,

This error message Cell #11. Can’t compile the student’s code. means that the 11th code cell can’t run through. Generally, you may identify the 11th code cell by just counting it from the topmost code cell, or you may also click the below “Restart & Run All” button

image

which will run all the code cells and stop at the 11th one that should report the same error.

The 11th cell runs the function compute_information_gain that is your exercise in the 10th cell and that is where you might want to start the debugging.

If you want some idea, you may search this forum with the keywords “Wrong information gain. Expected 0.0 got: nan” which is just the error message because, like you did, some learners had asked about it previously. Here is one of the results that may give you a hint which I think is already very close to the common cause of the error you posted. You may use the search for other similar discussions.

Good luck for the debugging, and cheers,
Raymond

Hello @Hamzah99
I found a thread where similar problem is discussed. Check below thread.

thank you both for your help.

all the problem was a mistake in the indentation.

1 Like

You are welcome!

Cheers,
Raymond