Мне нужно проверить модель ARIMA, проверив ее показатель r2.Поэтому мне нужно сделать ARIMA.predict, но есть ошибка:
TypeError: Невозможно преобразовать ввод [DatetimeIndex (['2014-08-10 06:00:00', '2014-05-05 16:00:00 ',' 2014-04-28 20:00:00 ',' 2014-03-27 21:00:00 ',' 2012-08-26 09:00:00 ',' 2012-09-29 08:00:00 ',' 2013-02-15 03:00:00 ',' 2013-02-28 09:00:00 ',' 2014-06-27 06:00:00 ','2014-01-18 11:00:00', ... '2013-11-10 22:00:00', '2013-03-18 21:00:00', '2013-09-09 00:00:00 ',' 2013-06-08 21:00:00 ',' 2013-11-11 12:00:00 ',' 2014-07-07 05:00:00 ',' 2014-07-2712:00:00 ',' 2014-06-03 23:00:00 ',' 2012-09-20 12:00:00 ',' 2012-12-18 22:00:00 '], dtype ='datetime64 [ns] ', name =' Datetime ', length = 3658,> freq = None)] типа to> Отметка времени
Вот мой код:
dateparse = lambda dates: pd.datetime.strptime(dates, "%d-%m-%Y %H:%M")
train=pd.read_csv("D:/Coding/Datasets/train_traffic.csv", parse_dates=
['Datetime'], index_col='Datetime',date_parser=dateparse)
X_train, X_test, y_train, y_test = ms.train_test_split(train.index,
train.Count, test_size=0.20, random_state=5)
model = ARIMA(ts_log, order=(2, 1, 0), freq='H')
AR = model.fit(disp=-1)
AR.predict(X_test)
Пример и типы данных: в Excel: 25-08-2012 00: 00.
pd.read_csv без параметров:
Out:dtype('O')
Out:'25-08-2012 00:00'
с параметрами:
dateparse = lambda dates: pd.datetime.strptime(dates, "%d-%m-%Y %H:%M")
pd.read_csv("D:/Coding/Datasets/train_traffic.csv", parse_dates=['Datetime'], index_col='Datetime',date_parser=dateparse)
Out:dtype('<M8[ns]')
df.index[0]
Out:Timestamp('2012-08-25 00:00:00')
Также я попробовал
pd.read_csv("D:/Coding/Datasets/train_traffic.csv", index_col='Datetime').index[0]
Out:'25-08-2012 00:00'
Out:dtype('O')
Спасибо!