-1

I already referred the posts here,here,and here. So, don't mark it as duplicate

I am trying to execute a tutorial as provided here (binary classification of breast cancer)

When I execute the below piece of code, I get an error as shown below

explainer = lime_tabular.LimeTabularExplainer(X_train, mode="classification",
                                              class_names=breast_cancer.target_names,
                                              feature_names=breast_cancer.feature_names,
                                             )

explainer

NameError: name 'lime_tabular' is not defined

But my code already has the below import statements

import lime
import lime.lime_tabular

What is causing this issue?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
The Great
  • 7,215
  • 7
  • 40
  • 128

1 Answers1

1

You are not giving a name to the imported resource.

You can either use lime.lime_tabular when you are calling it on the code,

or change the second line of import to from lime import lime_tabular

The second approach would be the one I prefer when I code.

Arson 0
  • 757
  • 2
  • 14
  • Thank you, but let's not stop there. What you have is a NameError, this means it is the mentioning of lime_tabular that is getting a mistake, not the existence or usage of the lime_tabular per se. If it was the module that was missing, it would be a ModuleNotFoundError. Maybe another attempt would be 'import lime.lime_tabular as lime_tabular'. If you have more info I can try to figure it out. – Arson 0 Jan 14 '22 at 03:35
  • you are fantastic. I made a typo error. I missed letter `F` in `From`. I typed it as `rom`. Hence, it didn't work. But now it works – The Great Jan 14 '22 at 03:37
  • If you have time, can help me with this related post? https://stackoverflow.com/questions/70984947/efficient-way-to-generate-lime-explanations-for-full-dataset – The Great Feb 04 '22 at 10:39