Skip to content

Commit

Permalink
output discover sum_E or E
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasbtnfr committed Mar 17, 2023
1 parent 24e4d05 commit 50865d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions skmine/periodic/cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def discover(self, dE_sum=True, chronological_order=True):
start when the cycle starts
length number of occurrences in the event
period inter-occurrence delay
dE shift corrections
sum_E absolute sum of errors
E shift corrections (if dE_sum=False)
cost MDL cost
========== ======================================
Expand Down Expand Up @@ -216,7 +217,8 @@ def to_timedelta(x): return pd.to_timedelta(x, unit='ns')

self.cycles["E"] = self.cycles["E"].apply(lambda x: list(map(to_timedelta, x)))
if dE_sum:
self.cycles["E"] = self.cycles["E"].apply(lambda x: np.sum(np.abs(x)))
self.cycles.rename(columns={"E": "sum_E"}, inplace=True)
self.cycles["sum_E"] = self.cycles["sum_E"].apply(lambda x: np.sum(np.abs(x)))

if chronological_order:
self.cycles.sort_values(by='t0', inplace=True)
Expand Down
2 changes: 1 addition & 1 deletion skmine/periodic/tests/test_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_discover(data):
assert res_discover["pattern"].dtypes.name == "object"
assert res_discover["repetition_major"].dtypes.name == "int64"
assert res_discover["period_major"].dtypes.name == "timedelta64[ns]"
assert res_discover["E"].dtypes.name == "timedelta64[ns]"
assert res_discover["sum_E"].dtypes.name == "timedelta64[ns]"

res_discover = pcm.discover(dE_sum=False)
assert res_discover["E"].dtypes.name == "object"
Expand Down

0 comments on commit 50865d3

Please sign in to comment.