gameanalysis.learning module

Package for learning complete games from data

The API of this individual module is still unstable and may change as improvements or refinements are made.

There are two general game types in this module: learned games and deviation games. Learned games vary by the method, but generally expose methods for computing payoffs and may other features. Deviation games use learned games and different functions to compute deviation payoffs via various methods.

gameanalysis.learning.neighbor(game, num_neighbors=2)[source]

Create a neighbor game from a model

Parameters
  • game (RsGame) – If this is a payoff model it will be used to take samples, if this is an existing deviation game, then this will use it’s underlying model.

  • num_neighbors (int, optional) – The number of deviations to explore out.

gameanalysis.learning.neighbor_json(json)[source]

Read neighbor game from json

gameanalysis.learning.nngame_train(game, epochs=100, layer_sizes=32, 32, dropout=0.2, verbosity=0, optimizer='sgd', loss='mean_squared_error')[source]

Train a neural network regression model

This mostly exists as a proof of concept, individual testing should be done to make sure it is working sufficiently. This API will likely change to support more general architectures and training.

gameanalysis.learning.point(game)[source]

Create a point game from a model

Parameters

game (RsGame) – If this is a payoff model it will be used to take samples, if this is an existing deviation game, then this will use it’s underlying model.

gameanalysis.learning.point_json(json)[source]

Read point game from json

gameanalysis.learning.rbfgame_json(json)[source]

Read an rbf game from json

gameanalysis.learning.rbfgame_train(game, num_restarts=3)[source]

Train a regression game with an RBF Gaussian process

This model is somewhat well tests and has a few added benefits over standard regression models due the nature of its functional form.

Parameters
  • game (RsGame) – The game to learn. Must have at least one payoff per strategy.

  • num_restarts (int, optional) – The number of random restarts to make with the optimizer. Higher numbers will give a better fit (in expectation), but will take longer.

gameanalysis.learning.sample(game, num_samples=100)[source]

Create a sample game from a model

Parameters
  • game (RsGame) – If this is a payoff model it will be used to take samples, if this is an existing deviation game, then this will use it’s underlying model.

  • num_samples (int, optional) – The number of samples to take.

gameanalysis.learning.sample_json(json)[source]

Read sample game from json

gameanalysis.learning.sklgame_train(game, estimator)[source]

Create a regression game from an arbitrary sklearn estimator

Parameters
  • game (RsGame) – The game to learn, must have at least one payoff per strategy.

  • estimator (sklearn estimator) – An estimator that supports clone, fit, and predict via the stand scikit-learn estimator API.