# Python - Predicting data based on multidimensional array with Keras

I've a list of data which is so called 3D array. Each of 10350 rows contains a 2D matrix with size of 150x16 (elements are float) (x_train). Corresponding training data for this huge array a linear array with size of 10350 integer which can be either 0 or 1 (y_train).

I used different methods to estimate the test_data. None of them worked with such type of array.

from matplotlib import pyplot as plt

from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from sklearn.preprocessing import MinMaxScaler

min_max_scaler = MinMaxScaler()

x_train = []
y_train = []

for i in range(len(train_data_set)):
x_train.append(train_data_set[i].arr_)
y_train.append(train_data_set[i].flag_)

num_units = 4
activation_function = 'sigmoid'
loss_function = 'mean_squared_error'
batch_size = 5
num_epochs = 100

regressor = Sequential()

regressor.compile(optimizer=optimizer, loss=loss_function)

regressor.fit(x_train, y_train, batch_size=batch_size, epochs=num_epochs)

inputs_x = []
inputs_y = []
for i in range(len(test_data_set)):
inputs_x.append(test_data_set[i].arr_)
inputs_x.append(test_data_set[i].flag_)

predicted_price = regressor.predict(inputs_x)


The library that I'm using is Keras. I'm new at data science, any suggestion will be welcome for me.

• Many things could be going wrong, but one thing that stands out is that you're using mean squared error as your loss function. For classification tasks, you should be using the binary cross entropy (called binary_crossentropy in Keras) Sep 27, 2018 at 2:58

regressor.add(LSTM(units=num_units, input_shape=(x_train.shape[1],x_train.shape[2])))