7b5306a5d69cbf68a15de0a2ad1f52327936d3e1,pmdarima/arima/arima.py,ARIMA,fit,#ARIMA#Any#Any#,247

Before Change


        if self.suppress_warnings:
            with warnings.catch_warnings(record=False):
                warnings.simplefilter("ignore")
                fit, self.arima_res_ = _fit_wrapper()
        else:
            fit, self.arima_res_ = _fit_wrapper()

        // Set df_model attribute for SARIMAXResults object
        sm_compat.bind_df_model(fit, self.arima_res_)

        // if the model is fit with an exogenous array, it must
        // be predicted with one as well.
        self.fit_with_exog_ = exogenous is not None

        // now make a forecast if we"re validating to compute the
        // out-of-sample score
        if cv_samples is not None:
            // get the predictions (use self.predict, which calls forecast
            // from statsmodels internally)
            pred = self.predict(n_periods=cv, exogenous=cv_exog)
            self.oob_ = scoring(cv_samples, pred, **self.scoring_args)

            // If we compute out of sample scores, we have to now update the
            // observed time points so future forecasts originate from the end
            // of our y vec
            self.add_new_observations(cv_samples, cv_exog)
        else:
            self.oob_ = np.nan

        // Save nobs since we might change it later if using OOB
        self.nobs_ = y.shape[0]

        // As of version 0.7.2, start saving the version with the model so
        // we can track changes over time.

After Change


        self.pkg_version_ = pmdarima.__version__
        return self

    def fit(self, y, exogenous=None, **fit_args):
        Fit an ARIMA to a vector, ``y``, of observations with an
        optional matrix of ``exogenous`` variables.

        Parameters
        ----------
        y : array-like or iterable, shape=(n_samples,)
            The time-series to which to fit the ``ARIMA`` estimator. This may
            either be a Pandas ``Series`` object (statsmodels can internally
            use the dates in the index), or a numpy array. This should be a
            one-dimensional array of floats, and should not contain any
            ``np.nan`` or ``np.inf`` values.

        exogenous : array-like, shape=[n_obs, n_vars], optional (default=None)
            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 = c1d(check_array(y, ensure_2d=False, force_all_finite=False,
                            copy=True, dtype=DTYPE))  // type: np.ndarray
        n_samples = y.shape[0]

        // if exog was included, check the array...
        if exogenous is not None:
            exogenous = check_array(exogenous, ensure_2d=True,
                                    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 /ቸ
        cv_samples = None
        cv_exog = None
        if cv:
            cv_samples = y[-cv:]
            y = y[:-cv]

            // This also means we have to address the exogenous matrix
            if exogenous is not None:
                cv_exog = exogenous[-cv:, :]
                exogenous = exogenous[:-cv, :]

        // Internal call
        self._fit(y, exogenous, **fit_args)

        // now make a forecast if we"re validating to compute the
        // out-of-sample score
        if cv_samples is not None:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: tgsmith61591/pmdarima
Commit Name: 7b5306a5d69cbf68a15de0a2ad1f52327936d3e1
Time: 2019-03-26
Author: tgsmith61591@gmail.com
File Name: pmdarima/arima/arima.py
Class Name: ARIMA
Method Name: fit


Project Name: tgsmith61591/pmdarima
Commit Name: 7b5306a5d69cbf68a15de0a2ad1f52327936d3e1
Time: 2019-03-26
Author: tgsmith61591@gmail.com
File Name: pmdarima/arima/arima.py
Class Name: ARIMA
Method Name: fit


Project Name: rasbt/mlxtend
Commit Name: 62fc64ead3faa5a783d2c7e0836ebaf06c1d7374
Time: 2016-06-26
Author: mail@sebastianraschka.com
File Name: mlxtend/feature_extraction/rbf_kernel_pca.py
Class Name: RBFKernelPCA
Method Name: fit


Project Name: metric-learn/metric-learn
Commit Name: 23d07466961fa7a72aa8692bc42d6d569b80c5c9
Time: 2019-01-02
Author: 31916524+wdevazelhes@users.noreply.github.com
File Name: metric_learn/sdml.py
Class Name: SDML
Method Name: fit