{"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":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport cudf\nimport os\nfrom sklearn.preprocessing import StandardScaler\nsc = StandardScaler()\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n #   for filename in filenames:\n  #      print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-23T07:53:36.113923Z","iopub.execute_input":"2022-10-23T07:53:36.114672Z","iopub.status.idle":"2022-10-23T07:53:42.011851Z","shell.execute_reply.started":"2022-10-23T07:53:36.114581Z","shell.execute_reply":"2022-10-23T07:53:42.010827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def rrt(dff):\n    trainX = dff[['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    trainYA = dff[['team_A_scoring_within_10sec']]\n    trainYB = dff[['team_B_scoring_within_10sec']]\n    \n    f23 = sc.fit_transform(trainX.as_gpu_matrix())\n    trainX = pd.DataFrame(f23)\n    \n    del dff,f23\n    \n    return trainX,trainYA,trainYB\ndef ttt(dff2):\n    test = dff2[['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    test.fillna(test.mean(), inplace=True)\n    \n    f24 = sc.fit_transform(test.as_gpu_matrix())\n    test = pd.DataFrame(f24)\n    \n    del dff2,f24\n    \n    return test","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:53:42.013899Z","iopub.execute_input":"2022-10-23T07:53:42.014290Z","iopub.status.idle":"2022-10-23T07:53:42.024481Z","shell.execute_reply.started":"2022-10-23T07:53:42.014254Z","shell.execute_reply":"2022-10-23T07:53:42.023589Z"},"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')\n#dtypes = {k: v for (k, v) in zip(dtypes_df.column, dtypes_df.dtype)}\ndf = cudf.read_csv('/kaggle/input/tabular-playground-series-oct-2022/train_0.csv')\ndf.dropna(inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:53:42.026446Z","iopub.execute_input":"2022-10-23T07:53:42.027244Z","iopub.status.idle":"2022-10-23T07:53:59.198279Z","shell.execute_reply.started":"2022-10-23T07:53:42.027217Z","shell.execute_reply":"2022-10-23T07:53:59.197086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainX,trainYA,trainYB = rrt(df)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:53:59.201179Z","iopub.execute_input":"2022-10-23T07:53:59.201544Z","iopub.status.idle":"2022-10-23T07:54:00.792238Z","shell.execute_reply.started":"2022-10-23T07:53:59.201510Z","shell.execute_reply":"2022-10-23T07:54:00.791159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#f1 = cudf.concat([df,df1,df2,df3,df4])\n#del df,df1,df2,df3,df4\n#f2 = cudf.concat([df5,df6,df7,df8,df9])\n#del df5,df6,df7,df8,df9\n#df = cudf.concat([f1,f2])","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:00.793988Z","iopub.execute_input":"2022-10-23T07:54:00.794445Z","iopub.status.idle":"2022-10-23T07:54:00.802153Z","shell.execute_reply.started":"2022-10-23T07:54:00.794404Z","shell.execute_reply":"2022-10-23T07:54:00.800605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dft = cudf.read_csv('/kaggle/input/tabular-playground-series-oct-2022/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:06.523022Z","iopub.execute_input":"2022-10-23T07:54:06.523939Z","iopub.status.idle":"2022-10-23T07:54:10.511551Z","shell.execute_reply.started":"2022-10-23T07:54:06.523892Z","shell.execute_reply":"2022-10-23T07:54:10.510575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = ttt(dft)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:10.513355Z","iopub.execute_input":"2022-10-23T07:54:10.513737Z","iopub.status.idle":"2022-10-23T07:54:14.485319Z","shell.execute_reply.started":"2022-10-23T07:54:10.513702Z","shell.execute_reply":"2022-10-23T07:54:14.484291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del df,dft","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:14.487086Z","iopub.execute_input":"2022-10-23T07:54:14.487514Z","iopub.status.idle":"2022-10-23T07:54:14.547521Z","shell.execute_reply.started":"2022-10-23T07:54:14.487471Z","shell.execute_reply":"2022-10-23T07:54:14.546504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#from xgboost import XGBClassifier\n#modelA = XGBClassifier(tree_method='gpu_hist', gpu_id=0)\n#modelA.fit(trainXA,trainYA)\n#modelB = XGBClassifier(tree_method='gpu_hist', gpu_id=0)\n#modelB.fit(trainXB,trainYB)\n#A = modelA.predict(test)\n#B = modelB.predict(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:38.466143Z","iopub.execute_input":"2022-10-23T07:54:38.467158Z","iopub.status.idle":"2022-10-23T07:54:38.472135Z","shell.execute_reply.started":"2022-10-23T07:54:38.467111Z","shell.execute_reply":"2022-10-23T07:54:38.470856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#ss = pd.read_csv('../input/tabular-playground-series-oct-2022/sample_submission.csv')\n#df = pd.DataFrame({'id':ss.id,'team_A_scoring_within_10sec':A,'team_B_scoring_within_10sec':B})\n#df.to_csv('cudaf1.csv',index = False)\n#modelA.save_model('modelA.json')\n#modelB.save_model('modelB.json')\n#trainYA=trainYA.to_pandas()","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:38.882532Z","iopub.execute_input":"2022-10-23T07:54:38.882896Z","iopub.status.idle":"2022-10-23T07:54:38.887550Z","shell.execute_reply.started":"2022-10-23T07:54:38.882867Z","shell.execute_reply":"2022-10-23T07:54:38.886289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def mmm():\n    from keras.models import Sequential\n    from keras.layers import Dense\n    from tensorflow.keras.optimizers import Adam\n    from tensorflow.keras.losses import BinaryCrossentropy\n    model = Sequential()\n    model.add(Dense(512, kernel_initializer='normal',activation='relu',input_shape=(54,)))\n    model.add(Dense(512,activation='relu'))\n    model.add(Dense(256,activation='relu'))\n    model.add(Dense(256,activation='relu'))\n    model.add(Dense(128,activation='relu'))\n    model.add(Dense(128,activation='relu'))\n    model.add(Dense(1,activation = 'sigmoid'))\n    model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.0001), metrics=['accuracy'])\n    return model","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:49.483114Z","iopub.execute_input":"2022-10-23T07:54:49.483490Z","iopub.status.idle":"2022-10-23T07:54:49.490765Z","shell.execute_reply.started":"2022-10-23T07:54:49.483461Z","shell.execute_reply":"2022-10-23T07:54:49.489792Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainYA=trainYA.to_pandas()\ntrainYB=trainYB.to_pandas()","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:54:52.602800Z","iopub.execute_input":"2022-10-23T07:54:52.603517Z","iopub.status.idle":"2022-10-23T07:54:52.642005Z","shell.execute_reply.started":"2022-10-23T07:54:52.603480Z","shell.execute_reply":"2022-10-23T07:54:52.641095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1 = mmm()\nmodel2 = mmm()","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:55:16.032847Z","iopub.execute_input":"2022-10-23T07:55:16.033213Z","iopub.status.idle":"2022-10-23T07:55:33.314963Z","shell.execute_reply.started":"2022-10-23T07:55:16.033181Z","shell.execute_reply":"2022-10-23T07:55:33.312859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.fit(trainX,trainYA,epochs=50,batch_size=10000)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T07:58:42.850483Z","iopub.execute_input":"2022-10-23T07:58:42.850864Z","iopub.status.idle":"2022-10-23T08:01:06.579488Z","shell.execute_reply.started":"2022-10-23T07:58:42.850833Z","shell.execute_reply":"2022-10-23T08:01:06.578481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.fit(trainX,trainYB,epochs=50,batch_size=10000)","metadata":{"execution":{"iopub.status.busy":"2022-10-23T08:01:06.581279Z","iopub.execute_input":"2022-10-23T08:01:06.581877Z","iopub.status.idle":"2022-10-23T08:02:52.208947Z","shell.execute_reply.started":"2022-10-23T08:01:06.581843Z","shell.execute_reply":"2022-10-23T08:02:52.208089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.save('modelA.h5')\nmodel2.save('modelB.h5')","metadata":{"execution":{"iopub.status.busy":"2022-10-23T08:13:08.341662Z","iopub.execute_input":"2022-10-23T08:13:08.342242Z","iopub.status.idle":"2022-10-23T08:13:08.436984Z","shell.execute_reply.started":"2022-10-23T08:13:08.342207Z","shell.execute_reply":"2022-10-23T08:13:08.436093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}