C2 W4: Problem with the final lab in week 4

Dear colleagues,

I have done the final lab coding in week 4 and I could pass all the tests.
All is O.K.

I have submitted the lab for the final score, but then I fail with 0%?
How could this happened?
Did anybody pass it?
Do you have similar problems?

I could also send you my code and the error list.

Let me know,
many thanks for helping,



P.s I hope to pass it soon.

Hi @Juergen_Geiser,

Yes, many have passed it.

  1. Can you share a screenshot of the grader’s report?

  2. Did you finish the notebook solely on Cousera, and NOT on your local environment?

  3. Go to the notebook, run through all the cells, make sure there is no error message, and then click “File” > “Save and Checkpoint”, and then share a screenshot of the upper part of the notebook like below:

I have your notebook and will reply via the private message.

Note that passing the tests in the notebook does not prove your code is perfect. The grader has its own separate tests.

Dear Colleagues,

I could improve the exercise 3 and it passed.
I have problems in exercise 4, the error is:

AssertionError: When the target variable is pure, there is no best split to do. Expected -1, got 0

What dose it mean, should I have to ask for a “no splitt case”?
I did the code as following:

{moderator edit: code removed}

What is wrong, please help me.

Thanks for your help,

best regards,


{moderator edit: code image removed}

Dear Raymond,

I found an error in exercise 3 and I could pass it. I go on but in exercise 4, there is also a problem:

I coded:

{moderator edit: code removed}

The example was fine, but the tests says:

AssertionError                            Traceback (most recent call last)
<ipython-input-20-c263c9190d86> in <module>
      4 # UNIT TESTS
----> 5 get_best_split_test(get_best_split)

~/work/public_tests.py in get_best_split_test(target)
    166     y = X0.T
    167     result = target(X, y, node_indexes)
--> 168     assert result == -1, f"When the target variable is pure, there is no best split to do. Expected -1, got {result}"
    169     print("\033[92m All tests passed.")

AssertionError: When the target variable is pure, there is no best split to do. Expected -1, got 0

Please help me, I got stuck and need a hint. Did I miss one statement, e.g., which says: the variable is pure???

Many thanky for your help,

best regards,


P.S. I want to pass the lab as soon as possible!

{Moderator edit: notebook link removed}

{Moderator edit: image of code removed}

I suspect the error is in your compute_information_gain() function.

Please do not post your code on the forum. That’s not allowed by the Code of Conduct.

Screen captures of any asserts or error messages are fine.

Hello Tom,

sorry I skipped the code, here is the screen-shot of the result of exercise 4.
Does it mean, I should have -1 as result, while my node_indexes is 0 ??
Then all is pure and I did not have to split again.
Sorry, I get stuck with this, please give me a hint,



Hello Tom,

it tried to apply the iteration over the node_indices,
while I put:
if i in node_idices

but I also field.

Could you help me to come over the problem,
that will help,



Please continue the conversation in the PM thread.