I have to predict the Air Quality Index for next 15 days, dataset is as follows:
But there are 6 different locations in the data set, and i want the model to show the results based on the location given in model.predict() along with time-series data.
model = Sequential()
model.add(LSTM(64, activation='relu', input_shape=(trainX.shape[1], trainX.shape[2]), return_sequences=True))
model.add(LSTM(32, activation='relu', return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(trainY.shape[1]))
model.compile(optimizer='adam', loss='mse')
model.summary()
history = model.fit(trainX, trainY, epochs=10, batch_size=16, validation_split=0.2, verbose=1)
plt.plot(history.history['loss'], label='Training loss')
plt.plot(history.history['val_loss'], label='Validation loss')
plt.legend()
predict_period_dates = pd.date_range(list(train_dates)[-1], periods=n_future, freq='1d').tolist()
print(predict_period_dates)
prediction = model.predict(trainX[-n_future:])
prediction_copies = np.repeat(prediction,train.shape[1], axis=-1)
y_pred_future = scaler.inverse_transform(prediction_copies)[:,0]
forecast_dates = []
for time_i in predict_period_dates:
forecast_dates.append(time_i.date())
df_forecast = pd.DataFrame({'Date':np.array(forecast_dates), 'AQI':y_pred_future})
df_forecast['Date']=pd.to_datetime(df_forecast['Date'])
original = final_df[['Date', 'AQI_calculated']]
original = original.loc[original['Date'] >= '2021-11-15']
sns.lineplot(x=original['Date'], y=original['AQI_calculated'])
sns.lineplot(x=df_forecast['Date'], y=df_forecast['AQI'])
I have implemented multivariate time-series prediction using LSTM the output of the code above is as follows:
This prediction is without the location, and i want to predict the AQI for a given location example 'predicting AQI for bandra for next 15 days'.
I would appreciate any help in this problem.