I want to forecast the future sales for products.
My Questions:
- How I have to set up the dataset for time series forecasting?
- What I have to change, to get int values from output?
Model and additional infos
X.shape(68, 108, 124)
y.shape(68, 108, 1)
X
array([[2008, 0, 0, ..., 0, 0, 0],
[2008, 0, 0, ..., 0, 0, 5],
[2008, 0, 0, ..., 0, 0, 0],
...,
[2008, 0, 0, ..., 0, 1, 0],
[2008, 0, 1, ..., 0, 0, 7],
[2008, 1, 0, ..., 0, 0, 8]],
[[2009, 0, 0, ..., 0, 0, 0],
[2009, 0, 0, ..., 0, 0, 0],
[2009, 0, 0, ..., 0, 1, 10],
...,
[2009, 0, 0, ..., 0, 0, 20],
[2009, 0, 1, ..., 0, 2, 0],
[2009, 1, 0, ..., 0, 0, 5]]])
the hole dataset have 68 sequences (each historic year = one sequence), each sequence 108 rows and 124 features. Features: year(int) + countries are one hot encoded (108 different) + 15 product categories (one hot encoded)
output
model.predict(X_train_lstm)
[[-0.00230993, -0.5376476 , -0.15334567, ..., 0.09862291,
0.16895522, -0.15376607],
[ 0.09281429, -0.61930186, -0.30336168, ..., 0.03798292,
0.19980578, -0.11670589],
[ 0.10739403, -0.6318171 , -0.32635477, ..., 0.02868856,
0.20453428, -0.11102566],
...,
[ 0.10971781, -0.63381183, -0.33001956, ..., 0.02720715,
0.2052879 , -0.11012031],
[ 0.10971781, -0.63381183, -0.33001956, ..., 0.02720715,
0.20528793, -0.11012033],
[ 0.1097179 , -0.63381183, -0.33001956, ..., 0.02720721,
0.2052879 , -0.1101203 ]],
...,
X.shape(68, 108, 124)
y.shape(68, 108, 1)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=seed, shuffle=False)
X_validation, X_test, y_validation, y_test = train_test_split(X_test, y_test, test_size=0.5, random_state=seed, shuffle=False)
model = Sequential()
model.add(LSTM(units=50, input_shape=(108,124), name="LSTM", return_sequences=True))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy'])
model.fit(X_train, y_train, epochs=10, batch_size=20, verbose=1, validation_data=(X_validation, y_validation))