Add wrappers for R's "arima" and "ets" functions

This commit is contained in:
Alexander Hess 2021-01-11 20:17:00 +01:00
commit 64482f48d0
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
10 changed files with 441 additions and 88 deletions

View file

@ -91,9 +91,6 @@ def stl( # noqa:C901,WPS210,WPS211,WPS231
Raises:
ValueError: some argument does not adhere to the specifications above
"""
# Re-seed R every time the process does something.
robjects.r('set.seed(42)')
# Validate all arguments and set default values.
if time_series.isnull().any():
@ -157,6 +154,13 @@ def stl( # noqa:C901,WPS210,WPS211,WPS231
else:
robust = False
# Initialize R only if necessary as it is tested only in nox's
# "ci-tests-slow" session and "ci-tests-fast" should not fail.
from urban_meal_delivery import init_r # noqa:F401,WPS433
# Re-seed R every time it is used to ensure reproducibility.
robjects.r('set.seed(42)')
# Call the STL function in R.
ts = robjects.r['ts'](pandas2ri.py2rpy(time_series), frequency=frequency)
result = robjects.r['stl'](