LSTM and prediction binary variable with time series approach

  keras, lstm, machine-learning, python, tensorflow

im trying to use LSTM ondataset which include milions of record event parking occupancy.

I decide to focus only on one device with higher frequency(around 17k rows) and that leads to my goal which is prediction of free/occupatied parking space based on information from past. Long time ago some generous people here on stack suggest to consider this problem as a time-series problem and that’s why i’m here with some questions about approach to LSTM in binary classification.

I followed instruction:

    I guess i looked through whole internet to find similare dataset and that’s why im confused.
    Based on article (and yt video) from curiousily i follow advice to take my data
  3. Put arrivaltime variable into index. (but make additional columns that represent arrivaltime_week, arrivaltime_minute, arrivaltime_hour, arrivaltime_dayofweek)
  4. I also have departuretime but i drop that column because i think duration in minutes will be sufficent
  5. I reshaped and scale my dataset
  6. Build lstm model

Important note:
There is possible to exist few 0 (false) examples in a row. Idk why but i guess sensors usually make random event.
To be more clear, There is no simple schema in time that device recorded as you can notice on example dataset below

|                     | durationminutes| vehiclePresent |
| -------- -----------| -------------- | -------------  |
| 2019-05-28 02:50:42 |   9            |  0             |
| 2019-05-28 02:59:10 |   1            |  1             |
| 2019-05-28 03:00:50 |   16           |  0             |
| 2019-05-28 03:16:35 |   7            |  1             |
| 2019-05-28 03:23:27 |   16           |  0             | 

My code:

model = keras.Sequential()

        return_sequences = False,
      input_shape=(X_train.shape[1], X_train.shape[2])
model.add((Dense(1, activation='sigmoid')))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

history =
    X_train, y_train,

plot results

printscreen of epochs

To sum up:

-results are weird, before i was build lstm model without sigmoid function and mix some parameters but in any case it showed like the model overfit.

-It’s my first attempt to neural network so i’m like "what’s going on?"

I eager to know your point of view. Is my model is alright, is it even possible to work with time series liek this without time structured in one schema (like only ex. 14:05, 14:10, 14:15)

Big thanks for help!

Source: Python Questions