I am trying to do a Time-Series Prediction Beyond Test Data. I followed the following tutorial to get were I am now (https://medium.com/swlh/a-quick-example-of-time-series-forecasting-using-long-short-term-memory-lstm-networks-ddc10dc1467d).
Now when I visualise the data I get this

But what I want is to only show the predicted value and not the entire dataset. So something like adding a slider at the bottom to show the prediction instead of having to zoom in. So the slider will let the user select dates from 2020/10 - 2021/10.
Also I want to display the predicted value (of the place you have hovered on) in a text box below the graph instead of on the graph only. So everytime you hover on a point the y-value on the prediction text updates as well.
Here’s the code I have now
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from statsmodels.tools.eval_measures import rmse
from sklearn.preprocessing import MinMaxScaler
from keras.preprocessing.sequence import TimeseriesGenerator
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
import warnings
warnings.filterwarnings("ignore")
df = pd.read_csv('AirPassengers.csv')
df.Month = pd.to_datetime(df.Month)
df = df.set_index("Month")
scaler = MinMaxScaler()
scaler.fit(train)
train = scaler.transform(train)
n_input = 12
n_features = 1
generator = TimeseriesGenerator(train, train, length=n_input, batch_size=76)
model = Sequential()
model.add(LSTM(200, activation='relu', input_shape=(n_input, n_features)))
model.add(Dropout(0.15))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')
model.fit_generator(generator,epochs=30)
pred_list = []
batch = train[-n_input:].reshape((1, n_input, n_features))
for i in range(n_input):
pred_list.append(model.predict(batch)[0])
batch = np.append(batch[:,1:,:],[[pred_list[i]]],axis=1)
from pandas.tseries.offsets import DateOffset
add_dates = [dd.index[-1] + DateOffset(months=x) for x in range(0,13) ]
future_dates = pd.DataFrame(index=add_dates[1:],columns=dd.columns)
df_predict = pd.DataFrame(scaler.inverse_transform(pred_list),
index=future_dates[-n_input:].index, columns=['Prediction'])
df_proj = pd.concat([dd,df_predict], axis=1)
plot_data = [
go.Scatter(
x=df_proj.index,
y=df_proj['Gauteng'],
name='actual'
),
go.Scatter(
x=df_proj.index,
y=df_proj['Prediction'],
name='prediction'
)
]
plot_layout = go.Layout(
title='Time Series Prediction'
)
fig = go.Figure(data=plot_data, layout=plot_layout)
import plotly as ply
ply.offline.plot(fig)
The dateset can be found on https://github.com/gianfelton/12-Month-Forecast-With-LSTM/blob/master/AirPassengers.csv
Thank you in advance