'Library errors with pmdarima and statsmodels

I have a problem with some libraries for time series. In particular first error rise when i import this library

from pmdarima.arima import auto_arima

As suggested in another post I use the command !pip install pmdarima to solve this problem. But then I have to restart the runtime otherwise I can't compile and I also have to re-use the command every time I open my colab/jupyter notebook.

So my first question is related to this issue. Is there any solution to avoid this process every time?

The second problem is connected to the first one, because I import other libraries that are:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
import datetime as datetime
from pmdarima.arima import auto_arima
from sklearn.metrics import mean_squared_error
from statsmodels.tsa.seasonal import seasonal_decompose
from dateutil.parser import parse
from statsmodels.tsa.stattools import adfuller
from pandas.plotting import autocorrelation_plot
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
from statsmodels.tsa.arima_model import ARIMA
from pmdarima import auto_arima
from statsmodels.tsa.statespace.sarimax import SARIMAX

According to the fact that I know how to solve the first problem, then I have several lines of code related to the time series prediction and when I have to use a function where I'm using the ARIMA model:

def Predict(train,test,Order1,Order2,Order3,parForecastLenght=31):
   
    # Build Model
    model = ARIMA(train.astype("float32"), order=(Order1, Order2, Order3))  
    fitted = model.fit(disp=-1)  

    # Forecast
    fc, se, conf = fitted.forecast(parForecastLenght, alpha=0.05)  

    # Make as pandas series
    fc_series = pd.Series(fc, index=test.iloc[0:parForecastLenght].index)
    lower_series = pd.Series(conf[:, 0], index=test.iloc[0:parForecastLenght].index)
    upper_series = pd.Series(conf[:, 1], index=test.iloc[0:parForecastLenght].index)

    # Plot
    plt.figure(figsize=(12,5), dpi=100)
    plt.plot(train, label='training')
    plt.plot(test, label='actual')
    plt.plot(fc_series, label='forecast')
    plt.fill_between(lower_series.index, lower_series, upper_series, color='k', alpha=.15)
    plt.title('Forecast vs Actuals')
    plt.legend(loc='upper left', fontsize=8)
    plt.show()
    return fc_series

when I use try to execute this code:

model1 = Predict(train_Att_Assunzioni,test_Att_Assunzioni,0,0,0,30)

appears this kind of error:

NotImplementedError: 
statsmodels.tsa.arima_model.ARMA and statsmodels.tsa.arima_model.ARIMA have
been removed in favor of statsmodels.tsa.arima.model.ARIMA (note the .
between arima and model) and statsmodels.tsa.SARIMAX.

statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework and
is both well tested and maintained. It also offers alternative specialized
parameter estimators.

So again I check posts on stackoverflow, I tried to implement the suggested operations, but nothing seems to work except for the substitution of the library from from statsmodels.tsa.arima_model import ARIMA to from statsmodels.tsa.arima.model import ARIMA but then the first problem rise again.

N.B. I tried to install statsmodels, pmadarima, I tried to change my work enviroment from colab to jupyter lab, but nothing



Solution 1:[1]

You can loop on an array with the map function. If you want to display the row for instance, you can do like this, in your return function:

return (
  <>
    {
      rows.map(row => row) // Display every row
    }
  </>
)

or if you want to access a specific property of each row:

rows.map(row => row.companies) // Display every companies

Take a look at some examples if you are not familiar with map

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheTisiboth