# C2 W4: Problem with the final lab in week 4

**URL:** <https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942>\
**Category:** Advanced Learning Algorithms\
**Tags:** week-module-4\
**Created:** [September 1, 2023, 9:40am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942 "2023-09-01T09:40:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juergen\_Geiser](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@Juergen\_Geiser](https://community.deeplearning.ai/u/Juergen_Geiser)\
**Post date:** [September 1, 2023, 9:40am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/1 "2023-09-01T09:40:39Z")

</div>

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,

Best

Juergen

P.s I hope to pass it soon.

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rmwkwok/32/126977_2.png) [@rmwkwok](https://community.deeplearning.ai/u/rmwkwok)\
**Post date:** [September 1, 2023, 10:44am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/2 "2023-09-01T10:44:57Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 1, 2023, 6:55pm UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/3 "2023-09-01T18:55:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 1, 2023, 6:56pm UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/4 "2023-09-01T18:56:22Z")

</div>

> [@Juergen\_Geiser](#):
>
> I have submitted the lab for the final score, but then I fail with 0%?  
> How could this happened?

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

---

<div class="post-metadata">

**Author:** ![Juergen\_Geiser](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@Juergen\_Geiser](https://community.deeplearning.ai/u/Juergen_Geiser)\
**Post date:** [September 4, 2023, 5:37am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/5 "2023-09-04T05:37:00Z")

</div>

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,

Juergen

 ![Screenshot (31)](https://global.discourse-cdn.com/dlai/original/3X/b/6/b6f1ce78dcc301636f5b510feeb3cf9a15f5012e.png)

{moderator edit: code image removed}

 ![Screenshot (33)](https://global.discourse-cdn.com/dlai/original/3X/0/0/00a0102815dde58dd24930d3969df37fc24e96ec.png)

---

<div class="post-metadata">

**Author:** ![Juergen\_Geiser](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@Juergen\_Geiser](https://community.deeplearning.ai/u/Juergen_Geiser)\
**Post date:** [September 4, 2023, 5:46am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/6 "2023-09-04T05:46:42Z")

</div>

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:

```auto
AssertionError Traceback (most recent call last)
<ipython-input-20-c263c9190d86> in <module>
      3 
      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,

Juergen

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

{Moderator edit: notebook link removed}

{Moderator edit: image of code removed}

 ![Screenshot (33).png](https://global.discourse-cdn.com/dlai/original/3X/0/0/00a0102815dde58dd24930d3969df37fc24e96ec.png)

 ![Screenshot (31).png](https://global.discourse-cdn.com/dlai/original/3X/b/6/b6f1ce78dcc301636f5b510feeb3cf9a15f5012e.png)

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 4, 2023, 5:57am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/7 "2023-09-04T05:57:57Z")

</div>

I suspect the error is in your compute\_information\_gain() function.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 4, 2023, 7:10am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/9 "2023-09-04T07:10:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Juergen\_Geiser](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@Juergen\_Geiser](https://community.deeplearning.ai/u/Juergen_Geiser)\
**Post date:** [September 4, 2023, 7:39am UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/10 "2023-09-04T07:39:40Z")

</div>

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,

Best

Juergen

 ![Screenshot (42)](https://global.discourse-cdn.com/dlai/original/3X/1/c/1c8edfcc03d5f443190bb6af40753da51e0fd40d.png)

---

<div class="post-metadata">

**Author:** ![Juergen\_Geiser](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@Juergen\_Geiser](https://community.deeplearning.ai/u/Juergen_Geiser)\
**Post date:** [September 4, 2023, 3:46pm UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/11 "2023-09-04T15:46:57Z")

</div>

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,

Best,

Juergen

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 4, 2023, 5:14pm UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/12 "2023-09-04T17:14:33Z")

</div>

Please continue the conversation in the PM thread.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [September 4, 2023, 5:14pm UTC](https://community.deeplearning.ai/t/c2-w4-problem-with-the-final-lab-in-week-4/433942/13 "2023-09-04T17:14:44Z")

</div>


