Deleted jupyter notebook cell - is there a way to get back to the code from an object still in memory?

Viewed 245

I have been trying to get a LIME interpreter working all day. Finally got the syntax right, but managed to delete the jupyter notebook cell defining the explainer. The object is still in memory, so I can call the object and get results, but now I can't get back to the actual code. The code should be something like this:

explainer = lime.lime_tabular.LimeTabularExplainer(train, feature_names=boston.feature_names, class_names=['price'], categorical_features=categorical_features, verbose=True, mode='regression')

Is there any way to inspect the explainer object that is in memory, and print the "settings" that were used to create it?

I have tried just running

explainer 

or

print(explainer)

but both just return

<lime.lime_tabular.LimeTabularExplainer object at 0x000001B5F1BAD860>
1 Answers

If your IPython kernel is still running, you can use IPython's line magic to view all commands executed in that kernel (this should include the code used to define your lime explainer).

The appropriate command for this is %history (alias %hist).

To execute, simply run that command in a new cell in the appropriate notebook.

Related