Go to Post If you want to change the culture sometimes you need to change a little yourself - Koko Ed [more]
Home
Go Back   Chief Delphi > ChiefDelphi.com Website > Extra Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 10 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 13-03-2014, 13:49
connor.worley's Avatar
connor.worley connor.worley is offline
Registered User
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley/San Diego
Posts: 601
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
paper: Weeks 1-2 Elo Analysis

Thread created automatically to discuss a document in CD-Media.

Weeks 1-2 Elo Analysis by connor.worley

Here is the Python code used to calculate the ratings:
Code:
import csv

teams = {}

def getElo(team):
    if team not in teams:
        teams[team] = 1200
    return teams[team]

def setElo(team, elo):
    teams[team] = elo

def calculateElo(fileName, kFactor):
    reader = csv.reader(open(fileName, 'r'))

    for row in reader:
        if row[3] == "Q" or row[3] == "E":
            averageRedElo  = (getElo(row[9])  + getElo(row[10]) + getElo(row[11]))/3
            averageBlueElo = (getElo(row[12]) + getElo(row[13]) + getElo(row[14]))/3

            Ea = 1/(1 + 10**((averageBlueElo - averageRedElo)/400))
            Eb = 1/(1 + 10**((averageRedElo - averageBlueElo)/400))

            if int(row[7]) > int(row[8]):
                Sa = 1
                Sb = 0
            elif int(row[8]) > int(row[7]):
                Sa = 0
                Sb = 1
            else:
                Sa = 0.5
                Sb = 0.5       

            dRa = kFactor*(Sa-Ea)
            dRb = kFactor*(Sb-Eb)

            setElo(row[9],  getElo(row[9])  + dRa)
            setElo(row[10], getElo(row[10]) + dRa)
            setElo(row[11], getElo(row[11]) + dRa)
            setElo(row[12], getElo(row[12]) + dRb)
            setElo(row[13], getElo(row[13]) + dRb)
            setElo(row[14], getElo(row[14]) + dRb)
            
calculateElo('matches_week_2_2014.csv', 24)
sortedTeams = sorted(teams, key=teams.get, reverse=True)
for team in sortedTeams:
    print(team, getElo(team))
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 18:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi