| Index: appengine/findit/crash/loglinear/test/model_test.py
|
| diff --git a/appengine/findit/crash/loglinear/test/model_test.py b/appengine/findit/crash/loglinear/test/model_test.py
|
| index 17d8e6e4b85a3b0a2cf9bb9e235042f119b6f750..408986c6a08a01c2179600efa31106f066ae2c3a 100644
|
| --- a/appengine/findit/crash/loglinear/test/model_test.py
|
| +++ b/appengine/findit/crash/loglinear/test/model_test.py
|
| @@ -7,9 +7,24 @@ import numpy as np
|
|
|
| from crash.loglinear.model import ToFeatureFunction
|
| from crash.loglinear.model import LogLinearModel
|
| +from crash.loglinear.model import UnnormalizedLogLinearModel
|
| from crash.loglinear.test.loglinear_testcase import LoglinearTestCase
|
|
|
|
|
| +class UnnormalizedLogLinearModelTest(LoglinearTestCase):
|
| +
|
| + def testSingleFeatureScore(self):
|
| + """Test that ``SingleFeatureScore`` returns weighted feature score."""
|
| + model = UnnormalizedLogLinearModel(self._feature_function, self._weights,
|
| + self._feature_to_weight, 0.1)
|
| + for feature in self._feature_list:
|
| + feature_value = feature(5)(True)
|
| + self.assertEqual(
|
| + model.SingleFeatureScore(feature_value),
|
| + feature_value.value * self._feature_to_weight.get(feature_value.name,
|
| + 0.))
|
| +
|
| +
|
| class LoglinearTest(LoglinearTestCase):
|
|
|
| def testToFeatureFunction(self):
|
| @@ -34,9 +49,11 @@ class LoglinearTest(LoglinearTestCase):
|
| guard against. At least this test is good for detecting typo-style
|
| errors where we try accessing fields/methods that don't exist.
|
| """
|
| - model = LogLinearModel(self._Y, self._feature_function, self._weights, 0.1)
|
| + model = LogLinearModel(self._Y, self._feature_function, self._weights,
|
| + self._feature_to_weight, 0.1)
|
| model.ClearAllMemos()
|
| - model = LogLinearModel(self._Y, self._feature_function, self._weights)
|
| + model = LogLinearModel(self._Y, self._feature_function, self._weights,
|
| + self._feature_to_weight)
|
| self.assertListEqual(self._weights, model.weights.tolist())
|
| self.assertEqual(math.sqrt(model.quadrance), model.l2)
|
|
|
|
|