Skip to content

Commit 96dd7d1

Browse files
committed
feat: entropy profile
1 parent 7760047 commit 96dd7d1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

popmon/analysis/profiling/hist_profiler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def _profile_1d_histogram(self, name, hist):
102102

103103
# difference between htype=None and htype="all" are arguments (bin labels vs hist)
104104
profile.update(Profiles.run([hist], dim=1, htype=None))
105+
profile.update(Profiles.run([hist], dim=-1, htype=None))
105106

106107
# postprocessing TS
107108
if is_ts:
@@ -110,9 +111,6 @@ def _profile_1d_histogram(self, name, hist):
110111
for k, v in profile.items()
111112
}
112113

113-
# postprocessing sum
114-
profile["count"] = profile["filled"] + profile["nan"]
115-
116114
return profile
117115

118116
def _profile_nd_histogram(self, name, hist, dim):

popmon/analysis/profiling/profiles.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ def profile_count(hist):
130130
return int(sum_entries(hist))
131131

132132

133+
@Profiles.register(
134+
key="entropy",
135+
description="Entropy in nats",
136+
dim=-1,
137+
htype=None,
138+
)
139+
def profile_entropy(hist):
140+
h = hist.bin_entries()
141+
h = h / h.sum()
142+
return -(h * np.ma.log(h)).sum()
143+
144+
133145
@Profiles.register(
134146
key="filled",
135147
description="Number of non-missing entries (non-NaN)",

0 commit comments

Comments
 (0)