I'm quite new to this system as well as python. As a result, there may be a few lines in the code that are redundant.
I'm attempting to forecast y (CARA Flows) with the help of x (Hybrid MF). Despite the fact that the identical code works flawlessly in Python, I'm receiving an issue in Tableau. I can see the proper forecasts in the error pane (as well as prediction for the next 12 months).
There are no issues with the integration as well. Could someone please explain the situation to me?
SCRIPT_REAL(
"
import pandas as pd
import numpy as np
dateparse = lambda dates: pd.datetime.strptime(dates, '%Y%m')
data = pd.read_excel('S:\AIM India\Anup\Requests_2018\CTI_Forecasting_Tableau\Forecast_CTI_2.xlsx',parse_dates=['YYYYMM'], index_col='YYYYMM',date_parser=dateparse)
ts_exogenMF = data['Hybrid_MF']
from statsmodels.tsa.arima_model import ARIMA
model = ARIMA(ts_exogenMF,order=(2, 0, 2))
results_ARIMA1 = model.fit(disp=-1)
forecast1,std,conf=results_ARIMA1.forecast(steps=12,alpha=0.5)
forecastMF=forecast1
MF_Arr=[]
MF_Arr=forecastMF
ts = data['CARA_Flows']
from statsmodels.tsa.stattools import adfuller
ts_log = np.log(ts)
ts_log_diff = ts_log - ts_log.shift()
model = ARIMA(ts_log,exog=ts_exogenMF,order=(2, 0, 2))
results_ARIMA2 = model.fit(disp=1)
Final_Untransformed_Forecast=results_ARIMA2.predict(start=1, end=46, exog=MF_Arr, dynamic=False)
predictions_ARIMA_log = pd.Series(ts_log.ix[0], index=ts_log.index)
predictions_ARIMA_cumsum = predictions_ARIMA_log.add(Final_Untransformed_Forecast,fill_value=0)
predictions_12M = np.exp(Final_Untransformed_Forecast)
return predictions_12M
",SUM([Hybrid MF]), SUM([CARA Flows]))