2
$\begingroup$

Working on a binary classification task to identify duplicate documents with 350,000 labeled samples, 70 features. There is about a 10:1 class imbalance. My best performing model so far has been a random forest, but I would like to see if I can use a deep feed forward neural network for better results.

I have been playing with the number of layers and hidden units and verify performance using 5-fold cross validation. Here is an example of one architecture:

for train_validation, test_validation in sfk.split(X_train,y_train):   
    model = Sequential()
    model.add(Dense(150, input_dim=X_train.shape[1], activation='relu')) 
    model.add(Dense(125, activation='relu'))
    model.add(Dense(100, activation='relu'))
    model.add(Dense(75, activation='relu'))
    model.add(Dense(50, activation='relu'))
    model.add(Dense(25, activation='relu'))
    model.add(Dense(1, activation='sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer='adam',metrics=['accuracy'])

    model.fit(X_train.iloc[train_validation,:].values,
              y_train.iloc[train_validation].values.reshape([-1,1]),
              epochs=13,
              batch_size=64,
              verbose=2,
              validation_data=(X_train.iloc[test_validation ,:].values,y_train.iloc[val_test].values.reshape([-1,1])))

I run that, get the mean/std of the accuracy and error. Then try adding a layer, removing a layer, adding some units, removing some. There is movement in accuracy and error (in the +/- 0.00x range). This approach is unscientific, what is a better way?

$\endgroup$
  • $\begingroup$ If you are using cross-validation correctly to measure performance, then I would say your approach is scientific. In that you create a hypothesis ("this model may be better") design an experiment (build the model and train it) then use measurements to test it and come to a conclusion ("no it is not better"). It might not be efficient though, if you are randomly trying different model hyper-parameters based on guesses. $\endgroup$ – Neil Slater Nov 29 '17 at 15:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.