# How to change parameters in LSTM for multivariate binary classification time series?

https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/

I am trying to follow this tutorial's code with a slightly different dataset, where the predictor is a 0 or 1: presence or absence of something. My data is continuous time series data, and I have other continuous variables that are inputs. For the most part, sans column numbers and names, my code is almost identical to the one in that tutorial. However, my predicted values show up like this on the plot:

And upon changing the "Dense" line from this:

model.add(Dense(1))


into:

model.add(Dense(1, activation='sigmoid'))


and the compile line from:

model.compile(loss='mae', optimizer='adam')


to:

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])


I thought this was all I needed to change to make the predictions binary, but my predictions plot still keeps giving decimals and nonbinaries, as the plot above shows. What else do I need to account for in a classification problem in LSTM?

The sigmoid activation gives you a number between 0 and 1 (you can consider it as the probability of item i to be of class 1). To get hard predictions (0s and 1s) you just use a rule that says "I consider that the item is predicted positive if the probability is above a certain threshold". For example, for a threshold of 0.5, you just map every predicted value above 0.5 to 1 and the rest to 0.