{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# packages\n\n# standard\nimport numpy as np\nimport pandas as pd\nimport time\n\n# plots\nimport matplotlib.pyplot as plt\nimport plotly.express as px\nimport seaborn as sns","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-25T09:32:53.172442Z","iopub.execute_input":"2021-11-25T09:32:53.172836Z","iopub.status.idle":"2021-11-25T09:32:55.150872Z","shell.execute_reply.started":"2021-11-25T09:32:53.172759Z","shell.execute_reply":"2021-11-25T09:32:55.150118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show files\n!ls -l '../input/g-research-crypto-forecasting/'","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:32:55.153192Z","iopub.execute_input":"2021-11-25T09:32:55.153417Z","iopub.status.idle":"2021-11-25T09:32:55.446089Z","shell.execute_reply.started":"2021-11-25T09:32:55.153386Z","shell.execute_reply":"2021-11-25T09:32:55.445514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load asset details table\ndf_assets = pd.read_csv('../input/g-research-crypto-forecasting/asset_details.csv')\ndf_assets","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:32:55.448258Z","iopub.execute_input":"2021-11-25T09:32:55.448505Z","iopub.status.idle":"2021-11-25T09:32:55.472401Z","shell.execute_reply.started":"2021-11-25T09:32:55.448471Z","shell.execute_reply":"2021-11-25T09:32:55.471958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot asset weights\nplt.bar(height=df_assets.Weight, x=df_assets.Asset_Name)\nplt.title('Asset Weights')\nplt.xticks(rotation=90)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:32:55.473991Z","iopub.execute_input":"2021-11-25T09:32:55.474715Z","iopub.status.idle":"2021-11-25T09:32:55.709581Z","shell.execute_reply.started":"2021-11-25T09:32:55.474686Z","shell.execute_reply":"2021-11-25T09:32:55.709016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load training data (takes some time...)\nt1 = time.time()\ndf_train = pd.read_csv('../input/g-research-crypto-forecasting/train.csv')\nt2 = time.time()\nprint('Elapsed time [s]: ', np.round(t2-t1,2))","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:32:55.710596Z","iopub.execute_input":"2021-11-25T09:32:55.710880Z","iopub.status.idle":"2021-11-25T09:33:48.473044Z","shell.execute_reply.started":"2021-11-25T09:32:55.710856Z","shell.execute_reply":"2021-11-25T09:33:48.472399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:48.474107Z","iopub.execute_input":"2021-11-25T09:33:48.475189Z","iopub.status.idle":"2021-11-25T09:33:48.490200Z","shell.execute_reply.started":"2021-11-25T09:33:48.475146Z","shell.execute_reply":"2021-11-25T09:33:48.489392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# data frame structure\ndf_train.info(verbose=True, show_counts=True)","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:48.491429Z","iopub.execute_input":"2021-11-25T09:33:48.491593Z","iopub.status.idle":"2021-11-25T09:33:48.855481Z","shell.execute_reply.started":"2021-11-25T09:33:48.491574Z","shell.execute_reply":"2021-11-25T09:33:48.854461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot target\ndf_train.Target.plot(kind='hist', bins=100)\nplt.title('Target (histogram)')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:48.856656Z","iopub.execute_input":"2021-11-25T09:33:48.857111Z","iopub.status.idle":"2021-11-25T09:33:52.312849Z","shell.execute_reply.started":"2021-11-25T09:33:48.857078Z","shell.execute_reply":"2021-11-25T09:33:52.312290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot target\ndf_train.Target.plot(kind='box', vert=False)\nplt.title('Target (boxplot)')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:52.313776Z","iopub.execute_input":"2021-11-25T09:33:52.314024Z","iopub.status.idle":"2021-11-25T09:33:55.954271Z","shell.execute_reply.started":"2021-11-25T09:33:52.314001Z","shell.execute_reply":"2021-11-25T09:33:55.953738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# basic stats\ndf_train.Target.describe(percentiles=[0.01,0.1,0.25,0.5,0.75,0.9,0.99])","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:55.955800Z","iopub.execute_input":"2021-11-25T09:33:55.956056Z","iopub.status.idle":"2021-11-25T09:33:56.815881Z","shell.execute_reply.started":"2021-11-25T09:33:55.956034Z","shell.execute_reply":"2021-11-25T09:33:56.815100Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Plot each asset","metadata":{}},{"cell_type":"markdown","source":"### Volume Weighted Asset Price","metadata":{}},{"cell_type":"code","source":"for my_id in range(0,14):\n    df_select = df_train[df_train.Asset_ID==my_id]\n    plt.figure(figsize=(14,4))\n    plt.scatter(df_select.timestamp, df_select.VWAP, s=1)\n    my_title='Asset ID: ' + str(my_id) + ' - ' + df_assets[df_assets.Asset_ID==my_id].reset_index().Asset_Name[0]\n    plt.title(my_title)\n    plt.grid()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:33:56.816811Z","iopub.execute_input":"2021-11-25T09:33:56.817011Z","iopub.status.idle":"2021-11-25T09:34:14.049355Z","shell.execute_reply.started":"2021-11-25T09:33:56.816985Z","shell.execute_reply":"2021-11-25T09:34:14.048302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Target","metadata":{}},{"cell_type":"code","source":"for my_id in range(0,14):\n    df_select = df_train[df_train.Asset_ID==my_id]\n    plt.figure(figsize=(14,4))\n    plt.scatter(df_select.timestamp, df_select.Target, s=1)\n    my_title='Asset ID: ' + str(my_id) + ' - ' + df_assets[df_assets.Asset_ID==my_id].reset_index().Asset_Name[0]\n    plt.title(my_title)\n    plt.grid()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:34:14.050574Z","iopub.execute_input":"2021-11-25T09:34:14.050737Z","iopub.status.idle":"2021-11-25T09:34:31.528054Z","shell.execute_reply.started":"2021-11-25T09:34:14.050715Z","shell.execute_reply":"2021-11-25T09:34:31.526421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Target distribution by asset","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(14,6))\nsns.violinplot(data=df_train, x='Asset_ID', y='Target')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:34:31.531480Z","iopub.execute_input":"2021-11-25T09:34:31.531729Z","iopub.status.idle":"2021-11-25T09:35:44.725429Z","shell.execute_reply.started":"2021-11-25T09:34:31.531702Z","shell.execute_reply":"2021-11-25T09:35:44.724469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Zoom in:","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(14,6))\nsns.violinplot(data=df_train, x='Asset_ID', y='Target')\nplt.ylim(-0.02,0.02)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-25T09:37:45.321291Z","iopub.execute_input":"2021-11-25T09:37:45.321517Z","iopub.status.idle":"2021-11-25T09:38:59.312784Z","shell.execute_reply.started":"2021-11-25T09:37:45.321495Z","shell.execute_reply":"2021-11-25T09:38:59.311783Z"},"trusted":true},"execution_count":null,"outputs":[]}]}