{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-14T18:28:38.003484Z","iopub.execute_input":"2022-10-14T18:28:38.00432Z","iopub.status.idle":"2022-10-14T18:28:38.042575Z","shell.execute_reply.started":"2022-10-14T18:28:38.004175Z","shell.execute_reply":"2022-10-14T18:28:38.041326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:41:34.958194Z","iopub.execute_input":"2022-10-14T22:41:34.958681Z","iopub.status.idle":"2022-10-14T22:41:34.964078Z","shell.execute_reply.started":"2022-10-14T22:41:34.958639Z","shell.execute_reply":"2022-10-14T22:41:34.962737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file =\"/kaggle/input/tabular-playground-series-oct-2022/train_0.csv\"\n\n# file = 'results.csv'\ntrain_0 = pd.DataFrame()\nwith open(file) as fl:\n    chunk_iter = pd.read_csv(fl, chunksize = 10000)\n    for chunk in chunk_iter:\n        train_0 = pd.concat([train_0,chunk])","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:41:35.108076Z","iopub.execute_input":"2022-10-14T22:41:35.108636Z","iopub.status.idle":"2022-10-14T22:43:05.780189Z","shell.execute_reply.started":"2022-10-14T22:41:35.108581Z","shell.execute_reply":"2022-10-14T22:43:05.778823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0[['team_A_scoring_within_10sec']].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:05.783166Z","iopub.execute_input":"2022-10-14T22:43:05.783713Z","iopub.status.idle":"2022-10-14T22:43:05.9397Z","shell.execute_reply.started":"2022-10-14T22:43:05.783661Z","shell.execute_reply":"2022-10-14T22:43:05.937819Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0[['team_B_scoring_within_10sec']].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:05.941573Z","iopub.execute_input":"2022-10-14T22:43:05.94216Z","iopub.status.idle":"2022-10-14T22:43:05.998094Z","shell.execute_reply.started":"2022-10-14T22:43:05.942107Z","shell.execute_reply":"2022-10-14T22:43:05.996721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# \ntrain_0 = pd.concat([train_0.loc[(train_0['team_A_scoring_within_10sec'] == 1) & (train_0['team_B_scoring_within_10sec'] == 0)][:10000],\ntrain_0.loc[(train_0['team_A_scoring_within_10sec'] == 0) &  (train_0['team_B_scoring_within_10sec'] == 1)][:10000],\ntrain_0.loc[(train_0['team_A_scoring_within_10sec'] == 0) &  (train_0['team_B_scoring_within_10sec'] == 0)][:5000],\ntrain_0.loc[(train_0['team_A_scoring_within_10sec'] == 1) &  (train_0['team_B_scoring_within_10sec'] == 1)][:5000]])\n\ntrain_0 = train_0.sample(frac=1)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.000806Z","iopub.execute_input":"2022-10-14T22:43:06.00121Z","iopub.status.idle":"2022-10-14T22:43:06.817625Z","shell.execute_reply.started":"2022-10-14T22:43:06.001173Z","shell.execute_reply":"2022-10-14T22:43:06.816274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0[['team_A_scoring_within_10sec']].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.819188Z","iopub.execute_input":"2022-10-14T22:43:06.819719Z","iopub.status.idle":"2022-10-14T22:43:06.833544Z","shell.execute_reply.started":"2022-10-14T22:43:06.819668Z","shell.execute_reply":"2022-10-14T22:43:06.831971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0[['team_B_scoring_within_10sec']].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.835814Z","iopub.execute_input":"2022-10-14T22:43:06.836559Z","iopub.status.idle":"2022-10-14T22:43:06.849069Z","shell.execute_reply.started":"2022-10-14T22:43:06.836517Z","shell.execute_reply":"2022-10-14T22:43:06.847303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.851057Z","iopub.execute_input":"2022-10-14T22:43:06.851601Z","iopub.status.idle":"2022-10-14T22:43:06.905301Z","shell.execute_reply.started":"2022-10-14T22:43:06.851563Z","shell.execute_reply":"2022-10-14T22:43:06.903884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_center(p1,p2,p3):\n     return ((np.array(p1) + np.array(p2)+ np.array(p3)) / 3.0)[0]\n    \n    \ndef get_dist(p1,p2):\n    return np.linalg.norm(p1-p2,axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.90698Z","iopub.execute_input":"2022-10-14T22:43:06.907427Z","iopub.status.idle":"2022-10-14T22:43:06.915253Z","shell.execute_reply.started":"2022-10-14T22:43:06.907388Z","shell.execute_reply":"2022-10-14T22:43:06.913753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# get_center(np.array([[0,1,2]]),np.array([[3,5,2]]),np.array([[3,15,2]]))","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.917423Z","iopub.execute_input":"2022-10-14T22:43:06.918258Z","iopub.status.idle":"2022-10-14T22:43:06.928536Z","shell.execute_reply.started":"2022-10-14T22:43:06.918206Z","shell.execute_reply":"2022-10-14T22:43:06.926827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0[['team_A_x','team_A_y','team_A_z']] = get_center(train_0[['p0_pos_x', 'p0_pos_y', 'p0_pos_z']].values,train_0[['p1_pos_x', 'p1_pos_y', 'p1_pos_z']].values, train_0[['p2_pos_x', 'p2_pos_y', 'p2_pos_z']].values)\ntrain_0[['team_B_x','team_B_y','team_B_z']] = get_center(train_0[['p3_pos_x', 'p3_pos_y', 'p3_pos_z']].values,train_0[['p4_pos_x', 'p4_pos_y', 'p4_pos_z']].values, train_0[['p5_pos_x', 'p5_pos_y', 'p5_pos_z']].values)\n\ntrain_0['A_dist_ball'] = get_dist(train_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, train_0[['team_A_x','team_A_y','team_A_z']].values)\ntrain_0['B_dist_ball'] = get_dist(train_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, train_0[['team_B_x','team_B_y','team_B_z']].values)\n\ntrain_0['A_dist_0'] = get_dist(train_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, np.array([0.0,0.0,0.0]))\ntrain_0['B_dist_0'] = get_dist(train_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, np.array([0.0,0.0,0.0]))\n","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:06.933554Z","iopub.execute_input":"2022-10-14T22:43:06.934106Z","iopub.status.idle":"2022-10-14T22:43:07.006437Z","shell.execute_reply.started":"2022-10-14T22:43:06.934044Z","shell.execute_reply":"2022-10-14T22:43:07.005217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:07.009067Z","iopub.execute_input":"2022-10-14T22:43:07.00986Z","iopub.status.idle":"2022-10-14T22:43:07.040205Z","shell.execute_reply.started":"2022-10-14T22:43:07.009809Z","shell.execute_reply":"2022-10-14T22:43:07.038529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0.columns","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:07.043558Z","iopub.execute_input":"2022-10-14T22:43:07.044461Z","iopub.status.idle":"2022-10-14T22:43:07.054602Z","shell.execute_reply.started":"2022-10-14T22:43:07.044404Z","shell.execute_reply":"2022-10-14T22:43:07.052866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'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', 'team_A_x', 'team_A_y', 'team_A_z',\n       'team_B_x', 'team_B_y', 'team_B_z', 'A_dist_ball', 'B_dist_ball',\n       'A_dist_0', 'B_dist_0'","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:23:44.04993Z","iopub.execute_input":"2022-10-14T22:23:44.050262Z","iopub.status.idle":"2022-10-14T22:23:44.060076Z","shell.execute_reply.started":"2022-10-14T22:23:44.050235Z","shell.execute_reply":"2022-10-14T22:23:44.058751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0 = train_0.dropna()\ntrain_0 = train_0[['team_A_x', 'team_A_y', 'team_A_z','A_dist_0', 'B_dist_0',\n       'team_B_x', 'team_B_y', 'team_B_z', 'A_dist_ball', 'B_dist_ball',\n       'team_A_scoring_within_10sec','team_B_scoring_within_10sec']]\n# train_0","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:12.725014Z","iopub.execute_input":"2022-10-14T22:43:12.725728Z","iopub.status.idle":"2022-10-14T22:43:12.760223Z","shell.execute_reply.started":"2022-10-14T22:43:12.725684Z","shell.execute_reply":"2022-10-14T22:43:12.758741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:13.395877Z","iopub.execute_input":"2022-10-14T22:43:13.39634Z","iopub.status.idle":"2022-10-14T22:43:13.419144Z","shell.execute_reply.started":"2022-10-14T22:43:13.396303Z","shell.execute_reply":"2022-10-14T22:43:13.417236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install river \n!pip install river_torch","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:43:14.773996Z","iopub.execute_input":"2022-10-14T22:43:14.774646Z","iopub.status.idle":"2022-10-14T22:44:46.186053Z","shell.execute_reply.started":"2022-10-14T22:43:14.774592Z","shell.execute_reply":"2022-10-14T22:44:46.183694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from river import compose\nfrom river import linear_model\nfrom river import metrics\nfrom river import preprocessing\nfrom torch import nn\nfrom torch import optim\nfrom torch import manual_seed\nfrom river import metrics, datasets, preprocessing, compose\nfrom river_torch import classification","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:46.189946Z","iopub.execute_input":"2022-10-14T22:44:46.190503Z","iopub.status.idle":"2022-10-14T22:44:50.610309Z","shell.execute_reply.started":"2022-10-14T22:44:46.190457Z","shell.execute_reply":"2022-10-14T22:44:50.608678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class MyModule(nn.Module):\n    def __init__(self, n_features):\n        super(MyModule, self).__init__()\n        self.dense0_0 = nn.Linear(n_features, 100)\n        self.nonlin = nn.ReLU()\n        self.dense1_0 = nn.Linear(100, 2)\n        self.softmax = nn.Softmax(dim=-1)\n\n    def forward(self, X, **kwargs):\n        X = self.nonlin(self.dense0_0(X))\n        X = self.nonlin(self.dense1_0(X))\n        \n        X = self.softmax(X)\n        return X","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:50.613642Z","iopub.execute_input":"2022-10-14T22:44:50.615167Z","iopub.status.idle":"2022-10-14T22:44:50.627599Z","shell.execute_reply.started":"2022-10-14T22:44:50.615079Z","shell.execute_reply":"2022-10-14T22:44:50.625401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_pipeline = compose.Pipeline(\n    preprocessing.StandardScaler(),\n    classification.Classifier(module=MyModule, loss_fn='binary_cross_entropy', optimizer_fn='adam'))","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:50.63135Z","iopub.execute_input":"2022-10-14T22:44:50.631942Z","iopub.status.idle":"2022-10-14T22:44:52.752372Z","shell.execute_reply.started":"2022-10-14T22:44:50.631885Z","shell.execute_reply":"2022-10-14T22:44:52.750944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"metric = metrics.Accuracy()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:52.754178Z","iopub.execute_input":"2022-10-14T22:44:52.755323Z","iopub.status.idle":"2022-10-14T22:44:52.766228Z","shell.execute_reply.started":"2022-10-14T22:44:52.755264Z","shell.execute_reply":"2022-10-14T22:44:52.765042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0_dict = train_0.to_dict('records')","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:52.768184Z","iopub.execute_input":"2022-10-14T22:44:52.769018Z","iopub.status.idle":"2022-10-14T22:44:53.048135Z","shell.execute_reply.started":"2022-10-14T22:44:52.768961Z","shell.execute_reply":"2022-10-14T22:44:53.046147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_0_dict[0].keys()","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:53.050487Z","iopub.execute_input":"2022-10-14T22:44:53.051533Z","iopub.status.idle":"2022-10-14T22:44:53.059842Z","shell.execute_reply.started":"2022-10-14T22:44:53.051449Z","shell.execute_reply":"2022-10-14T22:44:53.05828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"counter = 0\nfor train_0_item in train_0_dict:\n    y = train_0_item.pop(\"team_A_scoring_within_10sec\")\n    y_2 = train_0_item.pop(\"team_B_scoring_within_10sec\")\n# #     print(train_0_item)\n\n    if (y == 0 or  y_2 == 0) and counter >= 5000:\n        continue\n    counter += 1\n    \n    train_0_item['a_or_b'] = 0.0\n    y_pred_0 = model_pipeline.predict_one(train_0_item)      # make a prediction\n    metric_A = metric.update(y, y_pred_0)   # update the metric\n    model_pipeline = model_pipeline.learn_one(train_0_item, y)\n    \n    \n    train_0_item['a_or_b'] = 1.0\n    y_pred_1 = model_pipeline.predict_one(train_0_item)      # make a prediction\n    metric_B = metric.update(y_2, y_pred_1)   # update the metric\n    model_pipeline = model_pipeline.learn_one(train_0_item, y_2)\n    ","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:44:57.593271Z","iopub.execute_input":"2022-10-14T22:44:57.593735Z","iopub.status.idle":"2022-10-14T22:45:09.215097Z","shell.execute_reply.started":"2022-10-14T22:44:57.593699Z","shell.execute_reply":"2022-10-14T22:45:09.213664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"metric_A,metric_B","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:45:09.218994Z","iopub.execute_input":"2022-10-14T22:45:09.220345Z","iopub.status.idle":"2022-10-14T22:45:09.230205Z","shell.execute_reply.started":"2022-10-14T22:45:09.220262Z","shell.execute_reply":"2022-10-14T22:45:09.228606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_1","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:46:19.358676Z","iopub.execute_input":"2022-10-14T22:46:19.359131Z","iopub.status.idle":"2022-10-14T22:46:19.367553Z","shell.execute_reply.started":"2022-10-14T22:46:19.359094Z","shell.execute_reply":"2022-10-14T22:46:19.365694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv(\"/kaggle/input/tabular-playground-series-oct-2022/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:46:20.321233Z","iopub.execute_input":"2022-10-14T22:46:20.32165Z","iopub.status.idle":"2022-10-14T22:46:30.887019Z","shell.execute_reply.started":"2022-10-14T22:46:20.321616Z","shell.execute_reply":"2022-10-14T22:46:30.88552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_0 = test","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:46:30.888653Z","iopub.execute_input":"2022-10-14T22:46:30.889088Z","iopub.status.idle":"2022-10-14T22:46:30.898903Z","shell.execute_reply.started":"2022-10-14T22:46:30.88905Z","shell.execute_reply":"2022-10-14T22:46:30.895905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_0[['team_A_x','team_A_y','team_A_z']] = get_center(test_0[['p0_pos_x', 'p0_pos_y', 'p0_pos_z']].values,test_0[['p1_pos_x', 'p1_pos_y', 'p1_pos_z']].values, test_0[['p2_pos_x', 'p2_pos_y', 'p2_pos_z']].values)\ntest_0[['team_B_x','team_B_y','team_B_z']] = get_center(test_0[['p3_pos_x', 'p3_pos_y', 'p3_pos_z']].values,test_0[['p4_pos_x', 'p4_pos_y', 'p4_pos_z']].values, test_0[['p5_pos_x', 'p5_pos_y', 'p5_pos_z']].values)\n\ntest_0['A_dist_ball'] = get_dist(test_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, test_0[['team_A_x','team_A_y','team_A_z']].values)\ntest_0['B_dist_ball'] = get_dist(test_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, test_0[['team_B_x','team_B_y','team_B_z']].values)\n\ntest_0['A_dist_0'] = get_dist(test_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, np.array([0.0,0.0,0.0]))\ntest_0['B_dist_0'] = get_dist(test_0[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values, np.array([0.0,0.0,0.0]))\n","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:46:37.972436Z","iopub.execute_input":"2022-10-14T22:46:37.973025Z","iopub.status.idle":"2022-10-14T22:46:39.478044Z","shell.execute_reply.started":"2022-10-14T22:46:37.972981Z","shell.execute_reply":"2022-10-14T22:46:39.476449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_0 = test_0[['team_A_x', 'team_A_y', 'team_A_z','A_dist_0', 'B_dist_0',\n       'team_B_x', 'team_B_y', 'team_B_z', 'A_dist_ball', 'B_dist_ball']]\n                 \n#  ''''''                'p0_vel_x',\n# 'p0_vel_y', 'p0_vel_z', 'p0_boost', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z',\n# 'p1_boost', 'p2_vel_x', 'p2_vel_y','p2_vel_z', 'p2_boost', 'p3_vel_x','p3_vel_y',\n# 'p3_vel_z', 'p3_boost', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z','p4_boost','p5_vel_x',\n# 'p5_vel_y', 'p5_vel_z', 'p5_boost','boost0_timer', 'boost1_timer', 'boost2_timer',\n# 'boost3_timer','boost4_timer', 'boost5_timer','p0_dist_ball', 'p1_dist_ball','p2_dist_ball',\n# 'p3_dist_ball','p4_dist_ball', 'p5_dist_ball']]","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:40:21.6407Z","iopub.execute_input":"2022-10-14T22:40:21.640959Z","iopub.status.idle":"2022-10-14T22:40:21.7674Z","shell.execute_reply.started":"2022-10-14T22:40:21.640935Z","shell.execute_reply":"2022-10-14T22:40:21.76567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_0_dict = test_0.to_dict('records')","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:40:21.769685Z","iopub.execute_input":"2022-10-14T22:40:21.770176Z","iopub.status.idle":"2022-10-14T22:40:26.502214Z","shell.execute_reply.started":"2022-10-14T22:40:21.77013Z","shell.execute_reply":"2022-10-14T22:40:26.500851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_0_dict[0]","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:40:26.503731Z","iopub.execute_input":"2022-10-14T22:40:26.504033Z","iopub.status.idle":"2022-10-14T22:40:26.510242Z","shell.execute_reply.started":"2022-10-14T22:40:26.504008Z","shell.execute_reply":"2022-10-14T22:40:26.509392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 'game_num': 1,\n#  'event_id': 1002,\n#  'event_time': -33.31303,\n\n# 'player_scoring_next': 3,\n#  'team_scoring_next': 'B',\n#  'team_A_scoring_within_10sec': 0,\n#  'team_B_scoring_within_10sec': 0}\n\npred_list_A = []\npred_list_B = []\n\nfor test_0_item in test_0_dict:\n#     id = train_0_item.pop(\"id\")\n    \n    test_0_item['a_or_b'] = 0.0\n    y_pred_A = model_pipeline.predict_one(test_0_item)\n    pred_list_A.append(y_pred_A)\n    \n    test_0_item['a_or_b'] = 1.0\n    y_pred_B = model_pipeline.predict_one(test_0_item)\n    pred_list_B.append(y_pred_B)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:40:26.511522Z","iopub.execute_input":"2022-10-14T22:40:26.51176Z","iopub.status.idle":"2022-10-14T22:40:26.563263Z","shell.execute_reply.started":"2022-10-14T22:40:26.511736Z","shell.execute_reply":"2022-10-14T22:40:26.561865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sum(pred_list_B)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:40:26.564137Z","iopub.status.idle":"2022-10-14T22:40:26.564848Z","shell.execute_reply.started":"2022-10-14T22:40:26.564636Z","shell.execute_reply":"2022-10-14T22:40:26.564657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample= pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/sample_submission.csv')\nsample['team_A_scoring_within_10sec'] = pred_list_A\nsample['team_B_scoring_within_10sec'] = pred_list_B","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:35:38.016875Z","iopub.execute_input":"2022-10-14T22:35:38.017239Z","iopub.status.idle":"2022-10-14T22:35:38.578195Z","shell.execute_reply.started":"2022-10-14T22:35:38.017213Z","shell.execute_reply":"2022-10-14T22:35:38.577509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample.to_csv('submit.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-10-14T22:35:39.865264Z","iopub.execute_input":"2022-10-14T22:35:39.865625Z","iopub.status.idle":"2022-10-14T22:35:40.621061Z","shell.execute_reply.started":"2022-10-14T22:35:39.8656Z","shell.execute_reply":"2022-10-14T22:35:40.619538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}