How to use the pmdarima.compat.numpy.DTYPE function in pmdarima

To help you get started, we’ve selected a few pmdarima examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alkaline-ml / pmdarima / pmdarima / preprocessing / base.py View on Github external
def _check_y_exog(y, exog):
        """Validate input"""
        # Do not force finite, since a transformer's goal may be imputation.
        if y is not None:
            y = check_endog(y, dtype=DTYPE, copy=True, force_all_finite=False)

        if exog is not None:
            exog = check_exog(
                exog, dtype=DTYPE, copy=True, force_all_finite=False)
        return y, exog
github alkaline-ml / pmdarima / pmdarima / arima / auto.py View on Github external
if m < 1:
        raise ValueError('m must be a positive integer (> 0)')

    # check on n_iter
    if random and n_fits < 0:
        raise ValueError('n_iter must be a positive integer '
                         'for a random search')

    # validate error action
    actions = {'warn', 'raise', 'ignore', None}
    if error_action not in actions:
        raise ValueError('error_action must be one of %r, but got %r'
                         % (actions, error_action))

    # copy array
    y = check_endog(y, dtype=DTYPE)
    n_samples = y.shape[0]

    sarimax_kwargs = {} if not sarimax_kwargs else sarimax_kwargs

    # check for constant data
    if is_constant(y):
        warnings.warn('Input time-series is completely constant; '
                      'returning a (0, 0, 0) ARMA.')
        return _return_wrapper(_post_ppc_arima(
            solvers._fit_arima(
                y, xreg=exogenous, order=(0, 0, 0),
                seasonal_order=(0, 0, 0, 0),
                start_params=start_params, trend=trend, method=method,
                maxiter=maxiter, fit_params=fit_args,
                suppress_warnings=suppress_warnings, trace=trace,
                error_action=error_action, scoring=scoring,
github alkaline-ml / pmdarima / pmdarima / arima / arima.py View on Github external
def _check_exog(self, exogenous):
        # if we fit with exog, make sure one was passed, or else fail out:
        if self.fit_with_exog_:
            if exogenous is None:
                raise ValueError('When an ARIMA is fit with an exogenous '
                                 'array, it must also be provided one for '
                                 'predicting or updating observations.')
            else:
                return check_exog(
                    exogenous, force_all_finite=True, dtype=DTYPE)
        return None
github alkaline-ml / pmdarima / pmdarima / arima / arima.py View on Github external
An optional 2-d array of exogenous variables. If provided, these
            variables are used as additional features in the regression
            operation. This should not include a constant or trend. Note that
            if an ``ARIMA`` is fit on exogenous features, it must be provided
            exogenous features for making predictions.

        **fit_args : dict or kwargs
            Any keyword arguments to pass to the statsmodels ARIMA fit.
        """
        y = check_endog(y, dtype=DTYPE)
        n_samples = y.shape[0]

        # if exog was included, check the array...
        if exogenous is not None:
            exogenous = check_exog(exogenous, force_all_finite=False,
                                   copy=False, dtype=DTYPE)

        # determine the CV args, if any
        cv = self.out_of_sample_size
        scoring = get_callable(self.scoring, VALID_SCORING)

        # don't allow negative, don't allow > n_samples
        cv = max(cv, 0)

        # if cv is too big, raise
        if cv >= n_samples:
            raise ValueError("out-of-sample size must be less than number "
                             "of samples!")

        # If we want to get a score on the out-of-sample, we need to trim
        # down the size of our y vec for fitting. Addressed due to Issue #28
        cv_samples = None
github alkaline-ml / pmdarima / pmdarima / datasets / _base.py View on Github external
def fetch_from_web_or_disk(url, key, cache=True, dtype=DTYPE):
    """Fetch a dataset from the web, and save it in the pmdarima cache"""
    if key in _cache:
        return _cache[key]

    disk_cache_path = get_data_cache_path()

    # don't ask, just tell. avoid race conditions
    os.makedirs(disk_cache_path, exist_ok=True)

    # See if it's already there
    data_path = join(disk_cache_path, key + '.csv.gz')
    if os.path.exists(data_path):
        rslt = np.loadtxt(data_path).ravel()

    else:
        r = None
github alkaline-ml / pmdarima / pmdarima / preprocessing / base.py View on Github external
def _check_y_exog(y, exog):
        """Validate input"""
        # Do not force finite, since a transformer's goal may be imputation.
        if y is not None:
            y = check_endog(y, dtype=DTYPE, copy=True, force_all_finite=False)

        if exog is not None:
            exog = check_exog(
                exog, dtype=DTYPE, copy=True, force_all_finite=False)
        return y, exog