我正在尝试使用 tensorflow (2.2) 数据验证(TFDV 版本:0.22.2)在 databricks GPU 集群上可视化数据。
我在 databricks notebook 中运行代码: https://nbviewer.jupyter.org/github/tensorflow/tfx/blob/master/docs/tutorials/data_validation/tfdv_basic.ipynb
但是,当我运行的时候
tfdv.visualize_statistics(train_stats)
我得到了:
<IPython.core.display.HTML object>
没有显示 html 网页。
我已尝试更新 matlibplot,但它不起作用。
我也试过https://python-forum.io/Thread-How-to-display-IPython-core-display-HTML-object 和 How to embed HTML into IPython output?
但仍然没有显示 html。
谁能帮我解决这个问题?
谢谢
更新
我试过了:
html = tfdv.visualize_statistics(train_stats).data
得到:
<IPython.core.display.HTML object>
AttributeError: 'NoneType' object has no attribute 'data'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<command-2488671> in <module>
----> 1 html = tfdv.visualize_statistics(train_stats).data
AttributeError: 'NoneType' object has no attribute 'data'
最佳答案
这可以通过导入 function 来解决。生成 HTML 对象并调用它们而不是可视化函数。然后,使用 DataBricks displayHTML 函数可视化这些函数。
from tensorflow_data_validation.utils.display_util import get_statistics_html
displayHTML(get_statistics_html(train_stats))
问题在于 tfdv 实用程序笔记本导入了 Ipython 显示功能,并在可视化函数中使用 Ipython 显示功能覆盖了 DataBricks 显示功能。
try:
# pylint: disable=g-import-not-at-top
from IPython.display import display
from IPython.display import HTML
except ImportError as e:
display_anomalies 函数也有类似的问题,可以通过直接导入 get_anomalies_dataframe 函数并显示生成的 pandas dataframe 来解决。
关于python - 从数据 block 笔记本运行时,tensoflow 数据验证 visualize_statistics() 没有显示 html 网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62962941/