{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Looking at how teams improved Public LB score over time.\n** Last Updated June 3, 2019 - The final day of the competition**"},{"metadata":{},"cell_type":"markdown","source":"Example of how the plot works (gif not up to date with latest data):\n![](https://i.imgur.com/DHR598A.gif)"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":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.plotly as py\nimport plotly.graph_objs as go\nfrom plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\nplt.style.use('ggplot')\ncolor_pal = [x['color'] for x in plt.rcParams['axes.prop_cycle']]\n\n# Format the data\ndf = pd.read_csv('../input/lanl-leaderboard/LANL-Earthquake-Prediction-publicleaderboard_06_03_2019.csv')\ndf['SubmissionDate'] = pd.to_datetime(df['SubmissionDate'])\ndf = df.set_index(['TeamName','SubmissionDate'])['Score'].unstack(-1).T\ndf.columns = [name for name in df.columns]","execution_count":18,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Public LB Scores of Top Teams over time"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Interative Plotly\ninit_notebook_mode(connected=True)\nTOP_TEAMS = df.min().loc[df.min() < 1.29].index.values\ndf_filtered = df[TOP_TEAMS].ffill()\ndf_filtered = df_filtered.loc[df_filtered.index > '2019-04-21']\n# Create a trace\ndata = []\nfor col in df_filtered.columns:\n    data.append(go.Scatter(\n                        x = df_filtered.index,\n                        y = df_filtered[col],\n                        name=col)\n               )\n    \niplot(data)","execution_count":null,"outputs":[{"output_type":"display_data","data":{"text/html":"        <script type=\"text/javascript\">\n        window.PlotlyConfig = {MathJaxConfig: 'local'};\n        if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n        if (typeof require !== 'undefined') {\n        require.undef(\"plotly\");\n        requirejs.config({\n            paths: {\n                'plotly': ['https://cdn.plot.ly/plotly-latest.min']\n            }\n        });\n        require(['plotly'], function(Plotly) {\n            window._Plotly = Plotly;\n        });\n        }\n        </script>\n        "},"metadata":{}}]},{"metadata":{},"cell_type":"markdown","source":"# All competitors LB Position over Time"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Scores of top teams over time\nALL_TEAMS = df.columns.values\ndf[ALL_TEAMS].ffill().plot(figsize=(20, 10),\n                           ylim=(1.0, 1.8),\n                           color=color_pal[0],\n                           legend=False,\n                           alpha=0.01,\n                           title='All LANL Teams Scores over Time')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Top LB Scores"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Create Top Teams List\nTOP_TEAMS = df.min().loc[df.min() < 1.35].index.values\ndf[TOP_TEAMS].min().sort_values().plot(kind='barh',\n                                       xlim=(1.0, 1.36),\n                                       title='Teams with Scores less than 1.35',\n                                       figsize=(12, 15),\n                                       color=color_pal[3])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Count of LB Submissions that improved score\n## \"Slow and Steady wins the race\" ~or~ \"Keep overfitting until LB improves\"?\nThis is the count of times the person submitted and got the fun \"You're score improved\" notification. This is not the total submission count."},{"metadata":{"trusted":true},"cell_type":"code","source":"df[TOP_TEAMS].nunique().sort_values().plot(kind='barh',\n                                           figsize=(12, 15),\n                                           color=color_pal[1],\n                                           title='Count of Submissions improving LB score by Team')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Number of teams by date"},{"metadata":{"trusted":true},"cell_type":"code","source":"df.ffill().count(axis=1).plot(figsize=(20, 5), title='Number of Teams in the Competition by Date')\nplt.show()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}