简体   繁体   English

无法在数据块 python 中显示 html output

[英]Having trouble to display html output in data bricks python

There are similar question, but nothing solve my problem.有类似的问题,但没有解决我的问题。 One thing I think that the last line of my code doesn't work in data bricks (where I am working).一件事我认为我的代码的最后一行在数据块(我工作的地方)中不起作用。 I am displaying part of the code which you actually can't reproduce, but it's probably small issue that might be solved without reproducing code.我正在展示您实际上无法重现的部分代码,但这可能是一个小问题,无需重现代码即可解决。 But if it's needed, I will update that.但如果需要,我会更新它。

Another thing I got that I can probably use我得到的另一件事我可能会用到

displayHTML("""<p>https://www.medium.com" </p>""")

But I couldn't figure out how to get the the link.但是我不知道如何获取链接。 The part of the code is below (I fit a classification model) and want to use lime package to interpret.下面是部分代码(我拟合了一个分类模型),想用lime package来解释。

!pip install lime
import lime
from lime import lime_tabular

explainer = lime_tabular.LimeTabularExplainer(
    training_data=np.array(X_train),
    feature_names=X_train.columns,
    class_names=['Fail', 'No_Fail'],
    mode='classification'
)
exp = explainer.explain_instance(
    data_row=X_test.iloc[1], 
    predict_fn=lgbm_class.predict_proba
)
exp.show_in_notebook(show_table=True)

What can I try next?接下来我可以尝试什么?

Call to explainer.explain_instance returns an instance of the Explainer class, and this instance has the as_html function , so following theoretically should work:explainer.explain_instance的调用返回Explainer class 的一个实例,并且该实例具有as_html function ,因此理论上以下应该有效:

exp = explainer.explain_instance(
    data_row=X_test.iloc[1], 
    predict_fn=lgbm_class.predict_proba
)
displayHTML(exp.as_html())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM