{"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":"markdown","source":"# Importing Libraries and Loading datasets","metadata":{}},{"cell_type":"code","source":"import gc\nimport numpy as np\nimport pandas as pd\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom matplotlib.animation import FuncAnimation\n\nfrom xgboost import XGBClassifier\nfrom sklearn.metrics import roc_auc_score\nfrom sklearn.model_selection import StratifiedKFold","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:18.846982Z","iopub.execute_input":"2022-10-07T02:28:18.847546Z","iopub.status.idle":"2022-10-07T02:28:20.125792Z","shell.execute_reply.started":"2022-10-07T02:28:18.847473Z","shell.execute_reply":"2022-10-07T02:28:20.124627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def reduce_mem_usage(df, verbose=False):\n    numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n    start_mem = df.memory_usage().sum() / 1024**2    \n    for col in df.columns:\n        col_type = df[col].dtypes\n        if col_type in numerics:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)\n            else:\n                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)\n        else:\n            df[col] = df[col].astype('category')\n    end_mem = df.memory_usage().sum() / 1024**2\n    if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100 * (start_mem - end_mem) / start_mem))\n    return df","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:20.132323Z","iopub.execute_input":"2022-10-07T02:28:20.134877Z","iopub.status.idle":"2022-10-07T02:28:20.154812Z","shell.execute_reply.started":"2022-10-07T02:28:20.134839Z","shell.execute_reply":"2022-10-07T02:28:20.153279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv('../input/tabular-playground-series-oct-2022/test.csv', index_col='id')\nsub = pd.read_csv('../input/tabular-playground-series-oct-2022/sample_submission.csv')\n\n# Credits to https://www.kaggle.com/code/gazu468/feather-to-compress-your-data-8x-faster\ntrain = reduce_mem_usage(pd.read_feather(f\"../input/tpsoct22-feather-files/train_0.feather\"))\n# Rest of the data will be used when we are fitting the model due to memory limitations.","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:28:20.160148Z","iopub.execute_input":"2022-10-07T02:28:20.163211Z","iopub.status.idle":"2022-10-07T02:28:47.270427Z","shell.execute_reply.started":"2022-10-07T02:28:20.163174Z","shell.execute_reply":"2022-10-07T02:28:47.269441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Explore Data","metadata":{}},{"cell_type":"code","source":"train.head()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.273016Z","iopub.execute_input":"2022-10-07T02:28:47.273425Z","iopub.status.idle":"2022-10-07T02:28:47.307131Z","shell.execute_reply.started":"2022-10-07T02:28:47.273388Z","shell.execute_reply":"2022-10-07T02:28:47.306122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.308590Z","iopub.execute_input":"2022-10-07T02:28:47.308933Z","iopub.status.idle":"2022-10-07T02:28:47.334078Z","shell.execute_reply.started":"2022-10-07T02:28:47.308900Z","shell.execute_reply":"2022-10-07T02:28:47.333008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Columns: \\n{0}\".format(list(train.columns)))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.335604Z","iopub.execute_input":"2022-10-07T02:28:47.335951Z","iopub.status.idle":"2022-10-07T02:28:47.345269Z","shell.execute_reply.started":"2022-10-07T02:28:47.335917Z","shell.execute_reply":"2022-10-07T02:28:47.344043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Columns: \\n{0}\".format(list(test.columns)))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.347117Z","iopub.execute_input":"2022-10-07T02:28:47.347537Z","iopub.status.idle":"2022-10-07T02:28:47.355824Z","shell.execute_reply.started":"2022-10-07T02:28:47.347503Z","shell.execute_reply":"2022-10-07T02:28:47.354625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Columns only exist in training data: \\n{0}\".format([i for i in train.columns if i not in test.columns]))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.357552Z","iopub.execute_input":"2022-10-07T02:28:47.357961Z","iopub.status.idle":"2022-10-07T02:28:47.366571Z","shell.execute_reply.started":"2022-10-07T02:28:47.357920Z","shell.execute_reply":"2022-10-07T02:28:47.365529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Let's watch a Goal","metadata":{}},{"cell_type":"code","source":"print(\"Index of the first event which ends up with a goal: {0}\".format([i for i, x in enumerate(train['team_A_scoring_within_10sec'] == 1) if x][0]))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.368141Z","iopub.execute_input":"2022-10-07T02:28:47.368522Z","iopub.status.idle":"2022-10-07T02:28:47.645663Z","shell.execute_reply.started":"2022-10-07T02:28:47.368487Z","shell.execute_reply":"2022-10-07T02:28:47.644754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(8, 12))\n\nevent_start = 2111\nevent_end = 2210\nevent_frame = event_end - event_start\nname = ['Ball', 'Player 0', 'Player 1', 'Player 2', 'Player 3', 'Player 4', 'Player 5']\ncolors = ['green', 'blue', 'blue', 'blue', 'orange', 'orange', 'orange']\ndef animate(frame_num):\n    ax.clear()\n    plt.xlim([-80, 80])\n    plt.ylim([-120, 120])\n    \n    # Map\n    # Corner - NW\n    ax.annotate('', xy=(-65, 80), xytext=(-45, 100), arrowprops=dict(arrowstyle='-', color='red'))\n    # Edge - N\n    ax.annotate('', xy=(-45, 100), xytext=(-15, 100), arrowprops=dict(arrowstyle='-', color='red'))\n    ax.annotate('', xy=(15, 100), xytext=(45, 100), arrowprops=dict(arrowstyle='-', color='red'))\n    # Corner - NE\n    ax.annotate('', xy=(45, 100), xytext=(65, 80), arrowprops=dict(arrowstyle='-', color='red'))\n    # Edge - W\n    ax.annotate('', xy=(-65, -80), xytext=(-65, 80), arrowprops=dict(arrowstyle='-', color='red'))\n    \n    # Corner - SW\n    ax.annotate('', xy=(-65, -80), xytext=(-45, -100), arrowprops=dict(arrowstyle='-', color='red'))\n    # Edge - S\n    ax.annotate('', xy=(-45, -100), xytext=(-15, -100), arrowprops=dict(arrowstyle='-', color='red'))\n    ax.annotate('', xy=(15, -100), xytext=(45, -100), arrowprops=dict(arrowstyle='-', color='red'))\n    # Corner - SE\n    ax.annotate('', xy=(45, -100), xytext=(65, -80), arrowprops=dict(arrowstyle='-', color='red'))\n    # Edge - E\n    ax.annotate('', xy=(65, -80), xytext=(65, 80), arrowprops=dict(arrowstyle='-', color='red'))\n    \n    # Last frames to write goal!\n    if frame_num > event_frame:\n        event = train.iloc[event_end]\n    # Event starts at 2111 and ends at 2210.\n    # In this event team A is scoring.\n    else:\n        event = train.iloc[event_start + frame_num]\n    \n    x = event['ball_pos_x'], event['p0_pos_x'], event['p1_pos_x'], event['p2_pos_x'], event['p3_pos_x'], event['p4_pos_x'], event['p5_pos_x']\n    xv = event['ball_vel_x'], event['p0_vel_x'], event['p1_vel_x'], event['p2_vel_x'], event['p3_vel_x'], event['p4_vel_x'], event['p5_vel_x']\n\n    y = event['ball_pos_y'], event['p0_pos_y'], event['p1_pos_y'], event['p2_pos_y'], event['p3_pos_y'], event['p4_pos_y'], event['p5_pos_y']\n    yv = event['ball_vel_y'], event['p0_vel_y'], event['p1_vel_y'], event['p2_vel_y'], event['p3_vel_y'], event['p4_vel_y'], event['p5_vel_y']\n    \n    # Ball\n    ax.scatter(x[0], y[0], s=500, color='green')\n    # First team\n    ax.scatter(x[1:4], y[1:4], s=200, color='blue')\n    # Second team\n    ax.scatter(x[4:], y[4:], s=200, color='orange')\n    \n    # Movements\n    for i, txt in enumerate(name):\n        ax.annotate(txt, xy=(x[i], y[i]), color=colors[i], xytext=(x[i]+xv[i], y[i]+yv[i]),\n                    arrowprops=dict(arrowstyle='<-', color=colors[i]), ha='center', va='center')\n    \n    # Write Goal! when it happens :)\n    if frame_num > event_frame:\n        ax.annotate(\"Goal!\", xy=(0, 0), color='green', weight='bold', size=30, xytext=(0, 0),\n            arrowprops=dict(arrowstyle='-', color='Green'), ha='center', va='center')\n\n# Animation will be start at event 2111 and end in 2210\n# Which makes 99 frames, and interval is 0.1 second\nanimation = FuncAnimation(fig, animate, frames=event_frame + 5, interval=100)\nanimation.save('animation.gif', writer='imagemagick', fps=10);\n\ndel animation\ndel colors\ndel name\ndel fig\ndel ax\ngc.collect()","metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:28:47.649562Z","iopub.execute_input":"2022-10-07T02:28:47.649850Z","iopub.status.idle":"2022-10-07T02:29:33.416025Z","shell.execute_reply.started":"2022-10-07T02:28:47.649824Z","shell.execute_reply":"2022-10-07T02:29:33.415008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](./animation.gif)","metadata":{}},{"cell_type":"markdown","source":"# Basic Data Check","metadata":{}},{"cell_type":"code","source":"print('Train data shape:', train.shape)\nprint('Test data shape:', test.shape)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:29:33.417711Z","iopub.execute_input":"2022-10-07T02:29:33.418113Z","iopub.status.idle":"2022-10-07T02:29:33.423684Z","shell.execute_reply.started":"2022-10-07T02:29:33.418069Z","shell.execute_reply":"2022-10-07T02:29:33.422675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Missing Values","metadata":{}},{"cell_type":"code","source":"missing_values_train = train.isna().sum().sum()\nprint('Missing values in train data: {0}'.format(missing_values_train[missing_values_train > 0]))\n\nmissing_values_test = test.isna().sum().sum()\nprint('Missing values in test data: {0}'.format(missing_values_test[missing_values_test > 0]))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:29:33.425836Z","iopub.execute_input":"2022-10-07T02:29:33.427101Z","iopub.status.idle":"2022-10-07T02:29:33.943015Z","shell.execute_reply.started":"2022-10-07T02:29:33.426881Z","shell.execute_reply":"2022-10-07T02:29:33.941878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Handle missing values","metadata":{}},{"cell_type":"code","source":"train = train.dropna()\ntest = test.fillna(value=test.mean())","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:29:33.944637Z","iopub.execute_input":"2022-10-07T02:29:33.945023Z","iopub.status.idle":"2022-10-07T02:29:35.743204Z","shell.execute_reply.started":"2022-10-07T02:29:33.944986Z","shell.execute_reply":"2022-10-07T02:29:35.742226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing_values_train = train.isna().sum().sum()\nprint('Missing values in train data: {0}'.format(missing_values_train[missing_values_train > 0]))\n\nmissing_values_test = test.isna().sum().sum()\nprint('Missing values in test data: {0}'.format(missing_values_test[missing_values_test > 0]))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-10-07T02:29:35.744844Z","iopub.execute_input":"2022-10-07T02:29:35.745232Z","iopub.status.idle":"2022-10-07T02:29:36.100797Z","shell.execute_reply.started":"2022-10-07T02:29:35.745194Z","shell.execute_reply":"2022-10-07T02:29:36.099775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Feature Engineering\nCredits to https://www.kaggle.com/code/chazzer/rocket-league-xgboost-feat-engineering-cv/notebook","metadata":{}},{"cell_type":"code","source":"def euclidian_norm(x):\n    return np.linalg.norm(x, axis=1)\n\nvel_groups = {\n    f\"{el}_vel\": [f'{el}_vel_x', f'{el}_vel_y', f'{el}_vel_z']\n    for el in ['ball'] + [f'p{i}' for i in range(6)]\n}\npos_groups = {\n    f\"{el}_pos\": [f'{el}_pos_x', f'{el}_pos_y', f'{el}_pos_z']\n    for el in ['ball'] + [f'p{i}' for i in range(6)]\n}\n\ndef feature_engineering(df):\n    for col, vec in vel_groups.items():\n        df[col] = euclidian_norm(df[vec])\n\n    for col, vec in pos_groups.items():\n        df[col + \"_ball_dist\"] = euclidian_norm(df[vec].values - df[pos_groups[\"ball_pos\"]].values)\n    \n    return df\n\nfe = feature_engineering(train)\nfe.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:29:36.102475Z","iopub.execute_input":"2022-10-07T02:29:36.102857Z","iopub.status.idle":"2022-10-07T02:29:40.415012Z","shell.execute_reply.started":"2022-10-07T02:29:36.102821Z","shell.execute_reply":"2022-10-07T02:29:40.414182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mirror the board\n\nCredits to https://www.kaggle.com/code/spyrow/playground-oct-2022-lgbmclassifier?scriptVersionId=107206095","metadata":{}},{"cell_type":"code","source":"def mirror_ball(df):\n    # Mirror the coordinates\n    df[\"ball_pos_y\"] = df[\"ball_pos_y\"] * -1\n    df[\"ball_vel_y\"] = df[\"ball_vel_y\"] * -1\n    df[\"ball_pos_x\"] = df[\"ball_pos_x\"] * -1\n    df[\"ball_vel_x\"] = df[\"ball_vel_x\"] * -1\n    return df\n    \ndef mirror_players(df):\n    # Mirror the coordinates\n    def mirror(df, p, a):\n        df[f\"p{p}_pos_{a}\"] = df[f\"p{p}_pos_{a}\"] * -1\n        df[f\"p{p+3}_pos_{a}\"] = df[f\"p{p+3}_pos_{a}\"] * -1\n        df[f\"p{p}_vel_{a}\"] = df[f\"p{p}_vel_{a}\"] * -1\n        df[f\"p{p+3}_vel_{a}\"] = df[f\"p{p+3}_vel_{a}\"] * -1\n        \n        s = df[f\"p{p}_pos_{a}\"].copy()\n        df[f\"p{p}_pos_{a}\"] = df[f\"p{p+3}_pos_{a}\"]\n        df[f\"p{p+3}_pos_{a}\"] = s\n\n        s = df[f\"p{p}_vel_{a}\"].copy()\n        df[f\"p{p}_vel_{a}\"] = df[f\"p{p+3}_vel_{a}\"]\n        df[f\"p{p+3}_vel_{a}\"] = s\n        return df\n    \n    for p in range(3):\n        df = mirror(df, p, \"y\")\n        df = mirror(df, p, \"x\")\n    return df\n\ndef mirror(df):\n    s = df[\"boost0_timer\"].copy()\n    df[\"boost0_timer\"] = df[\"boost3_timer\"]\n    df[\"boost3_timer\"] = s\n    \n    s = df[\"boost1_timer\"].copy()\n    df[\"boost1_timer\"] = df[\"boost4_timer\"]\n    df[\"boost4_timer\"] = s\n    \n    s = df[\"boost2_timer\"].copy()\n    df[\"boost2_timer\"] = df[\"boost5_timer\"]\n    df[\"boost5_timer\"] = s\n    \n    s = df[\"team_A_scoring_within_10sec\"].copy()\n    df[\"team_A_scoring_within_10sec\"] = df[\"team_B_scoring_within_10sec\"]\n    df[\"team_B_scoring_within_10sec\"] = s\n        \n    return df\n\ndef mirror_board(df):\n    df = mirror_ball(df)\n    df = mirror_players(df)\n    df = mirror(df)\n    return df\n\nm = mirror_board(train)\nm.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:34:46.327546Z","iopub.execute_input":"2022-10-07T02:34:46.327908Z","iopub.status.idle":"2022-10-07T02:34:46.341144Z","shell.execute_reply.started":"2022-10-07T02:34:46.327880Z","shell.execute_reply":"2022-10-07T02:34:46.339217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Modelling","metadata":{}},{"cell_type":"code","source":"X_test = feature_engineering(reduce_mem_usage(test))\n\ndel m\ndel fe\ndel test\ndel train\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:29:41.024750Z","iopub.execute_input":"2022-10-07T02:29:41.025115Z","iopub.status.idle":"2022-10-07T02:29:46.179308Z","shell.execute_reply.started":"2022-10-07T02:29:41.025079Z","shell.execute_reply":"2022-10-07T02:29:46.178245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"N_SPLITS = 5\nmy_seed = 0\nparams = {'random_state': my_seed,\n          'tree_method': 'gpu_hist',\n          'n_estimators': 200,\n          'max_depth': 7,\n          'learning_rate': 0.1,\n          'objective': 'binary:logistic'}","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:29:46.180652Z","iopub.execute_input":"2022-10-07T02:29:46.181113Z","iopub.status.idle":"2022-10-07T02:29:46.187043Z","shell.execute_reply.started":"2022-10-07T02:29:46.181070Z","shell.execute_reply":"2022-10-07T02:29:46.186118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def preprocess_data(df):\n    # Handle missing values\n    df = df.dropna().copy()\n    # Drop unwanted columns\n    df = df.drop(['game_num', 'event_id', 'event_time',\n                  'player_scoring_next', 'team_scoring_next'], axis=1)\n    # Mirror the board and merge with the data set\n    mirror = mirror_board(df)\n    df = pd.concat([df, mirror])\n    df = df.reset_index(drop=True)\n    # Feature engineering\n    df = feature_engineering(df)\n    # Return X and y\n    return ({ 'A': df['team_A_scoring_within_10sec'], 'B': df['team_B_scoring_within_10sec'] },\n            df.drop(['team_A_scoring_within_10sec', 'team_B_scoring_within_10sec'], axis=1))\n\ndef run_model(X, y, X_test):\n    scores = []\n    test_predictions = []\n    cv = StratifiedKFold(n_splits=N_SPLITS, random_state=my_seed, shuffle=True)\n    for fold, (train_idx, test_idx) in enumerate(cv.split(X, y)):\n        train_X, val_X = X.iloc[train_idx], X.iloc[test_idx]\n        train_y, val_y = y.iloc[train_idx], y.iloc[test_idx]\n\n        model = XGBClassifier(**params)\n        model.fit(train_X, train_y)\n\n        predictions = model.predict_proba(val_X)[:, 1]\n        score = roc_auc_score(val_y, predictions)\n        scores.append(score)\n        print(f\"Fold {fold + 1} \\t\\t AUC: {score}\")\n\n        test_predictions.append(model.predict_proba(X_test)[:, 1])\n\n        del model\n        gc.collect()\n\n    print('Overall AUC: ', np.mean(scores))\n    return (np.mean(test_predictions, axis=0), np.mean(scores))\n\ndef get_predictions(X_test):\n    scores = {'A': [], 'B': [] }\n    test_predictions = {'A': [], 'B': [] }\n    for i in range(0,10): # Use all the training data\n        train_y, train_X = preprocess_data(reduce_mem_usage(pd.read_feather(f\"../input/tpsoct22-feather-files/train_{i}.feather\")))\n        for key in test_predictions:\n            print(f\"------ Data: train_{i}, Team: {key} ------\")\n            prediction, score = run_model(train_X, train_y[key], X_test)\n            test_predictions[key].append(prediction)\n            scores[key].append(score)\n\n        del train_y\n        del train_X\n        gc.collect()\n    print('----------------------------------------------')\n    print('Overall AUC for Team A: ', np.mean(scores['A']))\n    print('Overall AUC for Team B: ', np.mean(scores['B']))\n    return test_predictions","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:34:54.056646Z","iopub.execute_input":"2022-10-07T02:34:54.056997Z","iopub.status.idle":"2022-10-07T02:34:54.072300Z","shell.execute_reply.started":"2022-10-07T02:34:54.056969Z","shell.execute_reply":"2022-10-07T02:34:54.071131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = get_predictions(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-10-07T02:34:56.855373Z","iopub.execute_input":"2022-10-07T02:34:56.855805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"sub['team_A_scoring_within_10sec'] = np.mean(predictions['A'], axis=0)\nsub['team_B_scoring_within_10sec'] = np.mean(predictions['B'], axis=0)\nsub.to_csv('submission.csv', index=False)\nsub","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}