What does nnet minimise

Aaaand here is your fully reproducible solution, in a RStudio Cloud project:

https://rstudio.cloud/project/160813

There are two scripts:

  1. First, preprocess the data by running the script 1_preprocess_wine_data.R;
  2. Then, define, train and evaluate your model with 2_train_and_evaluate_model.R. As you can see, I tested different values for the number of units in the hidden layer, and the dropout rate: the best combination, for what it concerns the validation accuracy, was the baseline one.

Note the simplicity of the keras API:

  • you need just one function (use_session_with_seed()) to make your whole analysis reproducible, though note some caveats
  • adding modern regularization techniques such as dropout or batch norm is immediate
  • the number of layers and hidden units/layer, the loss function and the type of optimizer used are easy to identify & modify as desired
  • plotting the training history, as well as making inference on the test set, is also very easy.

Have fun trying different hyperparameters, if you want, but I don't think you can do much better than this, unless you add more layers.

4 Likes