2

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

这是一个不起作用的简单示例。我的期望是对该功能的通知,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)

4

1 回答 1

0

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

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

原来它还没有实现。

于 2020-11-16T10:24:40.607 回答