bradleyterry

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

README

Bradley-Terry Model Build Status stability-stable Go Report Card GoDoc codecov.io

The Bradley-Terry Model is useful when comparing the results of a bunch of pairings to see what item is most relevant or best choice.

It's also used a bunch to determine the best team to bet on.

I wrote this version because I need to compare the preferred pieces of equipment at a playground, and didn't want to have to call out to Python or R to get the correct answer.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Model

func Model(data []Pair) map[string]float64

Model takes in a dataset of Pairs that describe the winner and loser of multiple match-ups. The model will return a map[string]float64 that contains the preference/relevance of each given element.

Example
rand.Seed(10)
var data = []Pair{
	{Winner: "Player 2", Loser: "Player 1"},
	{Winner: "Player 2", Loser: "Player 3"},
	{Winner: "Player 3", Loser: "Player 2"},
	{Winner: "Player 3", Loser: "Player 2"},
}

output := Model(data)
fmt.Printf("Player 1: %.2f\n", output["Player 1"])
fmt.Printf("Player 2: %.2f\n", output["Player 2"])
fmt.Printf("Player 3: %.2f\n", output["Player 3"])
Output:

Player 1: 0.00
Player 2: 0.33
Player 3: 0.67

Types

type Pair

type Pair struct {
	Winner string
	Loser  string
}

Pair is a struct combining the outcome of a single match, and contains the name of the winner and the name of the loser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL