I want to make simple classifier with Keras that will classify my data. Features are numeric data and results are string/categorical data. I'm predicting 15 different categories/classes. This is how my code looks:
model = Sequential()
model.add(Dense(16, input_dim = x_train.shape[1], activation = 'relu')) # input layer requires input_dim param
model.add(Dense(16, activation = 'relu'))
model.add(Dense(16, activation = 'relu'))
model.add(Dense(1, activation='relu'))
model.compile(loss="binary_crossentropy", optimizer= "adam", metrics=['accuracy'])
#es = EarlyStopping(monitor='loss', min_delta=0.005, patience=1, verbose=1, mode='auto')
model.fit(x_train, y_train, epochs = 100, shuffle = True, batch_size=128, verbose=2)
scores = model.evaluate(x_test, y_test)
print(model.metrics_names[0], model.metrics_names[1])
the problem is that I'm always getting this error:
ValueError: could not convert string to float 'category1'
What am I doing wrong?
When I replace my classes names "category1", "category2" etc with integer numbers, my code works but it always give me accuracy of 0. I have tried to change number of nodes and layers and activation functions but the result is always 0. It seams like the model thinks that I'm doing regression not classification.
What is the correct way to do classification with Keras lib If my categorical values are not just 1 or 0?