首页 > 解决方案 > Tensorflow TFDV 不适用于特定的 NaN 值

问题描述

我正在使用 Tensorflow 数据验证从数据中生成统计信息并推断要在 TFX 中输入的模式。

我没有找到任何指定 NaN 值的选项,例如,在 pandas 中有一个字段“na_values”,可以在其中指定读取数据时将被视为 NaN 的值。

我查看了整个 TFDV 文档,但没有找到。

tfdv.generate_statistics_from_csv(
    data_location,
    column_names=None,
    delimiter=',',
    output_path=None,
    stats_options=options.StatsOptions(),
    pipeline_options=None
)

options.StatsOptions() 是用于生成统计信息的选项,例如sample_count、sample_rate 等...

对我来说,读取处理缺失值的数据将数据保存为 Csv 或 TFRecord 并在导入 TFDV 后生成统计信息是没有意义的。

标签: tensorflowtensorflow-data-validation

解决方案


In TFDV 0.13.0, you can use tfdv.generate_statistics_from_dataframe method to generate statistics from a pandas Dataframe. If your data fits in-memory, you can use pandas.read_csv method to read the CSV file (by specifying na_values) and then use the above method to generate statistics.


推荐阅读