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

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

Issue 2617273002: [Predator] Move ``SingleFeatureScore`` to LLM. (Closed)
Patch Set: Update doc strs. 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
Index: appengine/findit/crash/loglinear/feature.py
diff --git a/appengine/findit/crash/loglinear/feature.py b/appengine/findit/crash/loglinear/feature.py
index 20cda371f4b9ab7c92d40f972f748ebddb8a1f76..b0ff22a18795163d529bfd5ba016c166a9413d8f 100644
--- a/appengine/findit/crash/loglinear/feature.py
+++ b/appengine/findit/crash/loglinear/feature.py
@@ -138,3 +138,26 @@ class Feature(object):
information and decide the cuplrit based on all the evidence together.
"""
raise NotImplementedError()
+
+
+class FeatureFunction(object):
+ """Given a dict of scalar-valued functions, return an dict-valued function.
+
+ Properties:
+ fs (list of functions): A collection of curried functions ``X -> Y -> A``.
wrengr 2017/01/11 20:38:30 Type of ``fs`` should be an iterable of ``Feature`
Sharu Jiang 2017/01/12 01:41:38 Acknowledged.
+ That is, given a particular ``x`` they return a function ``Y -> A``. N.B.
+ each function should have a name property.
+ """
+ def __init__(self, fs):
+ self._fs = fs
+
+ def __call__(self, x):
+ """Fuction mapping ``X -> Y -> dict(A.name to A).
+
+ Returns:
+ A function ``X -> Y -> dict(A.name to A)`` where for all ``x``, ``y``, and
+ for a feature f in fs, we have
+ ``ToFeatureFunction(fs)(x)(y)[f.name] == f(x)(y)``.
wrengr 2017/01/11 20:38:30 the name "ToFeatureFunction"is no longer used anyw
Sharu Jiang 2017/01/12 01:41:38 Done.
+ """
+ name_to_fx = {f.name: f(x) for f in self._fs}
+ return lambda y: {name: fx(y) for name, fx in name_to_fx.iteritems()}

Powered by Google App Engine
This is Rietveld 408576698