Coder Social home page Coder Social logo

pfmonville / whole_history_rating Goto Github PK

View Code? Open in Web Editor NEW
50.0 7.0 13.0 47 KB

a python convertion from the ruby implementation of Rémi Coulom's Whole-History Rating (WHR) algorithm.

License: MIT License

Python 100.00%
whr algorithm history-rating python ranking

whole_history_rating's People

Contributors

endolith avatar pfmonville avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

whole_history_rating's Issues

win probabilities for all history

hello,

congrats for your work, I was wondering if there is a way to get the win probabilities for all the history. Maybe use the history ratings to derive it?

It would be useful to get a more precise estimate of the accuracy/mse than a train/test split

won_game_terms and lost_game_terms

In the PlayerDay class, there are functions called won_game_terms and lost_game_terms.

Say in the won_game_terms function, for each game a player has won, we append this:

[1.0,0.0,1.0,other_gamma]

And similarly to the lost games terms, we append this:

[0.0,other_gamma,1.0,other_gamma]

Clearly I know what the gamma is as that is defined but what do the other positions/numbers in these lists represent?

auto_iterate issues

  • iterates iteratively ten by ten is confusing language
  • time_limit (int, optional): the maximal time after should mention that the time limit is measured in seconds
  • The way the loop is arranged, the minimum number of iterations is actually 20, not 10, and it can take longer than the time limit if the dataset is large

I'm not sure the best way to improve these

How to import results from csv?

import pandas as pd

whr = whole_history_rating.Base()

df = pd.read_csv('MDB.csv', sep=',')

whr.load_games([df.home_team, df.away_team, "W", 0], separator=",")

whr.auto_iterate(time_limit = 10, precision = 10E-3)

 File "C:\intelo\whrwhr.py", line 8, in <module>
    whr.load_games([df.home_team, df.away_team, "W", 0], separator=",")
  File "C:\Users\under\AppData\Local\Programs\Python\Python310\lib\site-packages\whr\whole_history_rating.py", line 266, in load_games
    arguments = [x.strip() for x in line.split(separator)]
  File "C:\Users\under\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py", line 5902, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'split'. Did you mean: 'plot'?

How do I fix "unstable r on player"?

I'm running your library on a few years worth of data (starting in 2014 - now) in a relatively volatile sport. There are approximately 60,000 matches. I'm receiving the exception "unstable r on player".

Does this mean that there's a bug in my code somewhere? Or perhaps the algorithm doesn't work as well on this particular sport?

virtual_games Key Error

Double checked the games are in the right format and when I try and load them in I get this error.

whr.load_games(whr_hist, separator=",")


KeyError Traceback (most recent call last)
Input In [325], in <cell line: 1>()
----> 1 whr.load_games(whr_hist, separator=",")

File ~\anaconda3\lib\site-packages\whr\whole_history_rating.py:309, in Base.load_games(self, games, separator)
307 black = black.lower()
308 white = white.lower()
--> 309 self.create_game(black, white, winner, time_step, handicap, extras=extras)

File ~\anaconda3\lib\site-packages\whr\whole_history_rating.py:145, in Base.create_game(self, black, white, winner, time_step, handicap, extras)
143 black = black.lower()
144 white = white.lower()
--> 145 game = self._setup_game(black, white, winner, time_step, handicap, extras)
146 return self._add_game(game)

File ~\anaconda3\lib\site-packages\whr\whole_history_rating.py:121, in Base._setup_game(self, black, white, winner, time_step, handicap, extras)
119 if black == white:
120 raise AttributeError("Invalid game (black player == white player)")
--> 121 white_player = self.player_by_name(white)
122 black_player = self.player_by_name(black)
123 game = Game(black_player, white_player, winner, time_step, handicap, extras)

File ~\anaconda3\lib\site-packages\whr\whole_history_rating.py:93, in Base.player_by_name(self, name)
91 name = name.lower()
92 if self.players.get(name, None) is None:
---> 93 self.players[name] = Player(name, self.config)
94 return self.players[name]

File ~\anaconda3\lib\site-packages\whr\player.py:13, in Player.init(self, name, config)
10 self.debug = config.get('debug', False)
11 self.w2 = (math.sqrt(config['w2']) * math.log(10.) /
12 400.)**2. # Convert from elo^2 to r^2
---> 13 self.virtual_games = config['virtual_games']
14 self.days = []

KeyError: 'virtual_games'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.