我是预测,jupyter笔记本和python的新手。我似乎找不到问题
train_df = fit_train.drop(['price','Date'],axis=1).values
pred_df = fit_cast.drop(['price','Date'],axis=1).values
def fitForecast(stepwise_model, train_df, pred_df): #fittrain, fitcast
train_pred = pred_df[:len(train_df)] # data (M-Th)
cast_pred = pred_df[len(train_df):] # just Friday, the forecast
#xregTrain=train_pred.drop(['price','Date'],axis=1).values
#stepwise_model.fit(fit_train['price'], exogenous=xregTrain)
stepwise_model.fit(train_df['price'], exogenous=train_pred)
#xreg_cast=cast_pred.drop(['price','Date'],axis=1).values
future_forecast = stepwise_model.predict(n_periods=1, exogenous=cast_pred.reshape(1, -1))
return future_forecast
错误:
IndexError
Traceback (most recent call last)
<ipython-input-13-990978da5899> in <module>()
15 return future_forecast
16
---> 17 testFitForecast = fitForecast(stepwise_model, train_df, pred_df)
18
19 print(testFitForecast)
<ipython-input-13-990978da5899> in fitForecast(stepwise_model, train_df, pred_df)
8
9 #xregTrain=train_pred.drop(['price','Date'],axis=1).values
---> 10 stepwise_model.fit(train_df['price'], exogenous=train_pred)
11
12 #xreg_cast=cast_pred.drop(['price','Date'],axis=1).values
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices