def relative(v):
    n = float(sum(v.values())) or 1.0
    s = dict.__setitem__
    for f in v: # Modified in-place.
        s(v, f, v[f] / n)
    return v
Returns the vector with feature weights normalized so that their sum is 1.0 (in-place).
dataset/ETHPy150Open clips/pattern/pattern/vector/__init__.py/relative