Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: appengine/findit/crash/loglinear/changelist_classifier.py

Issue 2617273002: [Predator] Move ``SingleFeatureScore`` to LLM. (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/findit/crash/loglinear/model.py » ('j') | appengine/findit/crash/loglinear/model.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/loglinear/changelist_classifier.py
diff --git a/appengine/findit/crash/loglinear/changelist_classifier.py b/appengine/findit/crash/loglinear/changelist_classifier.py
index f25430adb419f556fe9994aa53b352e9a5f84df1..01ece27024cd002cc479f8e25216f29675cef7ed 100644
--- a/appengine/findit/crash/loglinear/changelist_classifier.py
+++ b/appengine/findit/crash/loglinear/changelist_classifier.py
@@ -49,10 +49,8 @@ class LogLinearChangelistClassifier(object):
weights['MinDistance'],
]
- self._model = UnnormalizedLogLinearModel(feature_function, weight_list)
-
- # TODO(crbug.com/674262): remove the need for storing these weights.
- self._weights = weights
+ self._model = UnnormalizedLogLinearModel(feature_function,
+ weight_list, weights)
wrengr 2017/01/09 19:31:51 we shouldn't have to pass both the weight dict and
# TODO(crbug.com/673964): something better for detecting "close to log(0)".
def _LogZeroish(self, x):
@@ -72,20 +70,6 @@ class LogLinearChangelistClassifier(object):
"""
return x < 0 and math.isinf(x)
- def _SingleFeatureScore(self, feature_value):
- """Returns the score (aka weighted value) of a ``FeatureValue``.
-
- This function assumes the report's stacktrace has already had any necessary
- preprocessing (like filtering or truncating) applied.
-
- Args:
- feature_value (FeatureValue): the feature value to check.
-
- Returns:
- The score of the feature value.
- """
- return feature_value.value * self._weights.get(feature_value.name, 0.)
-
def __call__(self, report):
"""Finds changelists suspected of being responsible for the crash report.
@@ -188,7 +172,7 @@ class LogLinearChangelistClassifier(object):
"""
formatted_reasons = []
for feature in features:
- feature_score = self._SingleFeatureScore(feature)
+ feature_score = self._model.SingleFeatureScore(feature)
if self._LogZeroish(feature_score): # pragma: no cover
logging.debug('Discarding reasons from feature %s'
' because it has zero probability' % feature.name)
@@ -216,7 +200,8 @@ class LogLinearChangelistClassifier(object):
"""
all_changed_files = {}
for feature in features:
- if self._LogZeroish(self._SingleFeatureScore(feature)): # pragma: no cover
+ if self._LogZeroish(
+ self._model.SingleFeatureScore(feature)): # pragma: no cover
logging.debug('Discarding changed files from feature %s'
' because it has zero probability' % feature.name)
continue
« no previous file with comments | « no previous file | appengine/findit/crash/loglinear/model.py » ('j') | appengine/findit/crash/loglinear/model.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698