{"cells":[{"metadata":{},"cell_type":"markdown","source":"# ASHRAE Final Leaderboard\n**Warning this is not the offical finals standings but based off of data provided by kaggle**\n\nMedals are estimated using this kernel by @sheriytm:\nhttps://www.kaggle.com/sheriytm/ashrae-public-lb-before-rescoring\n\nThe second shakeup visualization uses a design by @pednoi - please upvote his kernel here: https://www.kaggle.com/pednoi/visualize-the-shakeups-of-10-recent-competitions"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport seaborn as sns\nimport matplotlib.pylab as plt\n\nimport plotly.graph_objs as go\nfrom plotly.offline import init_notebook_mode, iplot\n\npd.set_option('max_rows', 5000)\n\nlb = pd.read_csv('/kaggle/input/ashrae-interim-scores/final_leaderboard_order.csv')","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"lb['public_rank'] = lb['PublicScore'].rank().astype(int)\nlb['private_rank'] = lb['PrivateScore'].rank().astype(int)\nlb['shake'] = lb['public_rank'] - lb['private_rank']\nlb['TeamName'] = lb['TeamName'].str[:20]\nlb['medal'] = ''\nlb.loc[lb['private_rank'] <= 367, 'medal'] = '🥉'\nlb.loc[lb['private_rank'] <= 183, 'medal'] = '🥈'\nlb.loc[lb['private_rank'] <= 17, 'medal'] = '🥇'\nlb = lb[['private_rank','medal','shake',\n         'TeamName','PublicScore','PrivateScore',\n         'public_rank','SubmissionTimestamp']]","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"def color_negative_red(val):\n    \"\"\"\n    Takes a scalar and returns a string with\n    the css property `'color: red'` for negative\n    strings, black otherwise.\n    \"\"\"\n    try:\n        color = 'red' if val < 0 else 'black'\n    except:\n        color = 'black'\n    return 'color: %s' % color","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 2, figsize=(16, 8))\nlb.query('PublicScore < 6 and PrivateScore < 6') \\\n    .plot(x='PublicScore',\n        y='PrivateScore',\n        kind='scatter',\n        title='ASHRAE Shake < 6',\n         ax=axes[0])\nlb.query('PublicScore < 1.6 and PrivateScore < 1.6') \\\n    .plot(x='PublicScore',\n        y='PrivateScore',\n        kind='scatter',\n        title='ASHRAE Shake < 1.6',\n         ax=axes[1])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"def plot_candle(title, diff):\n    closes = np.array(range(len(diff)))+1\n    opens = closes + np.array(diff)\n    highs = np.where(np.array(diff)<0, closes, opens)\n    lows =  np.where(np.array(diff)>=0, closes, opens)\n    \n    hovertext = ['private lb: '+str(c)+'<br>public lb: '+str(o) for o, c in zip(opens, closes)]\n\n    trace = go.Ohlc(x=list(range(1, len(diff)+1)), open=opens, high=highs, low=lows, close=closes,\n                    increasing=dict(line=dict(color='#FF6699')), decreasing=dict(line=dict(color='#66DD99')),\n                    text=hovertext, hoverinfo='text')\n    \n    layout = go.Layout(\n        title = \"<b>%s</b>\" % title,\n        xaxis = dict(\n            title='final ranks',\n            rangeslider = dict(visible=False)\n        ), \n        yaxis=dict(\n            title='shakeups',\n            autorange='reversed'\n        )\n    )\n    \n    fig = go.Figure(data=[trace], layout=layout)    \n    iplot(fig, filename='shakeup_candlestick')\n\nplot_candle('ASHRAE Shakeup', lb['shake'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"lb.style.\\\n    applymap(color_negative_red) \\\n    .hide_index()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":1}