{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"markdown","source":"## Let us track the public LB standings of Understanding Clouds from Satellite Images\nReference: https://www.kaggle.com/robikscube/the-race-to-predict-molecular-properties/data\n\nLast updated: Nov 16, 2019"},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","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 os\nimport matplotlib.pylab as plt\nimport plotly\nimport plotly.graph_objs as go\nfrom plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\nfrom sklearn.linear_model import LinearRegression\nimport datetime\nimport colorlover as cl\nplt.style.use('ggplot')\ncolor_pal = [x['color'] for x in plt.rcParams['axes.prop_cycle']]","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"","_uuid":"","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# Format the dataa\ndf = pd.read_csv('../input/cloud-leaderboard-race/understanding_cloud_organization-publicleaderboard-nov16.csv')\ndf['SubmissionDate'] = pd.to_datetime(df['SubmissionDate'])\ndf_tmp = df.set_index(['TeamName','SubmissionDate'])['Score']\ndf = df_tmp[~df_tmp.index.duplicated()]\ndf = df.unstack(-1).T\ndf.columns = [name for name in df.columns]\n \nTWELFTH_SCORE = df.max().sort_values(ascending=False)[15]\nTOP_SCORE = df.max().sort_values(ascending=False)[0]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Race after Oct 20"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# Interative Plotly\nmypal = cl.scales['9']['div']['Spectral']\ncolors = cl.interp( mypal, 15 )\nannotations = []\ninit_notebook_mode(connected=True)\nTOP_TEAMS = df.max().loc[df.max() > TWELFTH_SCORE].sort_values(ascending=False).index[:12].values\ndf_filtered = df[TOP_TEAMS].ffill()\ndf_filtered = df_filtered[df_filtered.index >= pd.to_datetime('2019-10-20')]\nteam_ordered = df_filtered.loc[df_filtered.index.max()] \\\n    .sort_values(ascending=False).index.tolist()\n\ndata = []\ni = 0\nfor col in df_filtered[team_ordered].columns:\n    data.append(go.Scatter(\n                        x = df_filtered.index,\n                        y = df_filtered[col],\n                        name=col,\n                        line=dict(color=colors[i], width=2),)\n               )\n    i += 1\n\nannotations.append(dict(xref='paper', yref='paper', x=0.0, y=1.05,\n                              xanchor='left', yanchor='bottom',\n                              text='Cloud Leaderboard Tracking',\n                              font=dict(family='Arial',\n                                        size=30,\n                                        color='rgb(37,37,37)'),\n                              showarrow=False))\n\nlayout = go.Layout(yaxis=dict(range=[TOP_SCORE-0.02, TOP_SCORE+0.01]),\n                   hovermode='x',\n                   plot_bgcolor='white',\n                  annotations=annotations,\n                  )\nfig = go.Figure(data=data, layout=layout)\nfig.update_layout(\n    legend=go.layout.Legend(\n        traceorder=\"normal\",\n        font=dict(\n            family=\"sans-serif\",\n            size=12,\n            color=\"black\"\n        ),\n        bgcolor=\"LightSteelBlue\",\n        bordercolor=\"Black\",\n        borderwidth=2,\n    )\n)\n\nfig.update_layout(legend_orientation=\"h\")\nfig.update_layout(template=\"plotly_white\")\n#fig.update_yaxes(showgrid=True, gridwidth=0.5, gridcolor='LightGrey')\nfig.update_xaxes(showgrid=False)\n\niplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","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}