我有以下输入值,并希望预测时间戳列表中存在的值的湿度值
startDate = "2013-01-01"
endDate = "2013-01-01"
knownTimestamps = ['2013-01-01 00:00','2013-01-01 01:00','2013-01-01 02:00','2013-01-01 03:00','2013-01-01 04:00',
'2013-01-01 05:00','2013-01-01 06:00','2013-01-01 08:00','2013-01-01 10:00','2013-01-01 11:00',
'2013-01-01 12:00','2013-01-01 13:00','2013-01-01 16:00','2013-01-01 17:00','2013-01-01 18:00',
'2013-01-01 19:00','2013-01-01 20:00','2013-01-01 21:00','2013-01-01 23:00']
humidity = ['0.62','0.64','0.62','0.63','0.63','0.64','0.63','0.64','0.48','0.46','0.45','0.44','0.46','0.47','0.48','0.49','0.51','0.52','0.52']
timestamps = ['2013-01-01 07:00','2013-01-01 09:00','2013-01-01 14:00','2013-01-01 15:00','2013-01-01 22:00']
我正在使用以下函数在 python 中使用 AR 模型预测湿度值
from statsmodels.tsa.arima_model import ARIMA
def predictMissingHumidity(startDate, endDate, knownTimestamps, humidity, timestamps):
data_prediction = pd.DataFrame({'knownTimestamps': knownTimestamps,'humidity': humidity})
print(data_prediction.head(10))
history = [float(x) for x in data_prediction.humidity]
predictions = []
test = timestamps
for t in range(len(test)):
model = ARIMA(history, order=(2,2,0))
model_fit = model.fit(disp=0)
output = model_fit.forecast()
yhat = output[0]
predictions.append(float(yhat))
print(predictions)
return predictions
该模型为时间戳列表中的值预测相同的湿度值。
res = predictMissingHumidity(startDate, endDate, knownTimestamps, humidity, timestamps)
print(res)
output = [0.5287247355700563, 0.5287247355700563, 0.5287247355700563,
0.5287247355700563, 0.5287247355700563]
有人可以帮我解决我哪里出错了吗