Skip to content

Commit

Permalink
Ensure calculated MI values are non-negative.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 292439679
  • Loading branch information
caveness authored and tfx-copybara committed Jan 30, 2020
1 parent 75e9524 commit 70a08b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Set num_missing and num_examples correctly in the presence of sparse
features.
* Compute weighted feature stats for all weighted features declared in schema.
* Enforce that mutual information is non-negative.
* Depends on `tensorflow-metadata>=0.21.0,<0.22`.
* Depends on `pyarrow>=0.15` (removed the upper bound as it is determined by
`tfx-bsl`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _calculate_mi(self, df: pd.DataFrame, labels: np.ndarray,
for i, (mi, shuffled_mi) in enumerate(
zip(mi_per_feature, shuffled_mi_per_feature)):
result[df.columns[i]] = {
MUTUAL_INFORMATION_KEY: mi,
MUTUAL_INFORMATION_KEY: mi.clip(min=0),
ADJUSTED_MUTUAL_INFORMATION_KEY: mi - shuffled_mi
}
return result
Expand Down

0 comments on commit 70a08b4

Please sign in to comment.