Пример #1
0
# -*- coding: utf-8 -*-

from pmdarima.datasets import load_lynx
from pmdarima.arima import ARIMA

from unittest.mock import patch
import pytest

lynx = load_lynx()


class MockMPLFigure:
    def __init__(self, fig, figsize):
        self.fig = fig
        self.figsize = figsize
        self.subplots = []

    def add_subplot(self, *args):
        ax = MockMPLAxis(*args)
        self.subplots.append(ax)
        return ax


class MockMPLAxis:
    def __init__(self, *args):
        pass

    def hist(self, *args, **kwargs):
        pass

    def hlines(self, *args, **kwargs):
Пример #2
0
# x = [ -6.,  -2.,   7.,  25.]
(4-10), (2-4), (9-2), (34-9) 
x
# 2
x_lag = x[1:]  # second lag
x_lag
x[:-1]
x = x_lag - x[:-1]
# x = [ 4.,  9., 18.]
(-2 - (-6)), (7 - (-2)), (18-7)  #check this

#%%% Stationary
import pmdarima as pm
from pmdarima import datasets

y = datasets.load_lynx()
pm.plot_acf(y)

from pmdarima.arima.stationarity import ADFTest

# Test whether we should difference at the alpha=0.05
# significance level
adf_test = ADFTest(alpha=0.05)
p_val, should_diff = adf_test.should_diff(y)  # (0.01, False)
p_val

#The verdict, per the ADF test, is that we should not difference. Pmdarima also provides a more handy interface for estimating your d parameter more directly. This is the preferred public method for accessing tests of stationarity:
from pmdarima.arima.utils import ndiffs

# Estimate the number of differences using an ADF test:
n_adf = ndiffs(y, test='adf')  # -> 0
.. raw:: html

   <br/>
"""
print(__doc__)

# Author: Taylor Smith <*****@*****.**>

from pmdarima.datasets import load_lynx
from pmdarima.arima import auto_arima
import matplotlib.pyplot as plt
import numpy as np

# #############################################################################
# Load the data and split it into separate pieces
data = load_lynx()
train, test = data[:100], data[100:]

# #############################################################################
# Fit with some validation (cv) samples
arima = auto_arima(train,
                   start_p=1,
                   start_q=1,
                   d=0,
                   max_p=5,
                   max_q=5,
                   out_of_sample_size=10,
                   suppress_warnings=True,
                   stepwise=True,
                   error_action='ignore')
Пример #4
0
# %%
modelo_busca2.fit(cresc_p1['Preco'].values)

# %%
valores_preditos2 = modelo_busca2.predict(n_periods=10)

# %%
plt.plot(valores_preditos2)
plt.plot(np.linspace(0, 9, 10), cresc_p2['Preco'])

# %%
from pmdarima.datasets import load_lynx

# %%
dado_lynx = load_lynx()

# %%
dado_lynx.shape

# %%
from pmdarima import model_selection

# %%
treino, teste = model_selection.train_test_split(dado_lynx, train_size=100)

# %%
teste1 = teste[:10]
teste2 = teste[10:]

# %%