mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 06:54:44 +00:00
192 lines
5.1 KiB
Plaintext
192 lines
5.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import operator\n",
|
|
"import csv\n",
|
|
"#constants\n",
|
|
"k=100\n",
|
|
"rdf=400\n",
|
|
"\n",
|
|
"def win_prob(yas,oas):\n",
|
|
" return 1/(1+10**(1/rdf*(oas-yas)))\n",
|
|
"def new_score(oscore,yas,oas,outcome):\n",
|
|
" return (oscore)+k*(outcome-win_prob(yas,oas))\n",
|
|
"\n",
|
|
"def readFile(filepath):\n",
|
|
"\n",
|
|
" with open(filepath) as csvfile:\n",
|
|
" lines = csv.reader(csvfile, delimiter=',', quotechar='|')\n",
|
|
" data = []\n",
|
|
" try:\n",
|
|
" for row in lines:\n",
|
|
" data.append((', '.join(row)).split(\", \"))\n",
|
|
" except:\n",
|
|
" pass\n",
|
|
"\n",
|
|
" return data\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"sb=readFile('scoreboard.csv')\n",
|
|
"teams=set([])\n",
|
|
"for i in sb:\n",
|
|
" teams.add(i[2])\n",
|
|
" teams.add(i[3])\n",
|
|
" teams.add(i[4])\n",
|
|
" teams.add(i[5])\n",
|
|
" teams.add(i[6])\n",
|
|
" teams.add(i[7])\n",
|
|
"list(teams)\n",
|
|
"tsd={}\n",
|
|
"for i in list(teams):\n",
|
|
" tsd[i]=500\n",
|
|
"for i in sb:\n",
|
|
" ras=tsd[i[2]]+tsd[i[3]]+tsd[i[4]]\n",
|
|
" bas=tsd[i[5]]+tsd[i[6]]+tsd[i[7]]\n",
|
|
" outcome=0\n",
|
|
" if i[8]>i[9]:\n",
|
|
" outcome=1\n",
|
|
" elif i[9]==i[8]:\n",
|
|
" outcome=.5\n",
|
|
" for j in range(2,5,1):\n",
|
|
" tsd[i[j]]=new_score(tsd[i[j]],ras,bas,outcome)\n",
|
|
" for j in range(5,8,1):\n",
|
|
" tsd[i[j]]=new_score(tsd[i[j]],bas,ras,1-outcome)\n",
|
|
" \n",
|
|
"rankinfs = sorted(tsd.items(), key=operator.itemgetter(1), reverse=True) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[('5934', 833.1830859510761),\n",
|
|
" ('48', 739.9728094005745),\n",
|
|
" ('16', 705.9551102513088),\n",
|
|
" ('3061', 702.9024075826381),\n",
|
|
" ('3695', 700.1366129603175),\n",
|
|
" ('2338', 696.932652524603),\n",
|
|
" ('4096', 652.7038522070818),\n",
|
|
" ('3488', 648.9766694246662),\n",
|
|
" ('4156', 638.0881039843185),\n",
|
|
" ('101', 626.9019952260375),\n",
|
|
" ('6823', 613.1453027540894),\n",
|
|
" ('930', 610.7992869961017),\n",
|
|
" ('2062', 608.0647276785079),\n",
|
|
" ('2830', 600.0239706519325),\n",
|
|
" ('5847', 589.0350788865741),\n",
|
|
" ('1736', 584.367394696335),\n",
|
|
" ('2358', 577.5524744241919),\n",
|
|
" ('5822', 575.4792058357157),\n",
|
|
" ('1675', 569.9944280943398),\n",
|
|
" ('111', 559.5150813478114),\n",
|
|
" ('1797', 537.9429025884093),\n",
|
|
" ('5148', 533.9623603303631),\n",
|
|
" ('1781', 519.5609268991466),\n",
|
|
" ('6651', 516.3195829730869),\n",
|
|
" ('6906', 501.7408783344565),\n",
|
|
" ('2022', 482.2765218696747),\n",
|
|
" ('7237', 474.4616019824547),\n",
|
|
" ('1884', 468.87487164611116),\n",
|
|
" ('2039', 467.0990375388428),\n",
|
|
" ('2451', 462.70812165138807),\n",
|
|
" ('7608', 462.0188420364676),\n",
|
|
" ('1739', 459.00590084129664),\n",
|
|
" ('2252', 456.43201385653043),\n",
|
|
" ('2151', 439.4118535382677),\n",
|
|
" ('4702', 435.5729578944645),\n",
|
|
" ('7738', 423.16353418538296),\n",
|
|
" ('4296', 420.5085609998351),\n",
|
|
" ('3734', 418.47615429198186),\n",
|
|
" ('7609', 409.29347746836567),\n",
|
|
" ('2709', 403.9793052336144),\n",
|
|
" ('3067', 402.77020998279653),\n",
|
|
" ('2136', 386.0798688817299),\n",
|
|
" ('5350', 383.4109800245315),\n",
|
|
" ('5125', 377.1609505922246),\n",
|
|
" ('4292', 357.43188113820975),\n",
|
|
" ('3110', 344.8643460008074),\n",
|
|
" ('2725', 332.21429556184444),\n",
|
|
" ('4645', 329.6452389079341),\n",
|
|
" ('6968', 329.08368400289095),\n",
|
|
" ('4241', 315.12115012426335),\n",
|
|
" ('4787', 288.64374620808815),\n",
|
|
" ('7560', 279.7779164676232),\n",
|
|
" ('2016', 247.25607506869346)]"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"rankinfs"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.5"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|