leaderbot.models.BradleyTerry.predict#

BradleyTerry.predict(x=None)#

Predict outcome between competitors.

Parameters:
xnp.ndarray, list, zip, or leaderbot.data.DataType

A 2D array (or equivalent list or zip) of integers with the shape (n_pairs, 2) where each row consists of indices [i, j] representing a match between a pair of agents with the indices i and j. Alternatively, a dictionary of the type leaderbot.data.DataType can be provided. If None, the X variable from the input data is used.

Returns:
probnp.array

An array of the shape (n_agents, ) where each entry represents the following codes:

  • +1: agent i wins j.

  • 0: agent i ties j.

  • -1: agent i losses to j.

Raises:
RuntimeError

If the model is not trained before calling this method.

See also

train

train model parameters.

infer

make inference of the probabilities of win, loss, and tie.

Examples

>>> from leaderbot.data import load
>>> from leaderbot.models import Davidson

>>> # Create a model
>>> data = load()
>>> model = Davidson(data)

>>> # Train the model
>>> model.train()

>>> # Make prediction
>>> x = list(zip((0, 1, 2), (1, 2, 0)))
>>> pred = model.predict(x)