{"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":"from mpl_toolkits import mplot3d\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom ipywidgets import interact, interactive, fixed, interact_manual\nimport ipywidgets as widgets\nfrom IPython.display import display\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os,gc,pickle\nimport tensorflow as tf\nfrom sklearn.decomposition import PCA\nfrom sklearn.model_selection import KFold,GroupKFold,train_test_split\nfrom sklearn.preprocessing import StandardScaler,MinMaxScaler\nfrom tqdm.notebook import tqdm\nimport tensorflow as tf\nimport tensorflow.keras.backend as K\nfrom tensorflow.keras.models import Model, load_model\nfrom tensorflow.keras.callbacks import ReduceLROnPlateau, LearningRateScheduler, EarlyStopping\nfrom tensorflow.keras.layers import Dense, Input, Concatenate\nfrom tensorflow.keras.utils import plot_model\nimport keras_tuner\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    print(dirname)\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))","metadata":{"_uuid":"49f4ac39-493a-4c93-8931-656ec3615ec1","_cell_guid":"6dc5674d-486a-4bb2-a208-44c4f50e2e1a","collapsed":false,"_kg_hide-input":true,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:18.425604Z","iopub.execute_input":"2022-10-06T11:12:18.426078Z","iopub.status.idle":"2022-10-06T11:12:26.658109Z","shell.execute_reply.started":"2022-10-06T11:12:18.425990Z","shell.execute_reply":"2022-10-06T11:12:26.656559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Credits\nSpecial thanks to [AmbrosM](https://www.kaggle.com/ambrosm) for his  [MSCI CITEseq Keras Quickstart](https://www.kaggle.com/code/ambrosm/msci-citeseq-keras-quickstart) and [MSCI Multiome Quickstart](https://www.kaggle.com/code/ambrosm/msci-multiome-quickstart) notebooks. I used his model for training and optimization with a little bit change.","metadata":{"_uuid":"85e34d79-61ce-49e6-9921-4bb9ac4d2fc3","_cell_guid":"bb37895e-f405-48b2-a304-6e929ae7a2e0","trusted":true}},{"cell_type":"markdown","source":"# Importing Data","metadata":{"_uuid":"d3c906f8-59d0-4d28-9181-250301771a9e","_cell_guid":"79974e33-659b-4cd8-806b-50789e6ab3d9","trusted":true}},{"cell_type":"markdown","source":"<p><strong>Columns:</strong></p>\n<ul>\n<li><p><strong><code>game_num</code></strong> <em>(train only)</em>: Unique identifier for the game from which the event was taken.</p></li>\n<li><p><strong><code>event_id</code></strong> <em>(train only)</em>: Unique identifier for the sequence of consecutive frames.</p></li>\n<li><p><strong><code>event_time</code></strong> <em>(train only)</em>: Time in seconds before the event ended, either by a goal being scored or simply when we decided to truncate the timeseries if a goal was not scored.</p></li>\n<li><p><strong><code>ball_pos_[xyz]</code></strong>: Ball's position as a 3d vector.</p></li>\n<li><p><strong><code>ball_vel_[xyz]</code></strong>: Ball's velocity as a 3d vector.</p></li>\n<li><p>For <code>i</code> in <code>[0, 6)</code>:</p>\n<ul>\n<li><strong><code>p{i}_pos_[xyz]</code></strong>: Player <code>i</code>'s position as a 3d vector.</li>\n<li><strong><code>p{i}_vel_[xyz]</code></strong>: Player <code>i</code>'s velocity as a 3d vector.</li>\n<li><strong><code>p{i}_boost</code></strong>: Player <code>i</code>'s boost remaining, in <code>[0, 100]</code>. A player can consume boost to substantially increase their speed, and is required to fly up into the <code>z</code> dimension (besides driving up a wall, or the small air gained by a jump).</li>\n<li>All <code>p{i}</code> columns will be <code>NaN</code> if and only if the player is demolished (destroyed by an enemy player; will respawn within a few seconds).</li>\n<li>Players 0, 1, and 2 make up team <code>A</code> and players 3, 4, and 5 make up team <code>B</code>.</li>\n<li>The orientation vector of the player's car (which way the car is facing) does not necessarily match the player's velocity vector, and this dataset does not capture orientation data.</li></ul></li>\n<li><p>For <code>i</code> in <code>[0, 6)</code>:</p>\n<ul>\n<li><strong><code>boost{i}_timer</code></strong>: Time in seconds until big boost orb <code>i</code> respawns, or <code>0</code> if it's available. Big boost orbs grant a full 100 boost to a player driving over it. The orb <code>(x, y)</code> locations are roughly <code>[ (-61.4, -81.9), (61.4, -81.9), (-71.7, 0), (71.7, 0), (-61.4, 81.9), (61.4, 81.9) ]</code> with <code>z = 0</code>.  (Players can also gain boost from small boost pads across the map, but we do not capture those pads in this dataset).</li></ul></li>\n<li><p><strong><code>player_scoring_next</code></strong> <em>(train only)</em>: Which player scores at the end of the current event, in <code>[0, 6)</code>, or <code>-1</code> if the event does not end in a goal.</p></li>\n<li><p><strong><code>team_scoring_next</code></strong> <em>(train only)</em>: Which team scores at the end of the current event (<code>A</code> or <code>B</code>), or <code>NaN</code> if the event does not end in a goal.</p></li>\n<li><p><strong><code>team_[A|B]_scoring_within_10sec</code></strong> <em>(train only)</em>: <strong>[Target columns]</strong> Value of <code>1</code> if <code>team_scoring_next == [A|B]</code> and <code>time_before_event</code> is in <code>[-10, 0]</code>, otherwise <code>0</code>.</p></li>\n<li><p><strong><code>id</code></strong> <em>(test and submission only)</em>: Unique identifier for each test row. Your submission should be a pair of  <code>team_A_scoring_within_10sec</code> and <code>team_B_scoring_within_10sec</code> probability predictions for each <code>id</code>, where your predictions can range the real numbers from <code>[0, 1]</code>.</p></li>\n</ul>","metadata":{"_uuid":"cf2d18a8-5e6a-46c0-b3ea-c14fddf1f021","_cell_guid":"2399769a-2dd0-41b6-b67c-658ecd7f4346","trusted":true}},{"cell_type":"markdown","source":"With read_subset method, we will read data and drop least event games and fill na values with .fillna(method=\"bfill\").fillna(method=\"ffill\") method.","metadata":{"_uuid":"3d52ab1a-89c0-4ffb-a36d-c64fe173506f","_cell_guid":"e42823e7-934f-4ff9-a5cb-f34616850005","trusted":true}},{"cell_type":"code","source":"def read_subset(cols_train=None,cols_test=None,df =None,drop=False, drop_index=None):\n    \"\"\"\n    \"\"\n    df : 'str' , {'train','test','both'} | 'train' return only train df , 'both' return both train and test df\n    cols: 'list',  reading for columns subset\n     columns_train:  ['game_num', 'event_id', 'event_time', 'ball_pos_x', 'ball_pos_y',\n    'ball_pos_z', 'ball_vel_x', 'ball_vel_y', 'ball_vel_z', 'p0_pos_x',\n    'p0_pos_y', 'p0_pos_z', 'p0_vel_x', 'p0_vel_y', 'p0_vel_z', 'p0_boost',\n    'p1_pos_x', 'p1_pos_y', 'p1_pos_z', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z',\n    'p1_boost', 'p2_pos_x', 'p2_pos_y', 'p2_pos_z', 'p2_vel_x', 'p2_vel_y',\n    'p2_vel_z', 'p2_boost', 'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p3_vel_x',\n    'p3_vel_y', 'p3_vel_z', 'p3_boost', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z',\n    'p4_vel_x', 'p4_vel_y', 'p4_vel_z', 'p4_boost', 'p5_pos_x', 'p5_pos_y',\n    'p5_pos_z', 'p5_vel_x', 'p5_vel_y', 'p5_vel_z', 'p5_boost',\n    'boost0_timer', 'boost1_timer', 'boost2_timer', 'boost3_timer',\n    'boost4_timer', 'boost5_timer', 'player_scoring_next',\n    'team_scoring_next', 'team_A_scoring_within_10sec',\n    'team_B_scoring_within_10sec']\n    \"\"\n    columns_test:  ['id', 'ball_pos_x', 'ball_pos_y', 'ball_pos_z', 'ball_vel_x',\n       'ball_vel_y', 'ball_vel_z', 'p0_pos_x', 'p0_pos_y', 'p0_pos_z',\n       'p0_vel_x', 'p0_vel_y', 'p0_vel_z', 'p0_boost', 'p1_pos_x', 'p1_pos_y',\n       'p1_pos_z', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p1_boost', 'p2_pos_x',\n       'p2_pos_y', 'p2_pos_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', 'p2_boost',\n       'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p3_vel_x', 'p3_vel_y', 'p3_vel_z',\n       'p3_boost', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z', 'p4_vel_x', 'p4_vel_y',\n       'p4_vel_z', 'p4_boost', 'p5_pos_x', 'p5_pos_y', 'p5_pos_z', 'p5_vel_x',\n       'p5_vel_y', 'p5_vel_z', 'p5_boost', 'boost0_timer', 'boost1_timer',\n       'boost2_timer', 'boost3_timer', 'boost4_timer', 'boost5_timer']\n    \n    \\n\n    \"\"\n    \"\"\"\n    if df=='train':\n        if drop:\n        \n        \n            train = pd.concat([pd.read_parquet(f\"../input/tpsoct22-parquet/train_{i}.parquet.gzip\",\n                                               columns=cols_train).set_index(\"game_num\")\\\n                                           .drop(index=drop_index,errors=\"ignore\").fillna(method=\"bfill\").fillna(method=\"ffill\").reset_index()\n                               for i in range(10)],axis=0)\n        else:\n            train = pd.concat([pd.read_parquet(f\"../input/tpsoct22-parquet/train_{i}.parquet.gzip\",\n                                               columns=cols_train)\n                               for i in range(10)],axis=0)\n        return train\n    elif df=='test':\n        test = pd.read_parquet(f\"../input/tpsoct22-parquet/test.parquet.gzip\",columns=cols_test).fillna(method=\"bfill\").fillna(method=\"ffill\")\n        return test\n    elif df=='both':\n        if drop:\n        \n        \n            train = pd.concat([pd.read_parquet(f\"../input/tpsoct22-parquet/train_{i}.parquet.gzip\",\n                                               columns=cols_train).set_index(\"game_num\")\\\n                                               .drop(index=drop_index,errors=\"ignore\").fillna(method=\"bfill\").fillna(method=\"ffill\").reset_index()\n                               for i in range(10)],axis=0)\n        else:\n            train = pd.concat([pd.read_parquet(f\"../input/tpsoct22-parquet/train_{i}.parquet.gzip\",\n                                               columns=cols_train)\n                               for i in range(10)],axis=0)\n        test = pd.read_parquet(f\"../input/tpsoct22-parquet/test.parquet.gzip\",columns=cols_test,errors=\"ignore\")\n        return train,test","metadata":{"_uuid":"a4ed2bc9-bbea-4799-97f6-9b68c73d2547","_cell_guid":"cdb8d3cd-6969-4460-ac2e-378805ba7085","collapsed":false,"_kg_hide-input":true,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:26.661388Z","iopub.execute_input":"2022-10-06T11:12:26.662305Z","iopub.status.idle":"2022-10-06T11:12:26.679994Z","shell.execute_reply.started":"2022-10-06T11:12:26.662257Z","shell.execute_reply":"2022-10-06T11:12:26.678063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# We will use this subset for determining for which games have least \n# events and we will drop them as row from training data while \n# we reading data.\ncols=['game_num', 'event_id', 'event_time']\n\ntrain0= read_subset(cols_train=cols,cols_test=None,df ='train')","metadata":{"_uuid":"d91e33ae-99e6-4492-8a0a-7abebd10b74d","_cell_guid":"f45b759b-764e-4a8e-a097-389ebcf6620f","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:26.682535Z","iopub.execute_input":"2022-10-06T11:12:26.683711Z","iopub.status.idle":"2022-10-06T11:12:30.313398Z","shell.execute_reply.started":"2022-10-06T11:12:26.683650Z","shell.execute_reply":"2022-10-06T11:12:30.312026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train0.head(3)","metadata":{"_uuid":"ad12ba7d-09a1-4b39-84aa-eee07bdf2b60","_cell_guid":"2f9ecd0e-308c-4206-9fc5-d4f7a726b3ac","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:30.317124Z","iopub.execute_input":"2022-10-06T11:12:30.317978Z","iopub.status.idle":"2022-10-06T11:12:30.339197Z","shell.execute_reply.started":"2022-10-06T11:12:30.317920Z","shell.execute_reply":"2022-10-06T11:12:30.337430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train0.game_num.value_counts()[0:10].plot(kind=\"bar\")\nplt.xlabel(\"game_num\")\nplt.title(\"top 10 most events games \");","metadata":{"_uuid":"3631b690-93cf-4f85-aaa9-12fa6316309f","_cell_guid":"552ff1d2-20ff-447d-a6e6-c5c384328071","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:30.340811Z","iopub.execute_input":"2022-10-06T11:12:30.342033Z","iopub.status.idle":"2022-10-06T11:12:30.829733Z","shell.execute_reply.started":"2022-10-06T11:12:30.341975Z","shell.execute_reply":"2022-10-06T11:12:30.828258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train0.game_num.value_counts()[-10:].plot(kind=\"bar\")\nplt.xlabel(\"game_num\")\nplt.title(\"top 10 least event games \");","metadata":{"_uuid":"0b25f38f-56d3-419e-81ac-72f7c48e0fdb","_cell_guid":"31d48017-0752-4700-bfaf-9da6363757ef","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:30.832147Z","iopub.execute_input":"2022-10-06T11:12:30.833021Z","iopub.status.idle":"2022-10-06T11:12:31.297756Z","shell.execute_reply.started":"2022-10-06T11:12:30.832961Z","shell.execute_reply":"2022-10-06T11:12:31.296404Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We will drop least event games for training, and train with ~21M samples/rows. Another word, 7300 matches will be on , 65 matches matches will be off.","metadata":{"_uuid":"1db3217d-90a5-47ee-9cb0-fc1d08d77e11","_cell_guid":"91ee34b6-9e3b-4a1f-8c29-e1f37e5aa5a7","trusted":true}},{"cell_type":"code","source":"drop_games =train0.game_num.value_counts()[7300:].index","metadata":{"_uuid":"8afd07b9-a4d5-4449-9a1d-44226853923c","_cell_guid":"8c023736-5998-4fd5-9b01-41cd3d68e104","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:31.299604Z","iopub.execute_input":"2022-10-06T11:12:31.303424Z","iopub.status.idle":"2022-10-06T11:12:31.446642Z","shell.execute_reply.started":"2022-10-06T11:12:31.303391Z","shell.execute_reply":"2022-10-06T11:12:31.445127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"drop_games","metadata":{"_uuid":"a5f46c9b-4779-4721-84ac-9c4aafe4c57c","_cell_guid":"425650e6-a6c6-4a1e-ae98-b2b6ca86fa02","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:31.448865Z","iopub.execute_input":"2022-10-06T11:12:31.449772Z","iopub.status.idle":"2022-10-06T11:12:31.462995Z","shell.execute_reply.started":"2022-10-06T11:12:31.449723Z","shell.execute_reply":"2022-10-06T11:12:31.461414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n# now selecting training columns and reading training data\ncols3=[\"game_num\",'ball_pos_x', 'ball_pos_y', 'ball_pos_z', 'ball_vel_x',\n   'ball_vel_y', 'ball_vel_z', 'p0_pos_x', 'p0_pos_y', 'p0_pos_z',\n   'p0_vel_x', 'p0_vel_y', 'p0_vel_z', 'p0_boost', 'p1_pos_x', 'p1_pos_y',\n   'p1_pos_z', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p1_boost', 'p2_pos_x',\n   'p2_pos_y', 'p2_pos_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', 'p2_boost',\n   'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p3_vel_x', 'p3_vel_y', 'p3_vel_z',\n   'p3_boost', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z', 'p4_vel_x', 'p4_vel_y',\n   'p4_vel_z', 'p4_boost', 'p5_pos_x', 'p5_pos_y', 'p5_pos_z', 'p5_vel_x',\n   'p5_vel_y', 'p5_vel_z', 'p5_boost']\n\n\ntrain3 = read_subset(cols_train=cols3,\n                     cols_test=None,\n                     df ='train',\n                     drop=True,\n                     drop_index=drop_games)\\\n                        .drop(columns=[\"game_num\"])\\\n                            .astype(np.float16)\ngc.collect()","metadata":{"_uuid":"0851cef2-4b1d-47d5-bde2-c22c2f12178e","_cell_guid":"3055d1eb-8ea0-4db9-8441-0d63bab37f73","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:12:31.465645Z","iopub.execute_input":"2022-10-06T11:12:31.466125Z","iopub.status.idle":"2022-10-06T11:14:16.074074Z","shell.execute_reply.started":"2022-10-06T11:12:31.466069Z","shell.execute_reply":"2022-10-06T11:14:16.072534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def feat(df):\n    df['ball_pos_mean'] = df[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].mean(axis=1)\n    df['ball_vel_mean'] = df[['ball_vel_x', 'ball_vel_y', 'ball_vel_z']].mean(axis=1)\n    df['ball_pos_std'] = df[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].std(axis=1)\n    df['ball_vel_std'] = df[['ball_vel_x', 'ball_vel_y', 'ball_vel_z']].std(axis=1)\n    for i in range(6):       \n        for col in [f'p{i}_pos_x', f'p{i}_pos_y', f'p{i}_pos_z']:\n            df[col] = (df[col] / ( np.linalg.norm(df[[f'p{i}_pos_x', f'p{i}_pos_y',f'p{i}_pos_z'] ],axis=1)))\n        for col in [f'p{i}_vel_x', f'p{i}_vel_y', f'p{i}_vel_z']:\n            df[col] = (df[col] / ( np.linalg.norm(df[[f'p{i}_vel_x', f'p{i}_vel_y',f'p{i}_vel_z'] ],axis=1)))\n    for col in ['ball_pos_x', 'ball_pos_y', 'ball_pos_z']:\n        df[col] = (df[col] / ( np.linalg.norm(df[['ball_pos_x', 'ball_pos_y', 'ball_pos_z'] ],axis=1)))\n    for col in ['ball_vel_x', 'ball_vel_y', 'ball_vel_z']:\n        df[col] = (df[col] / ( np.linalg.norm(df[['ball_vel_x', 'ball_vel_y', 'ball_vel_z'] ],axis=1 )))\n    print(\"done!\")","metadata":{"execution":{"iopub.status.busy":"2022-10-06T11:14:16.078873Z","iopub.execute_input":"2022-10-06T11:14:16.079276Z","iopub.status.idle":"2022-10-06T11:14:16.093372Z","shell.execute_reply.started":"2022-10-06T11:14:16.079225Z","shell.execute_reply":"2022-10-06T11:14:16.091685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We will use scaler.partial_fit method for ram efficiency or we will run out of ram.","metadata":{"_uuid":"ade21fdb-4b29-4eb5-80fa-b42530d802e4","_cell_guid":"030cf7ac-844b-482f-bfd0-5b8484b528e7","trusted":true}},{"cell_type":"code","source":"%%time\nfeat(train3)","metadata":{"execution":{"iopub.status.busy":"2022-10-06T11:14:16.095881Z","iopub.execute_input":"2022-10-06T11:14:16.096384Z","iopub.status.idle":"2022-10-06T11:16:55.583098Z","shell.execute_reply.started":"2022-10-06T11:14:16.096341Z","shell.execute_reply":"2022-10-06T11:16:55.581570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train3=train3.fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-10-06T11:16:55.585492Z","iopub.execute_input":"2022-10-06T11:16:55.585974Z","iopub.status.idle":"2022-10-06T11:17:01.816399Z","shell.execute_reply.started":"2022-10-06T11:16:55.585931Z","shell.execute_reply":"2022-10-06T11:17:01.814974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sc = MinMaxScaler()","metadata":{"_uuid":"844178cd-db94-4b9f-913e-dbcd846b8f88","_cell_guid":"6966d38a-80ea-4448-9da5-645c100c3831","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:17:01.821998Z","iopub.execute_input":"2022-10-06T11:17:01.829341Z","iopub.status.idle":"2022-10-06T11:17:01.838053Z","shell.execute_reply.started":"2022-10-06T11:17:01.829308Z","shell.execute_reply":"2022-10-06T11:17:01.836705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"batch_size = 1000000\nbatch_count = train3.shape[0]//batch_size+1\nbatch_count","metadata":{"_uuid":"35731a18-0e7d-4e7f-aa70-62ec91e648c8","_cell_guid":"4de60b15-aac5-4bef-9a92-13640706fc25","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:17:01.843388Z","iopub.execute_input":"2022-10-06T11:17:01.844520Z","iopub.status.idle":"2022-10-06T11:17:01.859760Z","shell.execute_reply.started":"2022-10-06T11:17:01.844479Z","shell.execute_reply":"2022-10-06T11:17:01.858453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in tqdm(range(batch_count)):\n    # StandartScaler and MinMaxScaler have partial fit method. Also sklearn SGDRegressor and \n    # incrementalPCA have partial fit method.\n    sc.partial_fit(train3[i*batch_size:(i+1)*batch_size])\n    gc.collect()","metadata":{"_uuid":"425347e0-9691-4da5-afb5-04335100b0e5","_cell_guid":"6da99f9f-6641-402e-bf1c-808067e633a3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:17:01.865110Z","iopub.execute_input":"2022-10-06T11:17:01.869358Z","iopub.status.idle":"2022-10-06T11:17:39.620474Z","shell.execute_reply.started":"2022-10-06T11:17:01.869315Z","shell.execute_reply":"2022-10-06T11:17:39.618928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train3 = sc.transform(train3).astype(np.float16)","metadata":{"_uuid":"4dd30e89-c24d-4f45-946e-c9c7b356c93c","_cell_guid":"3c3ae23f-5a6f-4574-96f4-f2459c9ec3f3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:17:39.622418Z","iopub.execute_input":"2022-10-06T11:17:39.624487Z","iopub.status.idle":"2022-10-06T11:18:19.467584Z","shell.execute_reply.started":"2022-10-06T11:17:39.624442Z","shell.execute_reply":"2022-10-06T11:18:19.466221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train3.shape","metadata":{"_uuid":"202d9477-71d1-462e-9614-2a5bf830088c","_cell_guid":"222ef5d0-fa55-43b1-8819-17614aac6573","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:19:30.588214Z","iopub.execute_input":"2022-10-06T11:19:30.588683Z","iopub.status.idle":"2022-10-06T11:19:30.598394Z","shell.execute_reply.started":"2022-10-06T11:19:30.588643Z","shell.execute_reply":"2022-10-06T11:19:30.596511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# targets subset, also will drop same drop_games for targets\ncols_target=['game_num','team_A_scoring_within_10sec',\n'team_B_scoring_within_10sec' ]","metadata":{"_uuid":"b3219b6a-36f8-47f6-b738-c552272b99d3","_cell_guid":"b653562b-6824-4adb-a8c1-272acbcf4ec6","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:19.483408Z","iopub.execute_input":"2022-10-06T11:18:19.484499Z","iopub.status.idle":"2022-10-06T11:18:19.490843Z","shell.execute_reply.started":"2022-10-06T11:18:19.484455Z","shell.execute_reply":"2022-10-06T11:18:19.489368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\ntargets = read_subset(cols_train=cols_target,\n                     cols_test=None,\n                     df ='train',\n                     drop=True,\n                     drop_index=drop_games)\\\n                        .drop(columns=[\"game_num\"]).values.astype(np.float16)\n                            \ngc.collect()","metadata":{"_uuid":"11be172c-01e5-434b-8cc9-8ffa098c59bd","_cell_guid":"0ce8f962-84d6-4c47-b551-5038455efc97","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:19.493107Z","iopub.execute_input":"2022-10-06T11:18:19.494071Z","iopub.status.idle":"2022-10-06T11:18:24.703627Z","shell.execute_reply.started":"2022-10-06T11:18:19.494025Z","shell.execute_reply":"2022-10-06T11:18:24.702183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train3.shape,targets.shape","metadata":{"_uuid":"a8a10ee8-ef65-41b6-8da3-2d52bf4a534d","_cell_guid":"dbf610b9-9551-400e-bef2-0e29eea37244","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:24.706972Z","iopub.execute_input":"2022-10-06T11:18:24.707702Z","iopub.status.idle":"2022-10-06T11:18:24.717404Z","shell.execute_reply.started":"2022-10-06T11:18:24.707669Z","shell.execute_reply":"2022-10-06T11:18:24.715713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Callbacks","metadata":{"_uuid":"4ad8a42c-79be-4406-9bfb-42857ef913ee","_cell_guid":"69c959fa-c42a-40d4-9798-946dd7f75381","trusted":true}},{"cell_type":"code","source":"epochs = 100\nlr = 0.01\ndecay_steps=epochs\nalpha=.00001\ndef scheduler(step): # lr cosine_decay\n    step = min(step, decay_steps)\n    cosine_decay = 0.5 * (1 + np.cos(np.pi * step / decay_steps))\n    decayed = (1 - alpha) * cosine_decay + alpha\n    return float(lr * decayed)\n# def scheduler2(epoch, lr): # lr exponentional_decay\n#     if epoch < 4:\n#         return lr\n#     else:\n#         return lr * tf.math.exp(-0.0225)\n\nepochs = 100\n\ndef plot_lr_decay(epochs,lr):\n    x = np.arange(0,epochs)\n    lrs = [] \n    lr2=lr\n    for epoch in x:\n        # if you use scheduler2 add here lr value like\n#         lr =  scheduler2(epoch,lr) \n        lr =  scheduler(epoch) \n        lrs.append(lr)\n    y = np.array(lrs)\n    plt.figure(figsize=(8,4))\n    plt.plot(x,y)\n    plt.vlines(x=45,linestyles=\"--\",colors=\"r\",ymin=y[-1],ymax=lr2)\n    plt.xlabel(\"epochs\")\n    plt.ylabel(\"learning rate\")\n    plt.title(\"learning rate decay\")\n    plt.show()\nlrDecay = tf.keras.callbacks.LearningRateScheduler(scheduler)\nplot_lr_decay(epochs,lr)\nlr = 0.01","metadata":{"_uuid":"9fb2b9c1-d381-44d1-ad2e-0fab9ff9d2e2","_cell_guid":"1b642d99-e7a9-4fcf-b6ee-c9cf0e15a0d6","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:24.719610Z","iopub.execute_input":"2022-10-06T11:18:24.720516Z","iopub.status.idle":"2022-10-06T11:18:24.967429Z","shell.execute_reply.started":"2022-10-06T11:18:24.720473Z","shell.execute_reply":"2022-10-06T11:18:24.965992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model and Optimization","metadata":{"_uuid":"848f4ce1-6867-459d-a709-fde26f67be38","_cell_guid":"f92583fd-e0cb-4221-9d4b-48f7e1b91dde","trusted":true}},{"cell_type":"code","source":"lr = 0.01\nLR_START = 0.01\nBATCH_SIZE = 256\ndef my_model(hp, n_inputs=52,n_outputs=2):\n\n    \n    \n    activation = 'softplus'\n    reg1 = hp.Float(\"reg1\", min_value=1e-15, max_value=1e-4, sampling=\"log\")\n    reg2 = hp.Float(\"reg2\", min_value=1e-15, max_value=1e-5, sampling=\"log\")\n    \n    inputs = Input(shape=(n_inputs, ))\n    x0 = Dense(hp.Choice('units1', [  32 ,64]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(inputs)\n    x1 = Dense(hp.Choice('units2', [64,128]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(x0)\n    x2 = Dense(hp.Choice('units3', [  64,128]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(x1)\n    x3 = Dense(hp.Choice('units4', [16,32]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(x2)\n    x3 = tf.keras.layers.Dropout(hp.Choice('drop0', [0.,0.22]))(x3)\n    \n    w0 = Dense(hp.Choice('units5', [ 128,256]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(inputs)\n    w1 = Dense(hp.Choice('units6', [ 128,256]), kernel_regularizer=tf.keras.regularizers.l1(reg1),\n              activation=activation,\n             )(w0)\n    w1 = tf.keras.layers.Dropout(hp.Choice('drop1', [0.,0.22]))(w1)\n    \n    x = Concatenate()([x0, x1, x2, x3,w1])\n    \n    x = tf.keras.layers.Dropout(hp.Choice('drop2', [0.,0.22]))(x)\n\n    x = Dense(n_outputs, kernel_regularizer=tf.keras.regularizers.l1(reg2),\n              activation=\"sigmoid\",\n             )(x)\n   \n        \n    clf = Model(inputs, x)\n    \n    clf.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=LR_START),\n                      loss=tf.keras.losses.BinaryCrossentropy()\n                     )\n    \n    return clf\n\ndisplay(plot_model(my_model(keras_tuner.HyperParameters()),\n                   show_layer_names=True, show_shapes=True, dpi=64))","metadata":{"_uuid":"05d4aa38-7618-4be0-a0f0-3ad114d9a2d3","_cell_guid":"07149888-38fd-4041-a15d-2781993c34bf","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:24.969743Z","iopub.execute_input":"2022-10-06T11:18:24.970680Z","iopub.status.idle":"2022-10-06T11:18:30.489045Z","shell.execute_reply.started":"2022-10-06T11:18:24.970635Z","shell.execute_reply":"2022-10-06T11:18:30.487525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TUNE = False","metadata":{"_uuid":"ae91764a-f67c-41bf-9f0f-90dba5597b11","_cell_guid":"dceeb2bf-7dae-467a-b3b8-8a94c26dfa96","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:30.492031Z","iopub.execute_input":"2022-10-06T11:18:30.492606Z","iopub.status.idle":"2022-10-06T11:18:30.500387Z","shell.execute_reply.started":"2022-10-06T11:18:30.492519Z","shell.execute_reply":"2022-10-06T11:18:30.498901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nif TUNE:\n    LR_START = 0.01\n    lr = 0.01\n    tuner = keras_tuner.BayesianOptimization(\n        my_model,\n        overwrite=True,\n        objective=keras_tuner.Objective(\"val_loss\", direction=\"min\"),\n        max_trials=3, #it is for demonstration, change for tune like  70 max trials. \n        directory='./',\n        seed=1)\n    \n    es = EarlyStopping(monitor=\"val_loss\",\n                       patience=12, \n                       verbose=0,\n                       mode=\"min\", \n                       restore_best_weights=True)\n    callbacks = [lrDecay, es]\n    X_tr, X_va, y_tr, y_va = train_test_split(train3[0:10000],targets[0:10000], test_size=0.2, random_state=1)\n    tuner.search(X_tr, y_tr,\n                 epochs=3, #it is for demonstration, change for tune like 200 epochs, \n                 validation_data=(X_va, y_va),\n                 batch_size=1024,\n                 callbacks=callbacks, \n                 verbose=0)\n    del X_tr, X_va, y_tr, y_va, lr, es, callbacks","metadata":{"_uuid":"f4e32877-8203-42fe-a49e-ed566a731306","_cell_guid":"07fd6df2-a499-44c3-9b82-7140f49a38ac","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:30.502122Z","iopub.execute_input":"2022-10-06T11:18:30.503898Z","iopub.status.idle":"2022-10-06T11:18:30.515730Z","shell.execute_reply.started":"2022-10-06T11:18:30.503856Z","shell.execute_reply":"2022-10-06T11:18:30.514590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if TUNE:\n    tuner.results_summary()\n    \n    # Table of the 10 best trials\n    display(pd.DataFrame([hp.values for hp in tuner.get_best_hyperparameters(10)]))\n    \n    # Keep the best hyperparameters\n    best_hp = tuner.get_best_hyperparameters(1)[0]\n    print(best_hp)\n    bhp_df=pd.DataFrame([hp.values for hp in tuner.get_best_hyperparameters(10)])\n    bhp_df.head(3)","metadata":{"_uuid":"2d27d387-1a4c-4c4b-9e23-87e2bae8ccaf","_cell_guid":"f2d16648-8fcf-437e-b284-6445146d811f","collapsed":false,"scrolled":true,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:30.517281Z","iopub.execute_input":"2022-10-06T11:18:30.518728Z","iopub.status.idle":"2022-10-06T11:18:30.533314Z","shell.execute_reply.started":"2022-10-06T11:18:30.518643Z","shell.execute_reply":"2022-10-06T11:18:30.532197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if not TUNE:\n    best_hp = keras_tuner.HyperParameters()\n    best_hp.values = {\"reg1\": 8.287727451226454e-050,\n                        \"reg2\": 1e-75,\n                        \"units1\": 32,\n                        \"units2\": 64,\n                        \"units3\": 64,\n                        \"units4\": 16,\n                        \"units5\": 128,\n                        \"units6\": 128,\n                        \"drop0\": 0.22,\n                        \"drop1\": 0.22,\n                        \"drop2\": 0.0\n                      \n                     }","metadata":{"_uuid":"b540f8e7-a1c9-4f14-8e9b-247cf3ef6bd3","_cell_guid":"fe0df81b-966d-45cd-bb82-895783b9835f","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:18:30.534955Z","iopub.execute_input":"2022-10-06T11:18:30.537585Z","iopub.status.idle":"2022-10-06T11:18:30.547307Z","shell.execute_reply.started":"2022-10-06T11:18:30.537541Z","shell.execute_reply":"2022-10-06T11:18:30.545736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Training","metadata":{"_uuid":"1d2ccb3b-8814-4226-8bdb-1ac703c0dd89","_cell_guid":"653f3e04-fdd6-4f6c-bdce-89e5bb1e3e46","trusted":true}},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"execution":{"iopub.status.busy":"2022-10-06T11:19:50.256840Z","iopub.execute_input":"2022-10-06T11:19:50.257302Z","iopub.status.idle":"2022-10-06T11:19:50.263916Z","shell.execute_reply.started":"2022-10-06T11:19:50.257271Z","shell.execute_reply":"2022-10-06T11:19:50.262316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.random.seed(1)\ntf.random.set_seed(1)\ncv = 3\nthreshold = 0.0\nkf = KFold(n_splits=cv,\n           shuffle=True, random_state=1)\n\nscore =[]\nscore2 =[]\ntest_preds = []\nmodels  = {}\nclf = False\n\nfor i , ( idx , idv ) in enumerate(kf.split(train3)):\n    \n    X_tr = train3[idx]\n    gc.collect()\n    y_tr = targets[idx]\n    #y_va = targets[idv]\n        \n\n\n    #X_va = train3[idv]\n\n    gc.collect()\n\n#     es = EarlyStopping(monitor=\"val_loss\",\n#                            patience=12, \n#                            verbose=0,\n# #                            mode=\"min\", \n#                            restore_best_weights=True)\n    callbacks = [lrDecay,\n#                  es\n                ]\n    \n    model = my_model( best_hp, n_inputs=52,n_outputs=2)\n    gc.collect()    \n    model.fit(X_tr, y_tr, \n                            #validation_data=(X_va, y_va), \n                            epochs=105,\n                            verbose=2,\n                            batch_size=1024*16,\n                            shuffle=True,\n                            callbacks=callbacks)\n    gc.collect()    \n    model.save(f\"model_{i}\",save_format=\"tf\")\n    \n    del model,X_tr,y_tr\n    gc.collect()","metadata":{"_uuid":"f64e772b-9267-4e6f-b7d1-8bf1e5c26a80","_cell_guid":"29cbd788-7e06-4a6c-91c6-98cc26c92109","collapsed":false,"scrolled":true,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:19:51.122284Z","iopub.execute_input":"2022-10-06T11:19:51.123357Z","iopub.status.idle":"2022-10-06T11:54:23.449012Z","shell.execute_reply.started":"2022-10-06T11:19:51.123311Z","shell.execute_reply":"2022-10-06T11:54:23.447619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del train3\ngc.collect()","metadata":{"_uuid":"ad71884c-1533-4d23-a296-aa198680c249","_cell_guid":"44a90b82-a037-4de7-bec6-37b9095f47ba","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:54:23.452516Z","iopub.execute_input":"2022-10-06T11:54:23.453091Z","iopub.status.idle":"2022-10-06T11:54:23.659084Z","shell.execute_reply.started":"2022-10-06T11:54:23.453044Z","shell.execute_reply":"2022-10-06T11:54:23.657390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Prediction","metadata":{"_uuid":"da065d7c-490a-430a-afc8-3c8a383d5297","_cell_guid":"a8dc5f17-dedf-450d-abbe-feb729f98623","trusted":true}},{"cell_type":"code","source":"%%time\ncols3=['ball_pos_x', 'ball_pos_y', 'ball_pos_z', 'ball_vel_x',\n   'ball_vel_y', 'ball_vel_z', 'p0_pos_x', 'p0_pos_y', 'p0_pos_z',\n   'p0_vel_x', 'p0_vel_y', 'p0_vel_z', 'p0_boost', 'p1_pos_x', 'p1_pos_y',\n   'p1_pos_z', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p1_boost', 'p2_pos_x',\n   'p2_pos_y', 'p2_pos_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', 'p2_boost',\n   'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p3_vel_x', 'p3_vel_y', 'p3_vel_z',\n   'p3_boost', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z', 'p4_vel_x', 'p4_vel_y',\n   'p4_vel_z', 'p4_boost', 'p5_pos_x', 'p5_pos_y', 'p5_pos_z', 'p5_vel_x',\n   'p5_vel_y', 'p5_vel_z', 'p5_boost' ]\ntest = read_subset(cols_test=cols3,\n                     df ='test',\n                     )\ngc.collect()","metadata":{"_uuid":"82ccaced-4cb0-46e8-ab80-acae5b71b8ab","_cell_guid":"b43017c6-ea31-410e-9d3d-17cdedbf87e1","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:58:19.206482Z","iopub.execute_input":"2022-10-06T11:58:19.206933Z","iopub.status.idle":"2022-10-06T11:58:21.088921Z","shell.execute_reply.started":"2022-10-06T11:58:19.206892Z","shell.execute_reply":"2022-10-06T11:58:21.086538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nfeat(test)\ntest = test.fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-10-06T11:58:23.281003Z","iopub.execute_input":"2022-10-06T11:58:23.282437Z","iopub.status.idle":"2022-10-06T11:58:24.353886Z","shell.execute_reply.started":"2022-10-06T11:58:23.282383Z","shell.execute_reply":"2022-10-06T11:58:24.352402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = sc.transform(test)\n","metadata":{"_uuid":"01292a32-27a3-40f3-9d98-50b9ae396e3a","_cell_guid":"bdbdeb58-39ef-43f3-b08b-fdfae17dc436","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:58:26.587132Z","iopub.execute_input":"2022-10-06T11:58:26.588699Z","iopub.status.idle":"2022-10-06T11:58:26.750565Z","shell.execute_reply.started":"2022-10-06T11:58:26.588653Z","shell.execute_reply":"2022-10-06T11:58:26.749053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gc.collect()","metadata":{"_uuid":"b53a75dc-0323-4d76-9d04-c8395c0534c8","_cell_guid":"8f2010d9-5cdb-40ea-9d7a-9a1bb28e5c10","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:58:27.873277Z","iopub.execute_input":"2022-10-06T11:58:27.873717Z","iopub.status.idle":"2022-10-06T11:58:28.086047Z","shell.execute_reply.started":"2022-10-06T11:58:27.873685Z","shell.execute_reply":"2022-10-06T11:58:28.084428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in range(cv):\n        print(f\"Predicting with fold {i}\")\n        model = tf.keras.models.load_model(f\"model_{i}\")\n        if i== 0:\n            test_pred = model.predict(test)\n        else:\n            test_pred += model.predict(test)","metadata":{"_uuid":"c12b1c2a-5c6f-4310-935c-cf60c744fce7","_cell_guid":"4a6ce4f1-6c8c-4f54-80ad-8787dd76ee7b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T11:58:29.816949Z","iopub.execute_input":"2022-10-06T11:58:29.817398Z","iopub.status.idle":"2022-10-06T12:00:10.963825Z","shell.execute_reply.started":"2022-10-06T11:58:29.817365Z","shell.execute_reply":"2022-10-06T12:00:10.962304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{"_uuid":"7cf41ebf-266d-41a9-b43c-d03ce02510af","_cell_guid":"f8de5598-007d-48b0-8b09-23c7d9c83f8a","trusted":true}},{"cell_type":"code","source":"test_pred /= cv\nsubmission = pd.read_csv(\"../input/tabular-playground-series-oct-2022/sample_submission.csv\")\nsubmission.iloc[:,1:] = test_pred\nsubmission.to_csv(\"submission.csv\",index=False)\n!head submission.csv","metadata":{"_uuid":"9e73834d-43db-4d6f-83e8-76a3fdad6eba","_cell_guid":"e7e9300a-a12d-419e-9a48-1cc8c5cd0ec8","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2022-10-06T12:00:10.966882Z","iopub.execute_input":"2022-10-06T12:00:10.967314Z","iopub.status.idle":"2022-10-06T12:00:15.656976Z","shell.execute_reply.started":"2022-10-06T12:00:10.967283Z","shell.execute_reply":"2022-10-06T12:00:15.655263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"_uuid":"ac422c18-e843-42c3-ad8a-481cc339ce1e","_cell_guid":"c44343b0-64e1-46c2-9673-247563de806f","collapsed":false,"jupyter":{"outputs_hidden":false},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}