Skip to content

Commit

Permalink
Min reg on BB side + cut off for regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder committed Nov 16, 2023
1 parent 3620593 commit c897595
Showing 1 changed file with 66 additions and 13 deletions.
79 changes: 66 additions & 13 deletions varats/varats/data/databases/feature_perf_precision_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,33 @@ def get_matching_event(
return feature_performances


def is_feature_relevant(

Check failure on line 135 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/data/databases/feature_perf_precision_database.py#L135

error: Function is missing a return type annotation [no-untyped-def]
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:135:1: error: Function is missing a return type annotation  [no-untyped-def]

Check failure on line 135 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/data/databases/feature_perf_precision_database.py#L135

error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:135:1: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
old_measurements,
new_measurements,
rel_cut_off: float = 0.01,
abs_cut_off: int = 20
):
"""Check if a feature can be ignored for regression checking as it's time
measurements seem not relevant."""
old_mean = np.mean(old_measurements)
new_mean = np.mean(new_measurements)

if old_mean < abs_cut_off and new_mean < abs_cut_off:
return False

old_rel_cut_off = old_mean * rel_cut_off
abs_mean_diff = abs(old_mean - new_mean)
if abs_mean_diff < old_rel_cut_off:
return False

return True


def precise_pim_regression_check(

Check failure on line 157 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L157 <116>

Missing function or method docstring (missing-function-docstring)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:157:0: C0116: Missing function or method docstring (missing-function-docstring)
baseline_pim: tp.DefaultDict[str, tp.List[int]],
current_pim: tp.DefaultDict[str, tp.List[int]]
current_pim: tp.DefaultDict[str, tp.List[int]],
rel_cut_off: float = 0.01,
abs_cut_off: int = 20
) -> bool:
is_regression = False

Expand All @@ -145,8 +169,11 @@ def precise_pim_regression_check(
continue

new_values = current_pim[feature]
if np.mean(old_values) < 20 and np.mean(new_values) < 20:
# TODO: adapt this to a relative value

# Skip features that seem not to be relevant for regressions testing
if not is_feature_relevant(
old_values, new_values, rel_cut_off, abs_cut_off
):
continue

ttest_res = ttest_ind(old_values, new_values)
Expand All @@ -170,7 +197,9 @@ def precise_pim_regression_check(

def cliffs_delta_pim_regression_check(

Check failure on line 198 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L198 <116>

Missing function or method docstring (missing-function-docstring)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:198:0: C0116: Missing function or method docstring (missing-function-docstring)
baseline_pim: tp.DefaultDict[str, tp.List[int]],
current_pim: tp.DefaultDict[str, tp.List[int]]
current_pim: tp.DefaultDict[str, tp.List[int]],
rel_cut_off: float = 0.01,
abs_cut_off: int = 20
) -> bool:
is_regression = False

Expand All @@ -181,9 +210,11 @@ def cliffs_delta_pim_regression_check(
continue

new_values = current_pim[feature]
# if np.mean(old_values) < 20 and np.mean(new_values) < 20:
# # TODO: adapt this to a relative value
# continue

if not is_feature_relevant(
old_values, new_values, rel_cut_off, abs_cut_off
):
continue

d, res = cliffs_delta(old_values, new_values)

Check warning on line 219 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L219 <612>

Unused variable 'res' (unused-variable)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:219:15: W0612: Unused variable 'res' (unused-variable)

Expand All @@ -207,7 +238,9 @@ def cliffs_delta_pim_regression_check(

def sum_pim_regression_check(

Check failure on line 239 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L239 <116>

Missing function or method docstring (missing-function-docstring)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:239:0: C0116: Missing function or method docstring (missing-function-docstring)
baseline_pim: tp.DefaultDict[str, tp.List[int]],
current_pim: tp.DefaultDict[str, tp.List[int]]
current_pim: tp.DefaultDict[str, tp.List[int]],
rel_cut_off: float = 0.01,

Check warning on line 242 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L242 <613>

Unused argument 'rel_cut_off' (unused-argument)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:242:4: W0613: Unused argument 'rel_cut_off' (unused-argument)
abs_cut_off: int = 20

Check warning on line 243 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L243 <613>

Unused argument 'abs_cut_off' (unused-argument)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:243:4: W0613: Unused argument 'abs_cut_off' (unused-argument)
) -> bool:
# TODO: add some tests

Check warning on line 245 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L245 <511>

TODO: add some tests (fixme)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:245:5: W0511: TODO: add some tests (fixme)
baseline_pim_totals: tp.List[tp.List[int]] = [
Expand Down Expand Up @@ -449,7 +482,7 @@ def get_regressing_config_ids_gt(
"""Computes the baseline data, i.e., the config ids where a regression was
identified."""

gt: tp.Dict[int, bool] = {}
ground_truth: tp.Dict[int, bool] = {}

for config_id in case_study.get_config_ids_for_revision(rev):
report_files = get_processed_revisions_files(
Expand Down Expand Up @@ -477,9 +510,21 @@ def get_regressing_config_ids_gt(
if not new_time:
return None

# TODO: what baseline cutoff to choose?

Check warning on line 513 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L513 <511>

TODO: what baseline cutoff to choose? (fixme)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:513:9: W0511: TODO: what baseline cutoff to choose? (fixme)
# req_diff = np.mean(old_time.measurements_wall_clock_time) * 0.03
req_diff = 0.1
if np.mean(old_time.measurements_wall_clock_time
) == np.mean(new_time.measurements_wall_clock_time):
gt[config_id] = False
ground_truth[config_id] = False
elif abs(
np.mean(old_time.measurements_wall_clock_time) -
np.mean(new_time.measurements_wall_clock_time)
) < req_diff:
# if project_name == "DunePerfRegression":
# print(
# f"No {patch_name=}_{config_id=} -> {old_time.measurements_wall_clock_time=} || {new_time.measurements_wall_clock_time=}"

Check failure on line 525 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L525 <301>

Line too long (143/80) (line-too-long)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:525:0: C0301: Line too long (143/80) (line-too-long)
# )
ground_truth[config_id] = False
else:
# d, res = cliffs_delta(
# old_time.measurements_wall_clock_time,
Expand All @@ -494,11 +539,19 @@ def get_regressing_config_ids_gt(
# if res == "large":
# if d > 0.7 or d < -0.7:
if ttest_res.pvalue < 0.05:
gt[config_id] = True
# if project_name == "DunePerfRegression":
# print(
# f"Reg {patch_name=}_{config_id=} -> {old_time.measurements_wall_clock_time=} || {new_time.measurements_wall_clock_time=}"

Check failure on line 544 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L544 <301>

Line too long (147/80) (line-too-long)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:544:0: C0301: Line too long (147/80) (line-too-long)
# )
ground_truth[config_id] = True
else:
gt[config_id] = False
# if project_name == "DunePerfRegression":
# print(
# f"No {patch_name=}_{config_id=} -> {old_time.measurements_wall_clock_time=} || {new_time.measurements_wall_clock_time=}"

Check failure on line 550 in varats/varats/data/databases/feature_perf_precision_database.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/databases/feature_perf_precision_database.py#L550 <301>

Line too long (147/80) (line-too-long)
Raw output
varats/varats/data/databases/feature_perf_precision_database.py:550:0: C0301: Line too long (147/80) (line-too-long)
# )
ground_truth[config_id] = False

return gt
return ground_truth


def map_to_positive_config_ids(reg_dict: tp.Dict[int, bool]) -> tp.List[int]:
Expand Down

0 comments on commit c897595

Please sign in to comment.