vp.features.ewma
Gap-aware EWMA with resets (catalog/ewma.viv).
Part of the distribution vipyr; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr.
Signature
vp.features.ewma(df=None, n=500, half_life='1D') Parameters
- df : pandas.DataFrame, default
None - The event table, rows in any order; None makes a synthetic one of n rows.
- n : int, default
500 - Rows of the synthetic table when df is None. Range: >= 1.
- half_life : str, default
'1D'
Returns
A frozen EwmaResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- frame : pandas.DataFrame
- The features, one row per input row, in the input's order and index: .
Raises
- TypeError
- An argument of the wrong type, or an unknown keyword.
- vipyr.VivBuildError
- An ImportError: no C compiler, or the program's C does not build.
Examples
import vipyr as vp
r = vp.features.ewma() # a synthetic table; pass df= for yours
print(r.frame.head())
assert r.check() ewma ewm_weight
0 NaN 0.000000
1 20.605000 0.656570
2 32.544731 1.067101
3 52.183958 1.867795
4 50.819510 0.797453Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Reference
- catalog.ewma_reference: a pandas groupby().apply() with a Python loop per row, equal to 10−13 relative; vipyr.check_point_in_time: no feature reads a row after its own time
Source
- Viv: catalog/ewma.viv
- Viv: catalog/catalog.py
- The defs it reaches and the calls between them: map of the code