AI4M Course 3 Week 1 autograder failed


I passed all unit tests WITHOUT seeing any errors or unexpected output, but the autograder failed, and showed 0/11. The error I see from autograder is

Cell #36. Can't compile the student's code. Error: NameError("name 'RandomForestClassifier' is not defined",)

This is really odd. RandomForestClassifier is clearly defined by the unmodified cell #36

from sklearn.ensemble import RandomForestClassifier
control_model = holdout_grid_search(RandomForestClassifier,
                                    tmp_X_train, tmp_y_train,
                                    tmp_X_val, tmp_y_val, hyperparams, verbose=True)

Another odd thing is that I see autograder is saying Exercise 1 when this cell being complained about is really for exercise 10.

I don’t know why it would complain. Here is my lab ID bpxiknwn. I’d appreciate any help!



This is my last remaining assignment left for this course. I’d highly appreciate any help!!

Hi @MrHuanwang,

Exercise 1 over here means Assignment 1.

As for the RandomForestClassifier issue @MrHuanwang, your implementation of Ex 10 has a flaw in it.

If you look at your assignment, you’ll notice you are using RandomForestClassifier (when setting up the estimator variable) in your Ex 10, before it is actually imported later (for the very first time in the assignment) in the test cell of Ex 10. So essentially, you are using a hard-coded function, that too before it is defined. You can get away with that behaviour in a Jupyter Notebook, but not when it would come to the grader.

If you read the description for the parameters for the function in Ex 10, you’ll realise what needs to be used to set up estimator.

Hope this helps,


I really should have caught it myself. It’s been a bit overwhelming to go through all 3 courses for the entire specialization over the past 4 days. My head is not in the clearest state. I’m glad I’m able to finish it all before the free 7 day trial ends for this specialization :stuck_out_tongue:

1 Like