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.
-
class
gameanalysis.learning.
DevRegressionGame
(game, regressors, offset, scale, min_payoffs, max_payoffs, rest)[source]¶ Bases:
gameanalysis.rsgame.CompleteGame
A game regression model that learns deviation payoffs
This model functions as a game, but doesn’t have a default way of computing deviation payoffs. It must be wrapped with another game that uses payoff data to compute deviation payoffs.
-
class
gameanalysis.learning.
NeighborDeviationGame
(model, num_devs=2)[source]¶ Bases:
gameanalysis.learning._DeviationGame
Create a neighbor game from a model
This takes a normalized weighted estimate of the deviation payoffs by finding all profiles within num_devs of the maximum probability profile for the mixture and weighting them accordingly. This is biased, but accurate in the limit as num_devs approaches num_players. It also produces discontinuities every time the maximum probability profile switches.
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_devs (int, optional) – The number of deviations to take.
-
class
gameanalysis.learning.
PointDeviationGame
(model)[source]¶ Bases:
gameanalysis.learning._DeviationGame
Deviation payoffs by point approximation
This model computes payoffs by finding the deviation payoffs from the point estimate of the mixture. It’s fast but biased. This is accurate in the limit as the number of players goes to infinity.
For this work, the underlying implementation of get_dev_payoffs must support floating point profiles, which only really makes sense for regression games. For deviation payoffs to have a jacobian, the underlying model must also support a jacobian for get_dev_payoffs.
Parameters: model (DevRegressionGame) – A payoff model
-
class
gameanalysis.learning.
RbfGpGame
(role_names, strat_names, num_role_players, offset, coefs, lengths, sizes, profiles, alpha)[source]¶ Bases:
gameanalysis.rsgame.CompleteGame
A regression game using RBF Gaussian processes
This regression game has a build in deviation payoff based off of a continuous approximation of the multinomial distribution.
-
class
gameanalysis.learning.
SampleDeviationGame
(model, num_samples=100)[source]¶ Bases:
gameanalysis.learning._DeviationGame
Deviation payoffs by sampling from mixture
This model produces unbiased deviation payoff estimates, but they’re noisy and random and take a while to compute. This is accurate in the limit as num_samples goes to infinity.
Parameters: - model (DevRegressionGame) – A payoff model
- num_samples (int, optional) – The number of samples to use for each deviation estimate. Higher means lower variance but higher computation time.
-
gameanalysis.learning.
neighbor
(game, num_devs=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_devs (int, optional) – The number of deviations to explore out.
-
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.
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.
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.