Skip to content

Commit

Permalink
Improve overall summary
Browse files Browse the repository at this point in the history
Fix #107
  • Loading branch information
Johannes Bechberger committed Aug 14, 2020
1 parent e6413e5 commit 6e757e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
18 changes: 9 additions & 9 deletions temci/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,19 @@ def _full_single_property_comp_table(self, property: str = None) -> '_Table':
<p>Using the more widely known arithmetic mean would be like
<a href='http://ece.uprm.edu/~nayda/Courses/Icom6115F06/Papers/paper4.pdf?origin=publication_detail'>
lying</a>.</p>
<p>The geometric standard deviation is <b>%s</b></p>.
<p>The geometric standard deviation is <b>%s</b></p>
""" % self._percent_format.format(pair.first_rel_to_second_std())
rel_diff = fnumber(pair.first_rel_to_second(), rel_deviation=pair.first_rel_to_second_std() - 1, is_percent=True)
popover.trigger = "hover click"
else:
pair = pair[property]
popover.content="""Left mean relative to the right mean:
\\begin{align}
& \\frac{\\overline{\\text{left[%s]}}}{\\overline{\\text{right[%s]}}} \\\\
&= \\frac{%5.4f}{%5.4f}
\\end{align}
<p>The maximum standard deviation of both benchmarks relative to the mean of the right one is <b>%s</b>.</p>
""" % (property, property, pair.first.mean(), pair.second.mean(),
popover.content = """Left mean relative to the right mean:
\\begin{{align}}
& \\frac{{\\overline{{\\text{{left[{}]}}}}}}{{\\overline{{\\text{{right[{}]}}}}}} \\\\
&= \\frac{{{:5.4f}}}{{{:5.4f}}}
\\end{{align}}
<p>The maximum standard deviation of both benchmarks relative to the mean of the right one is <b>{}</b>.</p>
""".format(property, property, pair.first.mean(), pair.second.mean(),
self._percent_format.format(pair.max_std_dev() / pair.second.mean()))
rel_diff = FNumber(pair.first_rel_to_second(), rel_deviation=pair.max_std_dev() / pair.second.mean(), is_percent=True)
cell = _Cell(self, content=str(rel_diff), popover=popover, color_class_obj=pair, show_click_on_info=True)
Expand Down Expand Up @@ -895,7 +895,7 @@ def header_popover_func(elem, index: int, is_header_row: bool):
Using the more widely known would be like
<a href='http://ece.uprm.edu/~nayda/Courses/Icom6115F06/Papers/paper4.pdf?origin=publication_detail'>
lying</a>.
""", trigger="hover click"), first=obj.first, second=obj.second, rel_diff=obj.first_rel_to_second(),
""", trigger="hover click"), first=obj.first, second=obj.second, rel_diff=self._format_float(obj.first_rel_to_second()),
std=self._format_float(obj.first_rel_to_second_std()))
return html

Expand Down
20 changes: 14 additions & 6 deletions temci/report/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class StatWarning(StatMessage):

@classmethod
def overridden(cls, value: t.Union[int, float]) -> bool:
return any(k.check_value(value) for k in cls.__subclasses__())
return any(not k.check_value(value) for k in cls.__subclasses__())


class StatError(StatWarning, StatMessage):
""" A message that signals a possible warning that is probably severe """
Expand All @@ -198,7 +199,7 @@ class StatError(StatWarning, StatMessage):
class StdDeviationToHighWarning(StatWarning):
""" A warning about a too high standard deviation. """

message = "The standard deviation per mean of {props} is too high. It should be <= {b_val}."
message = "The standard deviation per mean of {props} is too high. It should be {b_val}."
hint = "With the exec run driver you can probably use a preset. " \
"Also consider to increase the number of measured runs."
border_value = 0.01
Expand Down Expand Up @@ -755,7 +756,7 @@ def _get_stat_messages(self) -> t.List[StatMessage]:
NotEnoughObservationsWarning.create_if_valid(self, self.property, self.observations()),
NotEnoughObservationsError.create_if_valid(self, self.property, self.observations())
]
return msgs
return [msg for msg in msgs if msg is not None]

def mean(self) -> float:
""" Mean value of the measurements """
Expand Down Expand Up @@ -971,17 +972,20 @@ def _get_stat_messages(self) -> t.List[StatMessage]:

def first_rel_to_second(self) -> float:
"""
Calculates the geometric mean of the first means relative to the second means.
Calculates the geometric mean of the first means relative to the second means. Ignores NaNs in calculating
the geometric mean.
See http://www.cse.unsw.edu.au/~cs9242/15/papers/Fleming_Wallace_86.pdf
"""
return st.gmean([x.first_rel_to_second() for x in self.properties.values()])
return st.gmean([v for v in (x.first_rel_to_second() for x in self.properties.values()) if not math.isnan(v)])

def first_rel_to_second_std(self) -> float:
"""
Calculates the geometric standard deviation for the first_rel_to_second method.
Ignores NaNs in calculating the geometric std.
"""
return util.geom_std([x.first_rel_to_second() for x in self.properties.values()])
return util.geom_std([v for v in [x.first_rel_to_second() for x in self.properties.values()] if not math.isnan(v)])

def swap(self) -> 'TestedPair':
"""
Expand Down Expand Up @@ -1220,7 +1224,11 @@ def mean_diff_per_mean(self) -> float:
def first_rel_to_second(self) -> float:
"""
Calculates the mean of the first relative to the mean of the second (mean(first) / mean(second)).
Returns 1 if both means are equal, regardless of their values.
"""
if self.first.mean() == self.second.mean():
return 1
return self.first.mean() / self.second.mean()

def mean_diff_per_dev(self) -> float:
Expand Down

0 comments on commit 6e757e0

Please sign in to comment.