{"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-24T04:22:10.895119Z","iopub.execute_input":"2022-10-24T04:22:10.895611Z","iopub.status.idle":"2022-10-24T04:22:10.932670Z","shell.execute_reply.started":"2022-10-24T04:22:10.895510Z","shell.execute_reply":"2022-10-24T04:22:10.931292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cc = ['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       'team_A_scoring_within_10sec','team_B_scoring_within_10sec']","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:22:17.307106Z","iopub.execute_input":"2022-10-24T04:22:17.307563Z","iopub.status.idle":"2022-10-24T04:22:17.322711Z","shell.execute_reply.started":"2022-10-24T04:22:17.307508Z","shell.execute_reply":"2022-10-24T04:22:17.321507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dtypes_df = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_dtypes.csv')\ndtypes = {k: v for (k, v) in zip(dtypes_df.column, dtypes_df.dtype)}\n\ndf = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_0.csv',dtype=dtypes,usecols=cc)\ndf.to_feather('train_0.ftr')\ndel df\nprint('Done with train_0')\n\ndf1 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_1.csv',dtype=dtypes,usecols=cc)\ndf1.to_feather('train_1.ftr')\ndel df1\nprint('Done with train_1')\n\ndf2 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_2.csv',dtype=dtypes,usecols=cc)\ndf2.to_feather('train_2.ftr')\ndel df2\nprint('Done with train_2')\n\ndf3 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_3.csv',dtype=dtypes,usecols=cc)\ndf3.to_feather('train_3.ftr')\ndel df3\nprint('Done with train_3')\n\ndf4 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_4.csv',dtype=dtypes,usecols=cc)\ndf4.to_feather('train_4.ftr')\ndel df4\nprint('Done with train_4')\n\ndf5 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_5.csv',dtype=dtypes,usecols=cc)\ndf5.to_feather('train_5.ftr')\ndel df5\nprint('Done with train_5')\n\ndf6 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_6.csv',dtype=dtypes,usecols=cc)\ndf6.to_feather('train_6.ftr')\ndel df6\nprint('Done with train_6')\n\ndf7 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_7.csv',dtype=dtypes,usecols=cc)\ndf7.to_feather('train_7.ftr')\ndel df7\nprint('Done with train_7')\n\ndf8 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_8.csv',dtype=dtypes,usecols=cc)\ndf8.to_feather('train_8.ftr')\ndel df8\nprint('Done with train_8')\n\ndf9 = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_9.csv',dtype=dtypes,usecols=cc)\ndf9.to_feather('train_9.ftr')\ndel df9\nprint('Done with train_9')","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:22:20.834934Z","iopub.execute_input":"2022-10-24T04:22:20.835336Z","iopub.status.idle":"2022-10-24T04:29:12.847451Z","shell.execute_reply.started":"2022-10-24T04:22:20.835306Z","shell.execute_reply":"2022-10-24T04:29:12.845110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_feather('train_0.ftr',use_threads=True)\ndf1 = pd.read_feather('train_1.ftr',use_threads=True)\ndf2 = pd.read_feather('train_2.ftr',use_threads=True)\ndf3 = pd.read_feather('train_3.ftr',use_threads=True)\ndf4 = pd.read_feather('train_4.ftr',use_threads=True)\ndf5 = pd.read_feather('train_5.ftr',use_threads=True)\ndf6 = pd.read_feather('train_6.ftr',use_threads=True)\ndf7 = pd.read_feather('train_7.ftr',use_threads=True)\ndf8 = pd.read_feather('train_8.ftr',use_threads=True)\ndf9 = pd.read_feather('train_9.ftr',use_threads=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:29:32.778344Z","iopub.execute_input":"2022-10-24T04:29:32.778818Z","iopub.status.idle":"2022-10-24T04:29:42.575370Z","shell.execute_reply.started":"2022-10-24T04:29:32.778774Z","shell.execute_reply":"2022-10-24T04:29:42.573784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.concat([df,df1,df2,df3,df4,df5,df6,df7,df8,df9])","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:30:27.497622Z","iopub.execute_input":"2022-10-24T04:30:27.498192Z","iopub.status.idle":"2022-10-24T04:30:32.622482Z","shell.execute_reply.started":"2022-10-24T04:30:27.498151Z","shell.execute_reply":"2022-10-24T04:30:32.621201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del df1,df2,df3,df4,df5,df6,df7,df8,df9","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:30:32.624869Z","iopub.execute_input":"2022-10-24T04:30:32.625608Z","iopub.status.idle":"2022-10-24T04:30:32.634434Z","shell.execute_reply.started":"2022-10-24T04:30:32.625563Z","shell.execute_reply":"2022-10-24T04:30:32.632523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dft = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:08:32.984843Z","iopub.execute_input":"2022-10-24T04:08:32.985505Z","iopub.status.idle":"2022-10-24T04:08:42.845978Z","shell.execute_reply.started":"2022-10-24T04:08:32.985452Z","shell.execute_reply":"2022-10-24T04:08:42.844978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.dropna(inplace=True)\ndf.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:30:46.677295Z","iopub.execute_input":"2022-10-24T04:30:46.677804Z","iopub.status.idle":"2022-10-24T04:31:04.598965Z","shell.execute_reply.started":"2022-10-24T04:30:46.677768Z","shell.execute_reply":"2022-10-24T04:31:04.597607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv(\"df.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:31:34.216763Z","iopub.execute_input":"2022-10-24T04:31:34.217248Z","iopub.status.idle":"2022-10-24T04:47:27.913901Z","shell.execute_reply.started":"2022-10-24T04:31:34.217211Z","shell.execute_reply":"2022-10-24T04:47:27.912067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainX = df[['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']]\ntrainYA = df[['team_A_scoring_within_10sec']]","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:09:04.324178Z","iopub.execute_input":"2022-10-24T04:09:04.324583Z","iopub.status.idle":"2022-10-24T04:09:06.573526Z","shell.execute_reply.started":"2022-10-24T04:09:04.324544Z","shell.execute_reply":"2022-10-24T04:09:06.571924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainYB = df[['team_B_scoring_within_10sec']]","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:09:14.750453Z","iopub.execute_input":"2022-10-24T04:09:14.751397Z","iopub.status.idle":"2022-10-24T04:09:14.776507Z","shell.execute_reply.started":"2022-10-24T04:09:14.751346Z","shell.execute_reply":"2022-10-24T04:09:14.774973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = dft[['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']]","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:09:18.094158Z","iopub.execute_input":"2022-10-24T04:09:18.094579Z","iopub.status.idle":"2022-10-24T04:09:18.196898Z","shell.execute_reply.started":"2022-10-24T04:09:18.094536Z","shell.execute_reply":"2022-10-24T04:09:18.195479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del df,dft","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:09:26.584033Z","iopub.execute_input":"2022-10-24T04:09:26.584455Z","iopub.status.idle":"2022-10-24T04:09:26.633035Z","shell.execute_reply.started":"2022-10-24T04:09:26.584420Z","shell.execute_reply":"2022-10-24T04:09:26.631725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.fillna(test.mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:09:36.385028Z","iopub.execute_input":"2022-10-24T04:09:36.385725Z","iopub.status.idle":"2022-10-24T04:09:36.700083Z","shell.execute_reply.started":"2022-10-24T04:09:36.385688Z","shell.execute_reply":"2022-10-24T04:09:36.699096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del dft","metadata":{"execution":{"iopub.status.busy":"2022-10-21T05:09:46.977537Z","iopub.execute_input":"2022-10-21T05:09:46.978272Z","iopub.status.idle":"2022-10-21T05:09:46.985366Z","shell.execute_reply.started":"2022-10-21T05:09:46.978233Z","shell.execute_reply":"2022-10-21T05:09:46.984094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2022-10-24T04:18:44.804051Z","iopub.execute_input":"2022-10-24T04:18:44.804502Z","iopub.status.idle":"2022-10-24T04:18:44.823986Z","shell.execute_reply.started":"2022-10-24T04:18:44.804463Z","shell.execute_reply":"2022-10-24T04:18:44.822099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from xgboost import XGBClassifier\nmodelA = XGBClassifier(tree_method='gpu_hist', gpu_id=0)\nmodelA.fit(trainXA,trainYA)","metadata":{"execution":{"iopub.status.busy":"2022-10-21T05:10:04.612359Z","iopub.execute_input":"2022-10-21T05:10:04.612756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modelB = XGBClassifier(tree_method='gpu_hist', gpu_id=0)\nmodelB.fit(trainXB,trainYB)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"A = modelA.predict(test)\nB = modelB.predict(test)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ss = pd.read_csv('../input/tabular-playground-series-oct-2022/sample_submission.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.DataFrame({'id':ss.id,'team_A_scoring_within_10sec':A,'team_B_scoring_within_10sec':B})","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv('SS7.csv',index = False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}