Last active
August 31, 2016 22:29
-
-
Save bnaul/70e7223edddba03b98e728c7ef83427c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Regular season rankings (2nd to last week, before less-than-ten-game teams are dropped), re-ordered by sectionals placement:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Overwriting norcal.csv\n" | |
] | |
} | |
], | |
"source": [ | |
"%%file norcal.csv\n", | |
"Team,Rating\n", | |
"Mischief,1799\n", | |
"Polar Bears,1582\n", | |
"Blackbird,1610\n", | |
"BW Ultimate,1402\n", | |
"Classy,1251\n", | |
"Donuts,1352\n", | |
"Alchemy,1222\n", | |
"American Barbecue,1289\n", | |
"Groove,1099\n", | |
"Platypi,1304\n", | |
"Ursa Major,712" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Overwriting socal.csv\n" | |
] | |
} | |
], | |
"source": [ | |
"%%file socal.csv\n", | |
"Team,Rating\n", | |
"7 Figures,1513\n", | |
"Dorado,1504\n", | |
"Long Beach Legacy,1291\n", | |
"Family Style,1106\n", | |
"Rubix,1345" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Here we'll use isotonic regression to find the closest set of values to the original ratings that also respects the sectional placements:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"from sklearn.isotonic import isotonic_regression\n", | |
"\n", | |
"norcal = pd.read_csv('norcal.csv')\n", | |
"socal = pd.read_csv('socal.csv')\n", | |
"norcal['Re-Ordered'] = isotonic_regression(norcal['Rating'], increasing=False)\n", | |
"socal['Re-Ordered'] = isotonic_regression(socal['Rating'], increasing=False)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now combine and sort by the new ratings:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Team</th>\n", | |
" <th>Rating</th>\n", | |
" <th>Re-Ordered</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>Mischief</td>\n", | |
" <td>1799</td>\n", | |
" <td>1799.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>Polar Bears</td>\n", | |
" <td>1582</td>\n", | |
" <td>1596.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>Blackbird</td>\n", | |
" <td>1610</td>\n", | |
" <td>1596.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>7 Figures</td>\n", | |
" <td>1513</td>\n", | |
" <td>1513.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>Dorado</td>\n", | |
" <td>1504</td>\n", | |
" <td>1504.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>BW Ultimate</td>\n", | |
" <td>1402</td>\n", | |
" <td>1402.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>Classy</td>\n", | |
" <td>1251</td>\n", | |
" <td>1301.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>Donuts</td>\n", | |
" <td>1352</td>\n", | |
" <td>1301.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>9</th>\n", | |
" <td>Long Beach Legacy</td>\n", | |
" <td>1291</td>\n", | |
" <td>1291.0</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>10</th>\n", | |
" <td>Alchemy</td>\n", | |
" <td>1222</td>\n", | |
" <td>1255.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>11</th>\n", | |
" <td>American Barbecue</td>\n", | |
" <td>1289</td>\n", | |
" <td>1255.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>12</th>\n", | |
" <td>Family Style</td>\n", | |
" <td>1106</td>\n", | |
" <td>1225.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>13</th>\n", | |
" <td>Rubix</td>\n", | |
" <td>1345</td>\n", | |
" <td>1225.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>14</th>\n", | |
" <td>Groove</td>\n", | |
" <td>1099</td>\n", | |
" <td>1201.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>Platypi</td>\n", | |
" <td>1304</td>\n", | |
" <td>1201.5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>16</th>\n", | |
" <td>Ursa Major</td>\n", | |
" <td>712</td>\n", | |
" <td>712.0</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Team Rating Re-Ordered\n", | |
"1 Mischief 1799 1799.0\n", | |
"2 Polar Bears 1582 1596.0\n", | |
"3 Blackbird 1610 1596.0\n", | |
"4 7 Figures 1513 1513.0\n", | |
"5 Dorado 1504 1504.0\n", | |
"6 BW Ultimate 1402 1402.0\n", | |
"7 Classy 1251 1301.5\n", | |
"8 Donuts 1352 1301.5\n", | |
"9 Long Beach Legacy 1291 1291.0\n", | |
"10 Alchemy 1222 1255.5\n", | |
"11 American Barbecue 1289 1255.5\n", | |
"12 Family Style 1106 1225.5\n", | |
"13 Rubix 1345 1225.5\n", | |
"14 Groove 1099 1201.5\n", | |
"15 Platypi 1304 1201.5\n", | |
"16 Ursa Major 712 712.0" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"combined = norcal.append(socal)\n", | |
"combined.sort_values(by='Re-Ordered', inplace=True, ascending=False)\n", | |
"combined.index = range(1, 17)\n", | |
"combined" | |
] | |
} | |
], | |
"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.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment