MCPcopy Index your code
hub / github.com/clips/pattern / l2_norm

Method l2_norm

pattern/vector/__init__.py:632–639  ·  view source on GitHub ↗

Yields the Frobenius matrix norm (cached). n = the square root of the sum of the absolute squares of the values. The matrix norm is used to normalize (0.0-1.0) cosine similarity between documents.

(self)

Source from the content-addressed store, hash-verified

630
631 @property
632 def l2_norm(self):
633 """ Yields the Frobenius matrix norm (cached).
634 n = the square root of the sum of the absolute squares of the values.
635 The matrix norm is used to normalize (0.0-1.0) cosine similarity between documents.
636 """
637 if self._norm is None:
638 self._norm = sum(w * w for w in self.itervalues()) ** 0.5
639 return self._norm
640
641 norm = l2 = L2 = L2norm = l2norm = L2_norm = l2_norm
642

Callers

nothing calls this directly

Calls 2

sumFunction · 0.85
itervaluesMethod · 0.80

Tested by

no test coverage detected