Skip to content

Commit

Permalink
no changes change
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
Auto User committed Sep 4, 2024
1 parent 666e714 commit 8bd9a66
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pkg/algorithms/cmr/cmr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""CMR Algorithm"""
"""CMR - Comparing Mean Responses Algorithm"""

# pylint: disable = line-too-long
from typing import List
Expand Down Expand Up @@ -31,6 +31,10 @@ def _analyze(self):
self.dataframe["timestamp"] = pd.to_datetime(self.dataframe["timestamp"])
self.dataframe["timestamp"] = self.dataframe["timestamp"].astype(int) // 10**9

if len(self.dataframe.index) == 1:
series= self.setup_series()
series.data = self.dataframe
return series, {}
# if larger than 2 rows, need to get the mean of 0 through -2
self.dataframe = self.combine_and_average_runs( self.dataframe)

Expand Down Expand Up @@ -58,8 +62,8 @@ def run_cmr(self, tolerancy: int, dataframe_list: pd.DataFrame):
change_points_by_metric={ k:[] for k in metric_columns }
max_date_time = pd.Timestamp.max.to_pydatetime()
max_time = max_date_time.timestamp()
difference = ["difference", max_time]
pass_fail_list = ["Pass/Fail", max_time]
# difference = ["difference", max_time]
# pass_fail_list = ["Pass/Fail", max_time]
for column in metric_columns:
pct_change_result = dataframe_list[column].pct_change()
single_pct_diff = round(pct_change_result.iloc[[-1]].values[0] * 100)
Expand All @@ -69,7 +73,7 @@ def run_cmr(self, tolerancy: int, dataframe_list: pd.DataFrame):

change_point = ChangePoint(metric=column,
index=1,
time=difference[1],
time=max_time,
stats=ComparativeStats(
mean_1=dataframe_list[column][0],
mean_2=dataframe_list[column][1],
Expand All @@ -78,8 +82,8 @@ def run_cmr(self, tolerancy: int, dataframe_list: pd.DataFrame):
pvalue=1
))
change_points_by_metric[column].append(change_point)
difference.append(single_pct_diff)
pass_fail_list.append(pass_fail)
# difference.append(single_pct_diff)
# pass_fail_list.append(pass_fail)
# difference.append("none")
# pass_fail_list.append("none")
# dataframe_list.loc[len(dataframe_list.index)] = difference
Expand Down Expand Up @@ -111,10 +115,11 @@ def combine_and_average_runs(self, dataFrame: pd.DataFrame):

if isinstance(dF.loc[0, column], (numpy.float64, numpy.int64)):
mean = dF[column].mean()
data2[column] = [mean]
else:
column_list = dF[column].tolist()
mean = ','.join(column_list)
data2[column] = [mean]
non_numeric_joined_list = ','.join(column_list)
data2[column] = [non_numeric_joined_list]
i += 1
df2 = pd.DataFrame(data2)

Expand Down

0 comments on commit 8bd9a66

Please sign in to comment.