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

Function relative

pattern/vector/__init__.py:674–681  ·  view source on GitHub ↗

Returns the vector with feature weights normalized so that their sum is 1.0 (in-place).

(v)

Source from the content-addressed store, hash-verified

672_features = features
673
674def relative(v):
675 """ Returns the vector with feature weights normalized so that their sum is 1.0 (in-place).
676 """
677 n = float(sum(v.itervalues())) or 1.0
678 s = dict.__setitem__
679 for f in v: # Modified in-place.
680 s(v, f, v[f] / n)
681 return v
682
683rel = relative
684

Callers

nothing calls this directly

Calls 3

sumFunction · 0.85
sFunction · 0.85
itervaluesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…