Lr_model' is not defined

Hello,

I am getting :
Cell #23. Can’t compile the student’s code. Error: NameError(“name ‘lr_model’ 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_23.py”, line 25, in
abs_risks = lr_ARR_quantile(X_dev, y_dev, lr)
File “/tmp/student_solution_cells/cell_21.py”, line 45, in lr_ARR_quantile
baseline_risk = base_risks(X, lr_model)
NameError: name ‘lr_model’ is not defined

i do not know , who should define this. it is not part of this exercise so it should be somewhere maybe inutil ??? please help.

Thanks

Zvi

Hi,

@Zvi_Boiangou you’ll need to share your code so that anyone can see what’s causing the issue. Without seeing the code, it’s difficult to pinpoint the exact problem.

Thanks.

I doubt anyone could figure this out without seeing the complete notebook and all the associated files. Also note as a general matter that we’re not supposed to share solution code in a public way on the forums. The first question is where lr_model should be defined. Look for the cells in the notebook that contain “import” commands. Did you modify any of them? E.g. perhaps accidentally turn them from code cells into “markdown” (documentation) cells. If the import commands look correct, then maybe one of the accompanying files in your assignment was not correctly initialized or has been modified. You can click “File → Open” and then check the contents of any utility “dot py” files that are part of the assignment. Here’s a thread about how to get clean copies of the notebook and the rest of the files in the assignment (read all the way to the end of the article).

Hello,

The lr_model is not part of the exercise of this task, thus it should be defined as a part of some package.

i am getting this issue even in the middle of the task when the lr_ARR_quantile_test is called :

NameError Traceback (most recent call last)
in ()
1 ### test cell ex6: you cannot edit this cell
----> 2 lr_ARR_quantile_test(lr_ARR_quantile, X_dev, y_dev, lr)

~/work/W1A1/public_tests.py in lr_ARR_quantile_test(target, X_dev, y_dev, lr)
241
242 # Test
→ 243 abs_risks = target(X_dev, y_dev, lr)
244
245 # print the Series

in lr_ARR_quantile(X, y, lr)
21 ### START CODE HERE (REPLACE INSTANCES OF ‘None’ with your code) ###
22 # Calculate the baseline risks (use the function that you just implemented)
—> 23 baseline_risk = base_risks(X, lr_model)
24
25 # bin patients into 10 risk groups based on their baseline risks

NameError: name ‘lr_model’ is not defined

Hello @Zvi_Boiangou

UNQ_C6 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
def lr_ARR_quantile(X, y, lr):

for code
Calculate the baseline risks (use the function that you just implemented)

you are suppose to use only lr and not lr_model.

Regards
DP