C2 W3 Final Assignment

My assignment passed all tests but it is not getting accepted. Keeps showing:
‘Can’t compile the student’s code. Error: NameError(“name ‘X_cv’ is not defined”)’ when submitted and grade given is 0%.

Is your code using a variable with that name?

Should it?

X_cv is used in an ungraded cell. I cannot change it and it seems X_cv is defined after that cell.

Your code should use the variables that are passed in a function call. Not the notebook global parameters.

I am still stuck here. I did not use X_cv in my code. It still shows this:


NameError Traceback (most recent call last)
in
1 plt.close(“all”)
----> 2 plt_tune_regularization(X_train, y_train, X_cv, y_cv, x, y_pred, err_train, err_cv, optimal_reg_idx, lambda_range)

NameError: name ‘X_cv’ is not defined

This is an ungraded cell and I do not know what to do.

X_cv is defined in this cell (where the data is generated):

Did you remember to run this cell (and all of the cells in the notebook) before you ran the cells in Section 3.3?

The code snippet I gave is from section 2.3. The code used X_cv in 2.3 but declared it later. This is what I can see in my cells. I do not know if others are facing the same issues or my ungraded cells got changed somehow.

{moderator edit of original reply}

Summary: Somehow, a code cell that uses the X_cv variable was relocated to an earlier location in the notebook, such that it would run before the X_cv variable was defined.

The fix was to start over on the assignment with a fresh copy of the notebook.