Python 已删除的jupyter笔记本单元-是否有方法从仍在内存中的对象返回代码?

Python 已删除的jupyter笔记本单元-是否有方法从仍在内存中的对象返回代码?,python,jupyter-notebook,Python,Jupyter Notebook,我一整天都在找一个翻译。最终,语法正确,但成功删除了定义解释程序的jupyter笔记本单元。该对象仍在内存中,因此我可以调用该对象并获得结果,但现在我无法返回到实际代码。代码应该是这样的: explainer = lime.lime_tabular.LimeTabularExplainer(train, feature_names=boston.feature_names, class_names=['price'], categorical_features=categorical_featu

我一整天都在找一个翻译。最终,语法正确,但成功删除了定义解释程序的jupyter笔记本单元。该对象仍在内存中,因此我可以调用该对象并获得结果,但现在我无法返回到实际代码。代码应该是这样的:

explainer = lime.lime_tabular.LimeTabularExplainer(train, feature_names=boston.feature_names, class_names=['price'], categorical_features=categorical_features, verbose=True, mode='regression')
有没有办法检查内存中的explainer对象,并打印用于创建它的“设置”

我试过跑步

explainer 

但他们都回来了

<lime.lime_tabular.LimeTabularExplainer object at 0x000001B5F1BAD860>

如果您的IPython内核仍在运行,您可以使用IPython的line magic查看该内核中执行的所有命令(这应该包括用于定义lime解释程序的代码)

相应的命令是(别名
%hist


要执行该命令,只需在相应笔记本的新单元格中运行该命令。

我在jupyter中使用import-inspect-print(inspect.getmembers(explainer))获得了一些信息。您可以在编辑菜单项下尝试“撤消”。否则,您可以使用
%hist
查看当前会话的命令历史记录。否则,您可以尝试
explainer.\uuu dict\uuu
查看其所有变量谢谢,这比检查方法好得多!
<lime.lime_tabular.LimeTabularExplainer object at 0x000001B5F1BAD860>