{"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-09T05:46:42.253732Z","iopub.execute_input":"2022-10-09T05:46:42.254128Z","iopub.status.idle":"2022-10-09T05:46:42.289485Z","shell.execute_reply.started":"2022-10-09T05:46:42.254023Z","shell.execute_reply":"2022-10-09T05:46:42.288379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_0.csv',nrows=2000000)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:46:43.892072Z","iopub.execute_input":"2022-10-09T05:46:43.892457Z","iopub.status.idle":"2022-10-09T05:47:14.741712Z","shell.execute_reply.started":"2022-10-09T05:46:43.892414Z","shell.execute_reply":"2022-10-09T05:47:14.741034Z"},"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-09T05:47:14.743207Z","iopub.execute_input":"2022-10-09T05:47:14.743633Z","iopub.status.idle":"2022-10-09T05:47:24.463108Z","shell.execute_reply.started":"2022-10-09T05:47:14.743581Z","shell.execute_reply":"2022-10-09T05:47:24.462476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dft.columns","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:47:24.464340Z","iopub.execute_input":"2022-10-09T05:47:24.464926Z","iopub.status.idle":"2022-10-09T05:47:24.474300Z","shell.execute_reply.started":"2022-10-09T05:47:24.464866Z","shell.execute_reply":"2022-10-09T05:47:24.473611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:47:24.476194Z","iopub.execute_input":"2022-10-09T05:47:24.476577Z","iopub.status.idle":"2022-10-09T05:47:24.491329Z","shell.execute_reply.started":"2022-10-09T05:47:24.476539Z","shell.execute_reply":"2022-10-09T05:47:24.490362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df= df.dropna()\ndf.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:47:24.492646Z","iopub.execute_input":"2022-10-09T05:47:24.493003Z","iopub.status.idle":"2022-10-09T05:47:25.462495Z","shell.execute_reply.started":"2022-10-09T05:47:24.492972Z","shell.execute_reply":"2022-10-09T05:47:25.461497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainXA = 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-09T05:47:31.255547Z","iopub.execute_input":"2022-10-09T05:47:31.256114Z","iopub.status.idle":"2022-10-09T05:47:31.468518Z","shell.execute_reply.started":"2022-10-09T05:47:31.256076Z","shell.execute_reply":"2022-10-09T05:47:31.467645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainXB = 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']]\n\ntrainYB = df[['team_B_scoring_within_10sec']]","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:47:32.164629Z","iopub.execute_input":"2022-10-09T05:47:32.164970Z","iopub.status.idle":"2022-10-09T05:47:32.415502Z","shell.execute_reply.started":"2022-10-09T05:47:32.164934Z","shell.execute_reply":"2022-10-09T05:47:32.414775Z"},"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-09T05:47:33.296227Z","iopub.execute_input":"2022-10-09T05:47:33.296504Z","iopub.status.idle":"2022-10-09T05:47:33.428630Z","shell.execute_reply.started":"2022-10-09T05:47:33.296474Z","shell.execute_reply":"2022-10-09T05:47:33.427962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\nscaler = StandardScaler()\ntrainXA = scaler.fit_transform(trainXA)\ntrainXB = scaler.fit_transform(trainXB)\ntest = scaler.fit_transform(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:47:36.985942Z","iopub.execute_input":"2022-10-09T05:47:36.986206Z","iopub.status.idle":"2022-10-09T05:47:42.406763Z","shell.execute_reply.started":"2022-10-09T05:47:36.986179Z","shell.execute_reply":"2022-10-09T05:47:42.405860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainXA = pd.DataFrame(trainXA)\ntrainXB = pd.DataFrame(trainXB)\ntest = pd.DataFrame(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:48:13.456292Z","iopub.execute_input":"2022-10-09T05:48:13.456593Z","iopub.status.idle":"2022-10-09T05:48:13.462074Z","shell.execute_reply.started":"2022-10-09T05:48:13.456562Z","shell.execute_reply":"2022-10-09T05:48:13.460691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeClassifier\nclfA = DecisionTreeClassifier()\nclfA.fit(trainXA,trainYA)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:48:38.984727Z","iopub.execute_input":"2022-10-09T05:48:38.985364Z","iopub.status.idle":"2022-10-09T05:53:10.825822Z","shell.execute_reply.started":"2022-10-09T05:48:38.985326Z","shell.execute_reply":"2022-10-09T05:53:10.824597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clfB = DecisionTreeClassifier()\nclfB.fit(trainXB,trainYB)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:53:10.828966Z","iopub.execute_input":"2022-10-09T05:53:10.829361Z","iopub.status.idle":"2022-10-09T05:57:55.645192Z","shell.execute_reply.started":"2022-10-09T05:53:10.829305Z","shell.execute_reply":"2022-10-09T05:57:55.644124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#from sklearn.impute import KNNImputer\n#imputer = KNNImputer(n_neighbors=5)\n#test = pd.DataFrame(imputer.fit_transform(test))\ntest.fillna(test.mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:57:56.390505Z","iopub.execute_input":"2022-10-09T05:57:56.390813Z","iopub.status.idle":"2022-10-09T05:57:56.535721Z","shell.execute_reply.started":"2022-10-09T05:57:56.390781Z","shell.execute_reply":"2022-10-09T05:57:56.534883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#test = test.fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T04:51:07.818077Z","iopub.execute_input":"2022-10-09T04:51:07.818373Z","iopub.status.idle":"2022-10-09T04:51:07.988825Z","shell.execute_reply.started":"2022-10-09T04:51:07.818347Z","shell.execute_reply":"2022-10-09T04:51:07.987842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"A = clfA.predict(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:58:13.941731Z","iopub.execute_input":"2022-10-09T05:58:13.942102Z","iopub.status.idle":"2022-10-09T05:58:14.430064Z","shell.execute_reply.started":"2022-10-09T05:58:13.942063Z","shell.execute_reply":"2022-10-09T05:58:14.428998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"B = clfB.predict(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:58:16.431209Z","iopub.execute_input":"2022-10-09T05:58:16.431524Z","iopub.status.idle":"2022-10-09T05:58:16.929933Z","shell.execute_reply.started":"2022-10-09T05:58:16.431491Z","shell.execute_reply":"2022-10-09T05:58:16.928922Z"},"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":{"execution":{"iopub.status.busy":"2022-10-09T05:58:30.281408Z","iopub.execute_input":"2022-10-09T05:58:30.281946Z","iopub.status.idle":"2022-10-09T05:58:30.323750Z","shell.execute_reply.started":"2022-10-09T05:58:30.281909Z","shell.execute_reply":"2022-10-09T05:58:30.322741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv('SS4.csv',index = False)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:58:37.001625Z","iopub.execute_input":"2022-10-09T05:58:37.002687Z","iopub.status.idle":"2022-10-09T05:58:37.896344Z","shell.execute_reply.started":"2022-10-09T05:58:37.002644Z","shell.execute_reply":"2022-10-09T05:58:37.895410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ss = pd.read_csv('../input/tabular-playground-series-oct-2022/sample_submission.csv')\nss","metadata":{"execution":{"iopub.status.busy":"2022-10-09T05:58:26.572427Z","iopub.execute_input":"2022-10-09T05:58:26.572726Z","iopub.status.idle":"2022-10-09T05:58:26.846999Z","shell.execute_reply.started":"2022-10-09T05:58:26.572677Z","shell.execute_reply":"2022-10-09T05:58:26.845988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}