python - 从数据 block 笔记本运行时,tensoflow 数据验证 visualize_statistics() 没有显示 html 网页

标签 python tensorflow ipython tensorflow2.0

我正在尝试使用 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-objectHow 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/

相关文章:

apache-spark - PySpark错误:AttributeError:'NoneType'对象没有属性'_jvm'

python - Pandas to_excel 不写换行符

python - 如何访问生成器提供的 Keras 自定义损失函数中的样本权重?

使用 GCloud ( GCE VM ) 和使用 CUDA 安装 tensorflow-gpu 包的 Python 错误

python - 为什么我的 2D 插值器在 SciPy 中生成一个交换轴的矩阵?

ipython - 在笔记本上回答 Yes/No shell 提示

python 3错误RuntimeError : super(): no arguments

python - 使用 num_labels 1 vs 2 的 huggingface 变形金刚分类

python - 正则表达式匹配非字母字符(复合词的连字符除外)

windows - Tensorflow 在带有 anaconda 且没有互联网连接的 Windows 上安装