Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert fp32 datasets to fp64 in ARIMA and AutoARIMA + update notebook to avoid deprecation warnings with positional parameters #4195

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python/cuml/tsa/arima.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ from raft.common.handle cimport handle_t
from cuml.tsa.batched_lbfgs import batched_fmin_lbfgs_b
import cuml.common.logger as logger
from cuml.common import has_scipy
from cuml.common.input_utils import determine_array_dtype
from cuml.common.input_utils import input_to_cuml_array
from cuml.common.input_utils import input_to_host_array
from cuml.internals import _deprecate_pos_args
import warnings


cdef extern from "cuml/tsa/arima_common.h" namespace "ML":
Expand Down Expand Up @@ -209,6 +211,9 @@ class ARIMA(Base):
the estimator. If None, it'll inherit the output type set at the
module level, `cuml.global_settings.output_type`.
See :ref:`output-data-type-configuration` for more info.
convert_dtype : boolean
When set to True, the model will automatically convert the inputs to
np.float64.

Attributes
----------
Expand Down Expand Up @@ -311,7 +316,8 @@ class ARIMA(Base):
simple_differencing=True,
handle=None,
verbose=False,
output_type=None):
output_type=None,
convert_dtype=True):

if not has_scipy():
raise RuntimeError("Scipy is needed to run cuML's ARIMA estimator."
Expand Down Expand Up @@ -346,7 +352,9 @@ class ARIMA(Base):

# Endogenous variable. Float64 only for now.
self.d_y, self.n_obs, self.batch_size, self.dtype \
= input_to_cuml_array(endog, check_dtype=np.float64)
= input_to_cuml_array(
endog, check_dtype=np.float64,
convert_to_dtype=(np.float64 if convert_dtype else None))

if self.n_obs < d + s * D + 1:
raise ValueError("ERROR: Number of observations too small for the"
Expand Down
12 changes: 10 additions & 2 deletions python/cuml/tsa/auto_arima.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ from raft.common.handle cimport handle_t
from raft.common.handle import Handle
from cuml.common import input_to_cuml_array
from cuml.common import using_output_type
from cuml.common.input_utils import determine_array_dtype
from cuml.tsa.arima import ARIMA
from cuml.tsa.seasonality import seas_test
from cuml.tsa.stationarity import kpss_test
import warnings


# TODO:
Expand Down Expand Up @@ -145,6 +147,9 @@ class AutoARIMA(Base):
the estimator. If None, it'll inherit the output type set at the
module level, `cuml.global_settings.output_type`.
See :ref:`output-data-type-configuration` for more info.
convert_dtype : boolean
When set to True, the model will automatically convert the inputs to
np.float64.

Notes
-----
Expand Down Expand Up @@ -186,7 +191,8 @@ class AutoARIMA(Base):
handle=None,
simple_differencing=True,
verbose=False,
output_type=None):
output_type=None,
convert_dtype=True):
# Initialize base class
super().__init__(handle=handle,
verbose=verbose,
Expand All @@ -195,7 +201,9 @@ class AutoARIMA(Base):

# Get device array. Float64 only for now.
self.d_y, self.n_obs, self.batch_size, self.dtype \
= input_to_cuml_array(endog, check_dtype=np.float64)
= input_to_cuml_array(
endog, check_dtype=np.float64,
convert_to_dtype=(np.float64 if convert_dtype else None))

self.simple_differencing = simple_differencing

Expand Down