BayesBall

BayesBall is a small collection of Python modules for modelling probabilistic baseball events

View the Project on GitHub

BayesBall

written by: Chris French

version: 0.1.0 Pre-Alpha

Rationale:

BayesBall is a small collection of Python modules for modelling the probabilistic events that occur in a typical game of baseball. Events, for example, like pitching a baseball, catching a baseball, or stealing home.

Events are modeled with the BayesAction class. Every BayesAction is a subclass of ChainMap with the mappings shown below (ordered from last to first):

Every BayesAction determines values for prior probabilities defined over a finite set of action outcomes.

These outcomes and prior probabilities are not intended to be directly changed by the developer. Instead, probability values are initialized (relative to the event’s current reference class and action type) and manipulated by the logic internal to a BayesAction instance.

In other words, prior probability values are fixed by the logic encapsulated within BayesAction class methods.

This is a feature, not a bug.

Ideally, BayesAction instances should behave semi-autonomously. The average modeller should never manipulate these prior probabilities directly–but only indirectly, by manipulating the context of an event. That is, by altering its reference class: by changing the GameState and, if possible, the Environment.

Presently, the underlying logic in the main BayesActionPitchEvent –is unrealistic: it relies too heavily on symmetry assumptions rather than the Environment and players in the current lineups.

BayesBall is different from baseball simulations that are frequentist in nature: whereas BayesBall fixes prior probabilities explicitly, other simulation engines define event probabilities in terms of relative frequencies. For example, these simulations may calculate the probability that a hit pitch will result in a single by first assuming that, say, at most N (= 100,000) hits will occur over the course of a season. If M is the number of other hit events that could occur during an at-bat (excluding singles), the probability that an at-bat will result in a single, if a hit event must occur, is just

(N-n) / (N+M)

where n is the number of singles which have already occurred in the season.

Using BayesGame:

BayesGame provides a framework for developing a baseball game simulator.

Currently, the only dependencies are NumPy and SciPy.

To install these dependencies, use

pip3 install numpy

and

pip3 install scipy

and that’s it. Aside from Python’s curses library, there are no other dependencies.

To play through a toy baseball game example, simply run:

python3 game.py

If you are using Mac/Linux, play through a game with a curses-based app:

python3 app.py

Short Term Goals:

Long Term Goals:

License: GPL v3