in tensorflow_data_validation/anomalies/schema.cc [1218:1261]
std::vector<Description> Schema::UpdateWeightedFeature(
const FeatureStatsView& view, WeightedFeature* weighted_feature) {
std::vector<Description> descriptions;
int min_weight_length_diff = 0;
int max_weight_length_diff = 0;
for (const tensorflow::metadata::v0::CustomStatistic& custom_stat :
view.custom_stats()) {
const string& stat_name = custom_stat.name();
// Stat names should be in-sync with the weighted_feature_stats_generator.
if (stat_name == kMissingWeightedValue && custom_stat.num() != 0) {
descriptions.push_back(
{tensorflow::metadata::v0::AnomalyInfo::
WEIGHTED_FEATURE_MISSING_VALUE,
"Missing value feature",
absl::StrCat("Found ", custom_stat.num(),
" examples missing value feature.")});
} else if (stat_name == kMissingWeight && custom_stat.num() != 0) {
descriptions.push_back(
{tensorflow::metadata::v0::AnomalyInfo::
WEIGHTED_FEATURE_MISSING_WEIGHT,
"Missing weight feature",
absl::StrCat("Found ", custom_stat.num(),
" examples missing weight feature.")});
} else if (stat_name == kMinWeightLengthDiff && custom_stat.num() != 0) {
min_weight_length_diff = custom_stat.num();
} else if (stat_name == kMaxWeightLengthDiff && custom_stat.num() != 0) {
max_weight_length_diff = custom_stat.num();
}
}
if (min_weight_length_diff != 0 || max_weight_length_diff != 0) {
descriptions.push_back(
{tensorflow::metadata::v0::AnomalyInfo::
WEIGHTED_FEATURE_LENGTH_MISMATCH,
"Length mismatch between value and weight feature",
absl::StrCat("Mismatch between weight and value feature with ",
kMinWeightLengthDiff, " = ", min_weight_length_diff,
" and ", kMaxWeightLengthDiff, " = ",
max_weight_length_diff, ".")});
}
if (!descriptions.empty()) {
::tensorflow::data_validation::DeprecateWeightedFeature(weighted_feature);
}
return descriptions;
}