1. 程式人生 > >Poker rule induction by a neural network

Poker rule induction by a neural network

My first ML project is a neural network that would say Hello to everyone coming to our office and make coffee in the mornings. Though since I haven’t done it before, I wanted to start with something simpler. Like this task on kaggle https://www.kaggle.com/c/poker-rule-induction.

The solution that finally gave 100% accuracy on the test set required a bit of data augmentation and feature engineering. What I did was:

1. Add distances between cards as features. E.g. distance between Jack and King is 2, between King and Three is 3 and so on.

2. Increase training dataset 4 times.

And the neural network implementation in keras looks like this:

  model = keras.Sequential()

  model.add(keras.layers.Dense(120, activation='relu', input_shape=(30,)))
  model.add(keras.layers.Dropout(0.2))

  model.add(keras.layers.Dense(240, activation='relu'))
  model.add(keras.layers.Dropout(0.2))
  model.add(keras.layers.Dense(120, activation='relu'))
  model.add(keras.layers.Dropout(0.1))
  model.add(keras.layers.Dense(120, activation='relu'))
  model.add(keras.layers.Dense(60, activation='relu'))

  model.add(keras.layers.Dense(10, activation='softmax'))

  model.compile(optimizer=tf.train.AdamOptimizer(0.0005),
              loss='categorical_crossentropy',
              metrics=['accuracy'])
I appreciate any feedback.