I have a binary classification problem and want to build a NN model which classifies the data whether class 0 or class 1.
My actual implementation looks like the following:
# Split dataset in train and test data X_train, X_test, Y_train, Y_test = train_test_split(normalized_X, Y, test_size=0.3, random_state=seed) # Build the model model = Sequential() model.add(Dense(23, input_dim=45, kernel_initializer='normal', activation='relu')) model.add(Dense(1, kernel_initializer='normal', activation='sigmoid')) # Compile model model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) # Fit the model history = model.fit(X_train, Y_train, validation_split=0.3, epochs=200, batch_size=5, verbose=1, callbacks=[tensorboard, time_callback])
and I get a val_accuracy of 79.85% at the last training epoch.
I used a confusion matrix to evaluate the model:
y_pred = model.predict(X_test) y_pred =(y_pred>0.5) list(y_pred) cm = confusion_matrix(Y_test, y_pred) print(cm)
and I get these values: [[ 622 205] [ 216 1055]]
which makes 79.93% (approximately the same as the val_accuracy on the last epoch) of right predicted classes (622 TN + 1055 TP).
Now my question is: How to improve my NN so that I get above that? Okay, I am using 1 hidden Dense Layer, with 23 nodes. When to use Dense layers, and when to use Conv2D or Dropout, or any of the other layers of Keras?
PS: the categorical features were One-Hot-Encoded using:
basic_df = pd.get_dummies(basic_df, columns=['industry', 'weekday', 'category_name', 'page_name', 'type'])
And the label column is 'successful'.