【问题标题】:TFX / Tensorflow Data Validation (TFDV) does not work on data driftTFX / Tensorflow 数据验证 (TFDV) 不适用于数据漂移
【发布时间】:2023-04-02 06:22:01
【问题描述】:

我不确定下面的代码有什么问题。我阅读了文档,所有文档都指向与此类似的方法。

这是一个不起作用的简单示例。我的期望是通知 x1 功能,因为两个数据集之间的分布非常不同。

import numpy as np
import pandas as pd
import tensorflow_data_validation as tfdv

NUM_VALS_TRAIN = 10000

# -------- Today --------

df = pd.DataFrame({
    'x1': np.random.normal(4, 3, NUM_VALS_TRAIN),
    'x2': np.random.normal(-3, 4, NUM_VALS_TRAIN)})

stats_train_today = tfdv.generate_statistics_from_dataframe(df)

# -------- Yesterday --------

df = pd.DataFrame({
    'x1': np.random.normal(400, 300, NUM_VALS_TRAIN),
    'x2': np.random.normal(-3, 4, NUM_VALS_TRAIN)})

stats_train_yesterday = tfdv.generate_statistics_from_dataframe(df)

# -------- Validate --------

schema = tfdv.infer_schema(stats_train_yesterday)

tfdv.get_feature(schema, 'x1').drift_comparator.infinity_norm.threshold = 0.01

anomalies = tfdv.validate_statistics(statistics=stats_train_today,
                                     schema=schema,
                                     previous_statistics=stats_train_yesterday)

tfdv.display_anomalies(anomalies)

结果总是No anomalies found.

这段代码有什么问题?

(使用 tfx==0.24.1)

【问题讨论】:

  • 尝试使用drift_comparator.jensen_shannon_divergence.threshold 而不是drift_comparator.infinity_norm.threshold
  • jensen_shannon_divergence 确实有效!非常感谢@KeyurPotdar!

标签: python pandas validation data-analysis tfx


【解决方案1】:

好的,我在https://github.com/tensorflow/data-validation/blob/master/RELEASE.md找到了这个

“添加对检测数字特征中的漂移和分布偏斜的支持”

原来它还没有实现。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多