Hi team,
Can someone help me with the error I am getting? I have followed all the steps and written the code correctly, but this error is popping up. I have linked the screenshot.
Hi team,
Can someone help me with the error I am getting? I have followed all the steps and written the code correctly, but this error is popping up. I have linked the screenshot.
When you get an assert error from a unit test, it means your code was not written correctly.
You have a bug in your code.
Thank you, it is working now.
What was the bug? I am having the same exact problem despite going verbatim by the provided hints underneath the method: get_best_split().
Also, this is the only error I had in my assignment, and it results in a 0/100 for the assignment grade. Does that not sound like a bug? Only getting one function incorrect should not result in a failing grade for the coding assignments.
Also, does anyone know why there is no discussion tab for any of coursera’s machine learning specialization labs?
If you have an error that makes the grader crash, then it can’t give you any points.
All of the MLS course discussions are here on this platform. DLAI doesn’t use Coursera’s forums.
Or maybe I don’t understand what you mean by “labs”.
Thank you for your reply! I suppose I lucked out (SOL) with the particular error I am getting that “breaks” the autograder. So even though it happens near the end of the assignment/lab it still results in 0/100, weird! Didn’t know that.
By labs, I mean practice labs that are graded as part of a specialization for coursera; they are essentially jupyter notebooks with pre-loaded instructions for writing code cells that are graded with said (auto)grader you mentioned.
I am still getting the same error after running the associated test function; here is a screenshot so we can get a better picture of what’s happening. It includes print statements just to maybe get a better picture of what’s happening:
Here is what happens without the print statements:
The autograder decided to give me credit - I did nothing different code-wise. Not sure if someone corrected or fixed something or not. Either way, thanks again for your reply.
Hints:
In you code you add to get_best_split(), what did you set as the initial value for max_info_gain?
Inside the for-loop, did you call compute_information_gain() with the correct arguments? And, does your compute_information_gain() function work correctly?
Nothing wrong with the grader as far as I know, and updates on the weekends never happen in any case.
Glad you got past the issue.
Hi
I have the same issue with executing C2W4 assignment. Can you please help me to fix this issue?
Here is the copy of the code and error message:
best_feature = get_best_split(X_train, y_train, root_indices)
print("Best feature to split on: d" best_feature)
get_best_split_test(get_best_split)
AssertionError Traceback (most recent call last)
in
3
4 # UNIT TESTS
----> 5 get_best_split_test(get_best_split)
~/work/public_tests.py in get_best_split_test(target)
136 y = X[:,1]
137 result = target(X, y, node_indexes)
→ 138 assert result == 1, f"If the target is fully correlated with other feature, that feature must be the best split. Expected 1, got {result}"
139
140 y = 1 - X[:,0]
AssertionError: If the target is fully correlated with other feature, that feature must be the best split. Expected 1, got 0
It seems your code doesn’t compute the correct results for that test.
You are right. But I have no idea how to fix it since I have not changed the main code provided by Coursera. Can you please help?
Thanks
Please check your personal messages for instructions.
For those who find this thread later:
The issue was incorrect indentation within the get_best_split() function. Fixing the indentation was all that was needed.
This can happen if you copy-and-paste the hint code into the function cell, and do not notice that some of the keywords are shown in a red font.
This means the indentation is incorrect and needs to be re-entered.