Bug: cannot submit final Practice Lab: Decision Trees, despite passing all tests and retrying on different times & days

On passing all tests an submitting the lab, I consistently got graded 0% with following error log:

Cell #2. Can’t compile the student’s code. Error: NameError(“name ‘X_train’ is not defined”)
Traceback (most recent call last):
File “/home/www/app/grading/exceptions.py”, line 112, in handle_solution_errors
yield {}
File “/home/www/app/grading/abstract.py”, line 393, in _grade
context = compiled_code.run(cell_index=cell.index)
File “/home/www/app/grading/submission/compiled_code.py”, line 195, in run
return list(self._code_items.values())[cell_num - 1].run()
File “/home/www/app/grading/submission/compiled_code.py”, line 54, in run
return import_module(self.import_statement, items)
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/tmp/student_solution_cells/cell_2.py”, line 4, in
print(“First few elements of X_train:\n”, X_train[:5])
NameError: name ‘X_train’ is not defined

On and off in the lab itself the error will also happen:

–start lab copy: print(“First few elements of X_train:\n”, X_train[:5]) print(“Type of X_train:”,type(X_train)) ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
in
----> 1 print(“First few elements of X_train:\n”, X_train[:5])
2 print(“Type of X_train:”,type(X_train))

NameError: name ‘X_train’ is not defined

–end lab copy

This pertains to a cell that is out of student’s reach.

This error implies that something is wrong with your notebook. The grader is unable to locate a variable named X_train.

Either you have modified the notebook in a way that breaks the grader, or your notebook uses a notebook global variable that the grader does not have access to.

Either way, your smoothest path forward is to delete your notebook and get a fresh copy, and start over.

Tips: Avoid using global variables in your code, and do not make any undocumented changes to the notebook.

Use the File → Open menu, then select the notebook checkbox, and click on the red “trash can” icon.

Then use the Lab Help tool and “Get latest version”. The Lab Help is via the question-mark inside a circle, in the upper right corner of the notebook.

1 Like

Tom, thanks for your swift response!

The lab got graded.

1 Like

Nice work!