Hi,
This is on the Wk4 programming assignment:
I added code copy/pasting from the hints and I got the expected results + All tests passed.
However,
From # UNQ_C3 onwards, while still getting the expected results, my tests fail.
I can’t make up from the errors what to do different.
Any advise, pls ?
Thanks!
2 Likes
TMosh
January 3, 2024, 10:31pm
2
Please post a screen capture image showing the error messages or asserts.
TMosh
January 4, 2024, 1:20am
4
In the Hint code for the compute_entropy() function, you can put in some code here to give p1 an initial value.
1 Like
TMosh
January 4, 2024, 1:26am
5
That initial value is discussed in the instructions:
I’m seeing different Hints for # UNQ_C3…
1 Like
…and this is #UNQ_C3 , with my copy/pasted code…
{moderator edit: code removed}
1 Like
TMosh
January 4, 2024, 2:39am
9
Well, you’re looking at UNQ_C3 “compute_information_gain()”, and I’m talking about UNQ_C1 “compute_entropy()”.
On UNQ_C1 I look good, as much as I can tell…
{moderator edit: code removed}
1 Like
TMosh
January 4, 2024, 4:57am
12
Refer to the image of the hint code I posted earlier. You’re missing setting an initial value for P1.
Passing the notebook unit tests doesn’t prove your code is perfect.
1 Like
I thought the initial value of p1 was…
p1 = len(y[y == 1]) / len(y)
1 Like
TMosh
January 4, 2024, 8:50pm
14
Yes it should be.
Where is that in your code?
Here…
{moderator edit: code removed}
1 Like
TMosh
January 5, 2024, 5:18am
16
That should solve the problem of the “p1 referenced before assignment” error.
…supposably on #UNQ_C3 .
And it doesn’t solve the problem of the “p1 referenced before assignment” error.
1 Like
TMosh
January 5, 2024, 6:05pm
18
Check your personal messages for instructions.
TMosh
January 6, 2024, 12:32am
20
Sorry, I don’t open zip files for security reasons.
See my personal message to you for instructions. Send the ipynb file via a personal message. Do not modify the file name.
1 Like
TMosh
January 6, 2024, 4:54am
21
Update for those who find this thread later:
Inside the compute_entropy() function, the code that tests the p1 values was not indented to the correct level.
1 Like