{"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 os\nimport gc\nimport pandas as pd\nimport tensorflow as tf\nimport numpy as np\n\nfrom tensorflow import keras\nfrom tensorflow.keras.layers import Dense, BatchNormalization, Dropout\nfrom tensorflow.keras.optimizers import Adam, RMSprop\nfrom tensorflow.keras.models import Sequential\n\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:03.195533Z","iopub.execute_input":"2022-10-31T22:30:03.195971Z","iopub.status.idle":"2022-10-31T22:30:14.719579Z","shell.execute_reply.started":"2022-10-31T22:30:03.195890Z","shell.execute_reply":"2022-10-31T22:30:14.718597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.max_columns = None","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:14.721748Z","iopub.execute_input":"2022-10-31T22:30:14.722420Z","iopub.status.idle":"2022-10-31T22:30:14.727566Z","shell.execute_reply.started":"2022-10-31T22:30:14.722375Z","shell.execute_reply":"2022-10-31T22:30:14.726606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_path = '/kaggle/input/tabular-playground-series-oct-2022/'\nfeather_path = '../input/rocket-league/'","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:14.729045Z","iopub.execute_input":"2022-10-31T22:30:14.729660Z","iopub.status.idle":"2022-10-31T22:30:14.753786Z","shell.execute_reply.started":"2022-10-31T22:30:14.729607Z","shell.execute_reply":"2022-10-31T22:30:14.752657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dtypes_file = os.path.join(data_path, 'train_dtypes.csv')\ntest_dtypes_file = os.path.join(data_path, 'test_dtypes.csv')\nsample_submission_file = os.path.join(data_path, 'sample_submission.csv')\nsample_submission_file2 = os.path.join(data_path, 'sample_submission2.csv')\ntrain_feather_file = os.path.join(feather_path, 'train.feather')\ntest_feather_file = os.path.join(feather_path, 'test.feather')","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:14.755829Z","iopub.execute_input":"2022-10-31T22:30:14.756115Z","iopub.status.idle":"2022-10-31T22:30:14.767919Z","shell.execute_reply.started":"2022-10-31T22:30:14.756088Z","shell.execute_reply":"2022-10-31T22:30:14.766999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dtypes_df = pd.read_csv(train_dtypes_file)\ntest_dtypes_df = pd.read_csv(test_dtypes_file)\ncols_dtypes = {k: v for (k, v) in zip(train_dtypes_df.column, train_dtypes_df.dtype)}","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:14.769314Z","iopub.execute_input":"2022-10-31T22:30:14.769725Z","iopub.status.idle":"2022-10-31T22:30:14.813262Z","shell.execute_reply.started":"2022-10-31T22:30:14.769691Z","shell.execute_reply":"2022-10-31T22:30:14.812328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Ignoring the useless columns\nLets see what columns we will not use to train.","metadata":{}},{"cell_type":"code","source":"[c for c in train_dtypes_df['column'] if c not in test_dtypes_df['column'].values]","metadata":{"execution":{"iopub.status.busy":"2022-10-31T22:30:14.814844Z","iopub.execute_input":"2022-10-31T22:30:14.815609Z","iopub.status.idle":"2022-10-31T22:30:14.827576Z","shell.execute_reply.started":"2022-10-31T22:30:14.815574Z","shell.execute_reply":"2022-10-31T22:30:14.825847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Feature Selection","metadata":{}},{"cell_type":"code","source":"targets = ['team_A_scoring_within_10sec', 'team_B_scoring_within_10sec']\nuseless_cols = ['event_id', 'ball_vel_x', 'ball_vel_y', 'ball_vel_z', 'p0_vel_x', 'p0_vel_y', 'p0_vel_z', \n                'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', \n                'p3_vel_x', 'p3_vel_y', 'p3_vel_z', 'p4_vel_x', 'p4_vel_y', 'p4_vel_z', \n                'p5_vel_x', 'p5_vel_y', 'p5_vel_z', \n                'boost0_timer', 'boost1_timer', 'boost2_timer', \n                'boost3_timer', 'boost4_timer', 'boost5_timer', 'team_A_scoring_within_10sec', 'team_B_scoring_within_10sec'\n               ]\nuseless_cols2 = ['ball_vel_x', 'ball_vel_y', 'ball_vel_z', 'p0_vel_x', 'p0_vel_y', 'p0_vel_z', \n                'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', \n                'p3_vel_x', 'p3_vel_y', 'p3_vel_z', 'p4_vel_x', 'p4_vel_y', 'p4_vel_z', \n                'p5_vel_x', 'p5_vel_y', 'p5_vel_z', \n                 'boost0_timer', 'boost1_timer', 'boost2_timer', \n                'boost3_timer', 'boost4_timer', 'boost5_timer']\nuse_cols = [c for c in train_dtypes_df['column'] if c not in useless_cols]\nfeatures = test_dtypes_df['column'][1:].values # drop id","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:01:10.881927Z","iopub.execute_input":"2022-10-31T23:01:10.882279Z","iopub.status.idle":"2022-10-31T23:01:10.891431Z","shell.execute_reply.started":"2022-10-31T23:01:10.882250Z","shell.execute_reply":"2022-10-31T23:01:10.890311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_feather(train_feather_file)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:01:45.124569Z","iopub.execute_input":"2022-10-31T23:01:45.124957Z","iopub.status.idle":"2022-10-31T23:02:00.647495Z","shell.execute_reply.started":"2022-10-31T23:01:45.124927Z","shell.execute_reply":"2022-10-31T23:02:00.646477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:01.729142Z","iopub.execute_input":"2022-10-31T23:03:01.729534Z","iopub.status.idle":"2022-10-31T23:03:01.762421Z","shell.execute_reply.started":"2022-10-31T23:03:01.729504Z","shell.execute_reply":"2022-10-31T23:03:01.761439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def eliminate_useless_columns(df, columns_list):\n    df = df.drop(columns_list, axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:01.996155Z","iopub.execute_input":"2022-10-31T23:03:01.997250Z","iopub.status.idle":"2022-10-31T23:03:02.003442Z","shell.execute_reply.started":"2022-10-31T23:03:01.997188Z","shell.execute_reply":"2022-10-31T23:03:02.002265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def normalizer(df, columns, min_data, max_data):\n    for column in columns:\n        min_data = df[column].min()\n        max_data = df[column].max()\n        df[column] = (df[column] - min_data) / (max_data - min_data)\n    return df, min_data, max_data","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:02.251611Z","iopub.execute_input":"2022-10-31T23:03:02.252386Z","iopub.status.idle":"2022-10-31T23:03:02.258789Z","shell.execute_reply.started":"2022-10-31T23:03:02.252343Z","shell.execute_reply":"2022-10-31T23:03:02.257463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"targets_df = pd.DataFrame()\ntargets_df['team_A_scoring_within_10sec'] = train_df['team_A_scoring_within_10sec']\ntargets_df['team_B_scoring_within_10sec'] = train_df['team_B_scoring_within_10sec']\ntargets_df = targets_df[(targets_df['team_A_scoring_within_10sec']==1) | (targets_df['team_B_scoring_within_10sec']==1)]","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:02.537213Z","iopub.execute_input":"2022-10-31T23:03:02.537577Z","iopub.status.idle":"2022-10-31T23:03:04.393238Z","shell.execute_reply.started":"2022-10-31T23:03:02.537547Z","shell.execute_reply":"2022-10-31T23:03:04.391704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"targets_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:04.395745Z","iopub.execute_input":"2022-10-31T23:03:04.396448Z","iopub.status.idle":"2022-10-31T23:03:04.407094Z","shell.execute_reply.started":"2022-10-31T23:03:04.396409Z","shell.execute_reply":"2022-10-31T23:03:04.405693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.fillna(0, inplace=True)\ntrain_df = train_df[(train_df['team_A_scoring_within_10sec']==1) | (train_df['team_B_scoring_within_10sec']==1)]","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:04.411372Z","iopub.execute_input":"2022-10-31T23:03:04.412471Z","iopub.status.idle":"2022-10-31T23:03:07.790629Z","shell.execute_reply.started":"2022-10-31T23:03:04.412423Z","shell.execute_reply":"2022-10-31T23:03:07.789604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preparing data\ndef prepare_data(df):\n\n    # velocity value for 0-5 players and the ball\n    for i in range(6):\n        df[f'p{i}_vel'] = np.sqrt(\n           df[f'p{i}_vel_x']**2+\n           df[f'p{i}_vel_y']**2+\n           df[f'p{i}_vel_z']**2)\n\n    df['ball_vel'] = np.sqrt(\n       df['ball_vel_x']**2+\n       df['ball_vel_y']**2+\n       df['ball_vel_z']**2)\n    # distances from players to ball\n    for i in range(6):\n        df[f'p{i}_dist_ball'] = np.sqrt(\n           (df[f'p{i}_pos_x']-df['ball_pos_x'])**2+\n           (df[f'p{i}_pos_y']-df['ball_pos_y'])**2+\n           (df[f'p{i}_pos_z']-df['ball_pos_z'])**2)\n    # mean distance from team A or team B to the ball\n    df['mean_dist_teamA_to_ball'] = (df['p0_dist_ball']+ df['p1_dist_ball']+ df['p2_dist_ball'])/3\n    df['mean_dist_teamB_to_ball'] = (df['p3_dist_ball']+ df['p4_dist_ball']+ df['p5_dist_ball'])/3\n\n    # mean velocity for each team\n    df['mean_vel_teamA'] = (df['p0_vel']+ df['p1_vel']+ df['p2_vel'])/3\n    df['mean_vel_teamB'] = (df['p3_vel']+ df['p4_vel']+ df['p5_vel'])/3\n\n    # mean boost for each team\n    df['median_boost_A'] = (df['p0_boost'] + df['p1_boost'] + df['p2_boost']) / 3\n    df['median_boost_B'] = (df['p3_boost'] + df['p4_boost'] + df['p5_boost']) / 3\n    return df","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:07.793360Z","iopub.execute_input":"2022-10-31T23:03:07.793773Z","iopub.status.idle":"2022-10-31T23:03:07.804477Z","shell.execute_reply.started":"2022-10-31T23:03:07.793733Z","shell.execute_reply":"2022-10-31T23:03:07.803316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = prepare_data(train_df)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:07.805908Z","iopub.execute_input":"2022-10-31T23:03:07.806373Z","iopub.status.idle":"2022-10-31T23:03:09.896676Z","shell.execute_reply.started":"2022-10-31T23:03:07.806336Z","shell.execute_reply":"2022-10-31T23:03:09.895622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:12:54.678225Z","iopub.execute_input":"2022-10-31T23:12:54.678973Z","iopub.status.idle":"2022-10-31T23:12:54.723928Z","shell.execute_reply.started":"2022-10-31T23:12:54.678930Z","shell.execute_reply":"2022-10-31T23:12:54.722733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"eliminate_useless_columns(train_df, useless_cols)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:09.971289Z","iopub.execute_input":"2022-10-31T23:03:09.972290Z","iopub.status.idle":"2022-10-31T23:03:10.581006Z","shell.execute_reply.started":"2022-10-31T23:03:09.972246Z","shell.execute_reply":"2022-10-31T23:03:10.579849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"min_data = None\nmax_data = None","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:03:14.181366Z","iopub.execute_input":"2022-10-31T23:03:14.181799Z","iopub.status.idle":"2022-10-31T23:03:14.186639Z","shell.execute_reply.started":"2022-10-31T23:03:14.181764Z","shell.execute_reply":"2022-10-31T23:03:14.185375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lista_columnas_normalizar = ['ball_pos_x', 'ball_pos_y', 'ball_pos_z', 'p0_pos_x', 'p0_pos_y', 'p0_pos_z', 'p1_pos_x', 'p1_pos_y', 'p1_pos_z', 'p2_pos_x', 'p2_pos_y', 'p2_pos_z', 'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p4_pos_x', 'p4_pos_y', 'p4_pos_z', 'p5_pos_x', 'p5_pos_y', 'p5_pos_z', 'p0_boost', 'p1_boost', 'p2_boost', 'p3_boost', 'p4_boost', 'p5_boost', 'p0_vel', 'p1_vel', 'p2_vel', 'p3_vel', 'p4_vel', 'p5_vel', 'ball_vel', 'p0_dist_ball', 'p1_dist_ball', 'p2_dist_ball', 'p3_dist_ball', 'p4_dist_ball', 'p5_dist_ball', 'mean_dist_teamA_to_ball', 'mean_dist_teamB_to_ball', 'mean_vel_teamA', 'mean_vel_teamB', 'median_boost_A', 'median_boost_B']","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:12:42.038008Z","iopub.execute_input":"2022-10-31T23:12:42.038375Z","iopub.status.idle":"2022-10-31T23:12:42.045138Z","shell.execute_reply.started":"2022-10-31T23:12:42.038344Z","shell.execute_reply":"2022-10-31T23:12:42.043868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df, min_data, max_data = normalizer(train_df, lista_columnas_normalizar, min_data, max_data)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:12:45.469663Z","iopub.execute_input":"2022-10-31T23:12:45.470050Z","iopub.status.idle":"2022-10-31T23:12:47.054125Z","shell.execute_reply.started":"2022-10-31T23:12:45.470019Z","shell.execute_reply":"2022-10-31T23:12:47.052984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_feather(test_feather_file)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:12.127422Z","iopub.execute_input":"2022-10-31T23:13:12.128075Z","iopub.status.idle":"2022-10-31T23:13:14.020098Z","shell.execute_reply.started":"2022-10-31T23:13:12.128037Z","shell.execute_reply":"2022-10-31T23:13:14.018983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:17.482581Z","iopub.execute_input":"2022-10-31T23:13:17.483173Z","iopub.status.idle":"2022-10-31T23:13:17.490009Z","shell.execute_reply.started":"2022-10-31T23:13:17.483139Z","shell.execute_reply":"2022-10-31T23:13:17.488681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:14:14.652599Z","iopub.execute_input":"2022-10-31T23:14:14.652981Z","iopub.status.idle":"2022-10-31T23:14:14.660112Z","shell.execute_reply.started":"2022-10-31T23:14:14.652950Z","shell.execute_reply":"2022-10-31T23:14:14.658986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:14:12.645867Z","iopub.execute_input":"2022-10-31T23:14:12.646218Z","iopub.status.idle":"2022-10-31T23:14:12.729541Z","shell.execute_reply.started":"2022-10-31T23:14:12.646189Z","shell.execute_reply":"2022-10-31T23:14:12.728410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.fillna(0, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:32.304603Z","iopub.execute_input":"2022-10-31T23:13:32.305358Z","iopub.status.idle":"2022-10-31T23:13:32.370036Z","shell.execute_reply.started":"2022-10-31T23:13:32.305318Z","shell.execute_reply":"2022-10-31T23:13:32.369022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:14:03.325419Z","iopub.execute_input":"2022-10-31T23:14:03.326396Z","iopub.status.idle":"2022-10-31T23:14:03.370607Z","shell.execute_reply.started":"2022-10-31T23:14:03.326350Z","shell.execute_reply":"2022-10-31T23:14:03.369558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = prepare_data(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:37.822766Z","iopub.execute_input":"2022-10-31T23:13:37.823118Z","iopub.status.idle":"2022-10-31T23:13:37.972662Z","shell.execute_reply.started":"2022-10-31T23:13:37.823089Z","shell.execute_reply":"2022-10-31T23:13:37.971669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"eliminate_useless_columns(test_df, useless_cols2)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:41.019203Z","iopub.execute_input":"2022-10-31T23:13:41.019559Z","iopub.status.idle":"2022-10-31T23:13:41.196548Z","shell.execute_reply.started":"2022-10-31T23:13:41.019528Z","shell.execute_reply":"2022-10-31T23:13:41.195493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df, _, _ = normalizer(test_df, lista_columnas_normalizar, min_data, max_data)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:13:59.595544Z","iopub.execute_input":"2022-10-31T23:13:59.595967Z","iopub.status.idle":"2022-10-31T23:14:00.060380Z","shell.execute_reply.started":"2022-10-31T23:13:59.595934Z","shell.execute_reply":"2022-10-31T23:14:00.059415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Split Data","metadata":{}},{"cell_type":"code","source":"per = 1\nlength_train = train_df.shape[0]\n\nX_train, X_valid = train_df[:round(length_train*(1-per/100) - 1)], train_df[round(length_train*(1-per/100) - 1):]\nY_train, Y_valid = targets_df[:round(length_train*(1-per/100) - 1)], targets_df[round(length_train*(1-per/100) - 1):]\n#X_train, X_val, Y_train, Y_val = train_test_split(train_df, targets_df, test_size=0.01, random_state=0)\ndel (train_df, targets_df)\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:14:54.379701Z","iopub.execute_input":"2022-10-31T23:14:54.380065Z","iopub.status.idle":"2022-10-31T23:14:54.584912Z","shell.execute_reply.started":"2022-10-31T23:14:54.380034Z","shell.execute_reply":"2022-10-31T23:14:54.583805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## DNN Model","metadata":{}},{"cell_type":"code","source":"model = Sequential([\n    Dense(128, activation='relu', input_shape = [X_train.shape[1]]),\n    BatchNormalization(),\n    Dropout(0.05),\n    \n    Dense(256, activation='relu'),    \n    BatchNormalization(),\n    Dropout(0.1),\n    \n    Dense(256, activation='relu'),\n    BatchNormalization(),\n    Dropout(0.15),\n    \n    Dense(128, activation='relu'),    \n    BatchNormalization(),\n    Dropout(0.2),\n    \n    Dense(2)\n])","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:14:58.038395Z","iopub.execute_input":"2022-10-31T23:14:58.038815Z","iopub.status.idle":"2022-10-31T23:15:04.800489Z","shell.execute_reply.started":"2022-10-31T23:14:58.038782Z","shell.execute_reply":"2022-10-31T23:15:04.799436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2 = Sequential([\n    Dense(32, activation='relu', input_shape=[X_train.shape[1]]), \n    \n    Dense(64, activation='relu'),\n    Dropout(0.1), \n    \n    Dense(128, activation='relu'),\n    Dropout(0.3), \n    \n    Dense(2) \n])","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:26:59.395213Z","iopub.execute_input":"2022-10-31T23:26:59.395607Z","iopub.status.idle":"2022-10-31T23:26:59.444547Z","shell.execute_reply.started":"2022-10-31T23:26:59.395574Z","shell.execute_reply":"2022-10-31T23:26:59.443571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer='adam',\n             loss='binary_crossentropy',\n             metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:15:08.836333Z","iopub.execute_input":"2022-10-31T23:15:08.836740Z","iopub.status.idle":"2022-10-31T23:15:08.852191Z","shell.execute_reply.started":"2022-10-31T23:15:08.836706Z","shell.execute_reply":"2022-10-31T23:15:08.851084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.compile(optimizer='adam',\n             loss='binary_crossentropy',\n             metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:27:03.285537Z","iopub.execute_input":"2022-10-31T23:27:03.286769Z","iopub.status.idle":"2022-10-31T23:27:03.297951Z","shell.execute_reply.started":"2022-10-31T23:27:03.286709Z","shell.execute_reply":"2022-10-31T23:27:03.296951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(X_train, Y_train, \n              epochs=20, \n              steps_per_epoch=X_train.shape[0]//512, \n              batch_size=512,\n              validation_data=(X_valid, Y_valid),\n         )","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:15:25.140697Z","iopub.execute_input":"2022-10-31T23:15:25.141382Z","iopub.status.idle":"2022-10-31T23:25:49.935551Z","shell.execute_reply.started":"2022-10-31T23:15:25.141344Z","shell.execute_reply":"2022-10-31T23:25:49.934471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history2 = model2.fit(X_train, Y_train, \n              epochs=16, \n              steps_per_epoch=X_train.shape[0]//512, \n              batch_size=512,\n              validation_data=(X_valid, Y_valid),\n         )","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:27:07.549955Z","iopub.execute_input":"2022-10-31T23:27:07.550499Z","iopub.status.idle":"2022-10-31T23:31:16.676900Z","shell.execute_reply.started":"2022-10-31T23:27:07.550460Z","shell.execute_reply":"2022-10-31T23:31:16.675810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model.predict(test_df)\nscore = tf.nn.softmax(predictions)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:36:33.075757Z","iopub.execute_input":"2022-10-31T23:36:33.076119Z","iopub.status.idle":"2022-10-31T23:37:00.500208Z","shell.execute_reply.started":"2022-10-31T23:36:33.076090Z","shell.execute_reply":"2022-10-31T23:37:00.498798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions2 = model2.predict(test_df)\nscore2 = tf.nn.softmax(predictions2)","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:37:00.502146Z","iopub.execute_input":"2022-10-31T23:37:00.502515Z","iopub.status.idle":"2022-10-31T23:37:19.000583Z","shell.execute_reply.started":"2022-10-31T23:37:00.502479Z","shell.execute_reply":"2022-10-31T23:37:18.999511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ss = pd.read_csv(sample_submission_file)\nss['team_A_scoring_within_10sec'] = score[:,0]\nss['team_B_scoring_within_10sec'] = score[:,1]\nss.to_csv('Submission.csv', index=False)\nss.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-31T23:37:19.003542Z","iopub.execute_input":"2022-10-31T23:37:19.003949Z","iopub.status.idle":"2022-10-31T23:37:20.947220Z","shell.execute_reply.started":"2022-10-31T23:37:19.003911Z","shell.execute_reply":"2022-10-31T23:37:20.945949Z"},"trusted":true},"execution_count":null,"outputs":[]}]}