{"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":"# Imports","metadata":{}},{"cell_type":"code","source":"#import some lib\nimport pandas as pd\nimport numpy as np\nimport lightgbm as lgb\nfrom sklearn.model_selection import train_test_split\nimport path\nimport pathlib\nimport gc\nimport itertools\npd.set_option('display.max_columns', 500)","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.721826Z","iopub.execute_input":"2022-10-27T14:06:59.722284Z","iopub.status.idle":"2022-10-27T14:06:59.730150Z","shell.execute_reply.started":"2022-10-27T14:06:59.722248Z","shell.execute_reply":"2022-10-27T14:06:59.728707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"In this notebook I propose an LGBM model for the TPS Oct 2022.\n\nIt includes different fetures, most of them translated from @paddykb notebook https://www.kaggle.com/code/paddykb/tps-2022-10-fastai:\n* Bool for nan values in players\n* Distance from players to the ball\n* Distance from players and ball to goal A and B\n* Closest team to the ball\n* Average distance of each team to each goal\n* Predicted position of ball\n* Mirror of the game in y and x axis\n* Inter-team players swap\n\nIt also includes the incremental learning algorithm as implemented by @landfallmotto in https://www.kaggle.com/code/landfallmotto/tps-oct-22-continue-training-method-lightgbm#Continue-Training-LightGBM-Model\n\nOn the shoulders of giants:\n* @pietromaldini1 [data augmentation discussion](https://www.kaggle.com/competitions/tabular-playground-series-oct-2022/discussion/357577)\n* @hsuyab [Fast loading & High Compression with Feather](https://www.kaggle.com/code/hsuyab/fast-loading-high-compression-with-feather)\n* @spyrow [Mirroring the board](https://www.kaggle.com/code/spyrow/playground-oct-2022-lgbmclassifier?scriptVersionId=107206095)\n* @landfallmotto [LGBM Continued learning](https://www.kaggle.com/code/landfallmotto/tps-oct-22-continue-training-method-lightgbm#Continue-Training-LightGBM-Model)\n* @pietromaldini1 [Goal-Ball-Player angle](https://www.kaggle.com/competitions/tabular-playground-series-oct-2022/discussion/356916)\n","metadata":{}},{"cell_type":"markdown","source":"# Feature Engineering","metadata":{}},{"cell_type":"code","source":"features = [\n    'ball_pos_x', 'ball_pos_y','ball_pos_z', 'ball_vel_x', 'ball_vel_y', 'ball_vel_z', \n    'p0_pos_x', 'p0_pos_y', 'p0_pos_z', 'p0_vel_x', 'p0_vel_y', 'p0_vel_z', 'p0_boost', 'p0_na',\n    'p1_pos_x', 'p1_pos_y', 'p1_pos_z', 'p1_vel_x', 'p1_vel_y', 'p1_vel_z', 'p1_boost', 'p1_na',\n    'p2_pos_x', 'p2_pos_y', 'p2_pos_z', 'p2_vel_x', 'p2_vel_y', 'p2_vel_z', 'p2_boost', 'p2_na',\n    'p3_pos_x', 'p3_pos_y', 'p3_pos_z', 'p3_vel_x', 'p3_vel_y', 'p3_vel_z', 'p3_boost', 'p3_na',\n    'p4_pos_x', 'p4_pos_y', 'p4_pos_z', 'p4_vel_x', 'p4_vel_y', 'p4_vel_z', 'p4_boost', 'p4_na',\n    'p5_pos_x', 'p5_pos_y', 'p5_pos_z', 'p5_vel_x', 'p5_vel_y', 'p5_vel_z', 'p5_boost', 'p5_na',\n    'boost0_timer', 'boost1_timer', 'boost2_timer', 'boost3_timer',\n    'boost4_timer', 'boost5_timer']\n\nfeatures_x_axis = [feature for feature in features if feature.endswith('_x')]\nfeatures_y_axis = [feature for feature in features if feature.endswith('_y')]\n\nfeatures_p0 = [feature for feature in features if ('0_' in feature)]\nfeatures_p1 = [feature for feature in features if ('1_' in feature)]\nfeatures_p2 = [feature for feature in features if ('2_' in feature)]\nfeatures_p3 = [feature for feature in features if ('3_' in feature)]\nfeatures_p4 = [feature for feature in features if ('4_' in feature)]\nfeatures_p5 = [feature for feature in features if ('5_' in feature)]\n\ntargets= [\"team_A_scoring_within_10sec\",\"team_B_scoring_within_10sec\"]","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.749134Z","iopub.execute_input":"2022-10-27T14:06:59.749928Z","iopub.status.idle":"2022-10-27T14:06:59.763321Z","shell.execute_reply.started":"2022-10-27T14:06:59.749892Z","shell.execute_reply":"2022-10-27T14:06:59.761794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def fe(x):\n    # indicators for respawns...\n    x['p0_na'] = x['p0_pos_x'].isna().astype('int8')\n    x['p1_na'] = x['p1_pos_x'].isna().astype('int8')\n    x['p2_na'] = x['p2_pos_x'].isna().astype('int8')\n    x['p3_na'] = x['p3_pos_x'].isna().astype('int8')\n    x['p4_na'] = x['p4_pos_x'].isna().astype('int8')\n    x['p5_na'] = x['p5_pos_x'].isna().astype('int8')\n    \n    for feature in features:\n        if feature.endswith('_na'):\n            continue\n        if feature.endswith('_x'):\n            x[feature] = (x[feature] / 82).fillna(0).astype('float16') #82\n        if feature.endswith('_y'):\n            x[feature] = (x[feature] / 120).fillna(0).astype('float16') #120\n        if feature.endswith('_z'):\n            x[feature] = (x[feature] / 40).fillna(0).astype('float16') #40\n        if feature.endswith('_boost'):\n            x[feature] = (x[feature] / 100).fillna(0).astype('float16')\n        if feature.endswith('_timer'):\n            x[feature] = (-x[feature] / 100).astype('float16')\n    return x","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.778287Z","iopub.execute_input":"2022-10-27T14:06:59.779429Z","iopub.status.idle":"2022-10-27T14:06:59.790436Z","shell.execute_reply.started":"2022-10-27T14:06:59.779388Z","shell.execute_reply":"2022-10-27T14:06:59.788913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vel_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\ngoalx = [0/82,0/82]\ngoaly = [-100/120,100/120]\ngoalz = [6.8/40,6.8/40]\n\ndef euclidian_norm(x):\n    return np.linalg.norm(x, axis=1)\n\ndef signed_angle_xy(p_ball, goal_ball):\n    return (np.arctan2(p_ball[:,[1]], p_ball[:,[0]])-np.arctan2(goal_ball[:,[1]], goal_ball[:,[0]])) * 180 / np.pi\n\ndef preprocess(df):\n    # velocity magnitude\n    for col, vec in vel_groups.items():\n        df[col] = euclidian_norm(df[vec])\n        df[col + \"_ball_angle\"] = signed_angle_xy(df[vec].values , df[vel_groups['ball_vel']].values)\n    \n    # players distance to ball and goal\n    for col, vec in pos_groups.items():\n        #ball\n        df[col + \"_ball_dist\"] = euclidian_norm(df[vec].values - df[pos_groups[\"ball_pos\"]].values)\n        #goal_A\n        df[col + \"_goal_A_dist\"] = euclidian_norm(df[vec].values - np.array([goalx[0],goaly[0],goalz[0]]))\n        #goal_B\n        df[col + \"_goal_B_dist\"] = euclidian_norm(df[vec].values - np.array([goalx[1],goaly[1],goalz[1]]))\n        #angle_p_goalA\n        df[col + \"_ball_goal_A_angle\"] = signed_angle_xy(\n            df[vec].values - df[pos_groups[\"ball_pos\"]].values,\n            np.array([goalx[0],goaly[0],goalz[0]] - df[pos_groups[\"ball_pos\"]].values))\n        #angle_p_goalB\n        df[col + \"_ball_goal_B_angle\"] = signed_angle_xy(\n            df[vec].values - df[pos_groups[\"ball_pos\"]].values,\n            np.array([goalx[1],goaly[1],goalz[1]] - df[pos_groups[\"ball_pos\"]].values))\n        \n        \n    df = df.drop(columns=['ball_pos_ball_dist', \"ball_pos_ball_goal_A_angle\", 'ball_pos_ball_goal_B_angle', 'ball_vel_ball_angle'])\n    \n    player_dict = {\n        'p0_pos_ball_dist':0, \n        'p1_pos_ball_dist':0, \n        'p2_pos_ball_dist':0,\n        'p3_pos_ball_dist':1,\n        'p4_pos_ball_dist':1,\n        'p5_pos_ball_dist':1\n    }\n    \n    df['closer_team_ball'] = df[['p0_pos_ball_dist', 'p1_pos_ball_dist', 'p2_pos_ball_dist','p3_pos_ball_dist','p4_pos_ball_dist','p5_pos_ball_dist']].T.idxmin()\n    df['closer_team_ball'] = df['closer_team_ball'].map(player_dict).astype('int8')\n    \n    df['avg_team_A_dist_goal_A'] = df[['p0_pos_goal_A_dist', 'p1_pos_goal_A_dist', 'p2_pos_goal_A_dist']].mean(axis=1)\n    df['avg_team_A_dist_goal_B'] = df[['p0_pos_goal_B_dist', 'p1_pos_goal_B_dist', 'p2_pos_goal_B_dist']].mean(axis=1)\n    \n    df['avg_team_B_dist_goal_A'] = df[['p3_pos_goal_A_dist', 'p4_pos_goal_A_dist', 'p5_pos_goal_A_dist']].mean(axis=1)\n    df['avg_team_B_dist_goal_B'] = df[['p3_pos_goal_B_dist', 'p4_pos_goal_B_dist', 'p5_pos_goal_B_dist']].mean(axis=1)\n    \n    df['ball_predy'] = (df['ball_vel_y']/9.66) + (df['ball_pos_y'])\n    df['ball_predx'] = (df['ball_vel_x']/9.66) + (df['ball_pos_x'])\n#     df['ball_predz'] = (df['ball_vel_z']/9.66) + (df['ball_pos_z'])\n\n    #predicted_y_pos\n    #df[\"p0_predy\"] = (df[\"p0_vel_y\"]/9.66) + (df[\"p0_pos_y\"])\n    #df[\"p1_predy\"] = (df[\"p1_vel_y\"]/9.66) + (df[\"p1_pos_y\"])\n    #df[\"p2_predy\"] = (df[\"p2_vel_y\"]/9.66) + (df[\"p2_pos_y\"])\n    #df[\"p3_predy\"] = (df[\"p3_vel_y\"]/9.66) + (df[\"p3_pos_y\"])\n    #df[\"p4_predy\"] = (df[\"p4_vel_y\"]/9.66) + (df[\"p4_pos_y\"])\n    #df[\"p5_predy\"] = (df[\"p5_vel_y\"]/9.66) + (df[\"p5_pos_y\"])\n    \n    df['pred_ball_pos_goal_A_dist'] = euclidian_norm(\n        ((df[['ball_vel_x', 'ball_vel_y', 'ball_vel_z']].values/9.66) + (df[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values))- np.array([goalx[0],goaly[0],goalz[0]])\n    )\n    df['pred_ball_pos_goal_B_dist'] = euclidian_norm(\n        ((df[['ball_vel_x', 'ball_vel_y', 'ball_vel_z']].values/9.66) + (df[['ball_pos_x', 'ball_pos_y', 'ball_pos_z']].values))- np.array([goalx[1],goaly[1],goalz[1]])\n    )\n    \n    \n    \n    return df","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.803635Z","iopub.execute_input":"2022-10-27T14:06:59.804269Z","iopub.status.idle":"2022-10-27T14:06:59.826680Z","shell.execute_reply.started":"2022-10-27T14:06:59.804233Z","shell.execute_reply":"2022-10-27T14:06:59.825049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data augmentation","metadata":{}},{"cell_type":"code","source":"dict_to_swap_players = lambda features_pi, features_pj:{feature_pi:feature_pj for feature_pi,feature_pj in zip(features_pi, features_pj)}\np0_to_p3 = dict_to_swap_players(features_p0, features_p3)\np1_to_p4 = dict_to_swap_players(features_p1, features_p4)\np2_to_p5 = dict_to_swap_players(features_p2, features_p5)\n\np3_to_p0 = dict_to_swap_players(features_p3, features_p0)\np4_to_p1 = dict_to_swap_players(features_p4, features_p1)\np5_to_p2 = dict_to_swap_players(features_p5, features_p2)\n\npA_to_pB = {**p0_to_p3,**p1_to_p4, **p2_to_p5, **p3_to_p0, **p4_to_p1, **p5_to_p2}\n\ndef mirror_game_in_y_x(df):\n    df_mirror = df.copy()\n    #Swap Y axis\n    df_mirror[features_y_axis] = -df_mirror[features_y_axis].copy()\n    #Swap X axis\n    df_mirror[features_x_axis] = -df_mirror[features_x_axis].copy()\n    #Swap team A players with team B players\n    df_mirror.rename(columns=pA_to_pB, inplace=True)\n    #Swap target (since it is a mirror, team B would annotate when team A was going to annotate.)\n    df_mirror.rename(columns={targets[0]:targets[1], targets[1]:targets[0]}, inplace=True)\n    \n    return df_mirror","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.832880Z","iopub.execute_input":"2022-10-27T14:06:59.833322Z","iopub.status.idle":"2022-10-27T14:06:59.846633Z","shell.execute_reply.started":"2022-10-27T14:06:59.833289Z","shell.execute_reply":"2022-10-27T14:06:59.845368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def swap_players(df):\n    \"\"\"Randomly swap each team`s players\"\"\"\n    np.random.seed(42)\n    team_A_player_features = [features_p0, features_p1, features_p2]\n    team_B_player_features = [features_p3, features_p4, features_p5]\n    \n    team_A_player_columns = list(itertools.chain.from_iterable(team_A_player_features))\n    team_B_player_columns = list(itertools.chain.from_iterable(team_B_player_features))    \n    \n    player_permutations = list(itertools.permutations(range(3)))\n    idx_to_swap = np.random.choice(range(len(player_permutations)), len(df))\n    for idx_group, permutation in enumerate(player_permutations):\n        swap_A_player_columns = list(itertools.chain.from_iterable([team_A_player_features[i] for i in permutation]))\n        df.iloc[np.where(idx_to_swap==idx_group)[0], df.columns.get_indexer(team_A_player_columns)]=df.iloc[np.where(idx_to_swap==idx_group)][swap_A_player_columns].values\n        \n    idx_to_swap = np.random.choice(range(len(player_permutations)), len(df))\n    for idx_group, permutation in enumerate(player_permutations):\n        swap_B_player_columns = list(itertools.chain.from_iterable([team_B_player_features[i] for i in permutation]))\n        df.iloc[np.where(idx_to_swap==idx_group)[0], df.columns.get_indexer(team_B_player_columns)]=df.iloc[np.where(idx_to_swap==idx_group)][swap_B_player_columns].values\n        \n    return df","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.856472Z","iopub.execute_input":"2022-10-27T14:06:59.856925Z","iopub.status.idle":"2022-10-27T14:06:59.871044Z","shell.execute_reply.started":"2022-10-27T14:06:59.856880Z","shell.execute_reply":"2022-10-27T14:06:59.869650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Incremental learning","metadata":{}},{"cell_type":"code","source":"import pathlib\n\ntrain_files = list(pathlib\\\n                   .Path('../input/data-shuffled-and-split-in-10-feather-files/feather_data/')\\\n                   .glob('shuffled_train*.ftr'))\ntrain_files.sort()","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.878205Z","iopub.execute_input":"2022-10-27T14:06:59.878605Z","iopub.status.idle":"2022-10-27T14:06:59.891002Z","shell.execute_reply.started":"2022-10-27T14:06:59.878565Z","shell.execute_reply":"2022-10-27T14:06:59.889724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lgbm_params = {\n    'objective':'binary',\n    'learning_rate':0.025,\n    'lambda_l2':2,\n    'path_smooth':1,\n    'boosting_type':'gbdt',\n    'num_leaves':100,\n#     'max_depth':10,\n    'extra_trees':True,\n    'bagging_freq':10,\n#     'bagging_fraction':0.7,\n    \"pos_bagging_fraction\": 0.7,\n    \"neg_bagging_fraction\": 0.7,\n    'num_iterations':250,\n    'force_col_wise':True,\n}\n\nn_iters=2\nfor n_iter in range(n_iters):    \n    \n    for train_file in train_files[0:10]:\n        print(f\"{train_file}:\")\n        print(\"Creating dataframe from file\")\n        if train_file == train_files[0]:\n            continue\n        if train_file == train_files[1]:\n            train_df_iter_0 = fe(pd.read_feather(train_files[0]))\n            train_df_iter_1 = fe(pd.read_feather(train_files[1]))\n            train_df_iter = pd.concat([train_df_iter_0, train_df_iter_1])\n            del train_df_iter_0, train_df_iter_1\n            gc.collect()\n        else:\n            train_df_iter = fe(pd.read_feather(train_file))\n            \n        print(\"Appending mirror game\")\n        train_df_iter = pd.concat([train_df_iter, mirror_game_in_y_x(train_df_iter)])\n            \n        print(\"Swaping among teamplayers\")\n        train_df_iter = swap_players(train_df_iter.copy())\n\n        print(\"Adding new features\")\n        train_df_iter = preprocess(train_df_iter.copy())\n\n        train_df_iter = train_df_iter.drop([\"game_num\",\"event_id\",\"event_time\",\"player_scoring_next\",\"team_scoring_next\"],axis=1)\n\n        X = train_df_iter.drop([\"team_A_scoring_within_10sec\",\"team_B_scoring_within_10sec\"],axis=1)\n        yA = train_df_iter[[\"team_A_scoring_within_10sec\"]]\n        yB = train_df_iter[[\"team_B_scoring_within_10sec\"]]\n\n        del train_df_iter\n        gc.collect()\n\n        print(\"Getting train and valid sets\")\n        train_XA,valid_XA,train_yA,valid_yA = train_test_split(X,yA,test_size=0.05,random_state=42)\n\n        del yA\n        gc.collect()\n\n        train_XB,valid_XB,train_yB,valid_yB = train_test_split(X,yB,test_size=0.05,random_state=42)\n\n        del X, yB\n        gc.collect()\n\n        lgb_train_a = lgb.Dataset(train_XA, train_yA)\n        lgb_eval_a = lgb.Dataset(valid_XA, valid_yA, reference=lgb_train_a)\n        lgb_train_b = lgb.Dataset(train_XB, train_yB)\n        lgb_eval_b = lgb.Dataset(valid_XB, valid_yB, reference=lgb_train_b)\n\n        # model A\n        print(f\"Training model A. File:{train_file}\")\n        if train_file == train_files[0]:\n            continue\n        if (train_file == train_files[1]) & (n_iter == 0):\n            evals = {}\n            model_A = lgb.train(lgbm_params,lgb_train_a, valid_sets=[lgb_eval_a, lgb_train_a], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], keep_training_booster=True, verbose_eval=100)\n        elif train_file != train_files[9]:\n            evals = {}\n            model_A_iter = lgb.train(lgbm_params,lgb_train_a, valid_sets=[lgb_eval_a, lgb_train_a], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], keep_training_booster=True, init_model=model_A, verbose_eval=100)\n            model_A = model_A_iter  \n        else:\n            evals = {}\n            model_A_iter = lgb.train(lgbm_params,lgb_train_a, valid_sets=[lgb_eval_a, lgb_train_a], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], init_model=model_A, verbose_eval=100)\n            model_A = model_A_iter\n\n        del train_XA,train_yA, valid_XA, valid_yA\n        lgb.plot_metric(evals, title=\"Model A log loss during training\")\n        gc.collect()\n\n        # model B\n        print(f\"Training model B. File:{train_file}\")\n        if train_file == train_files[0]:\n            continue\n        if (train_file == train_files[1]) & (n_iter == 0):\n            evals = {}\n            model_B = lgb.train(lgbm_params,lgb_train_b, valid_sets=[lgb_eval_b, lgb_train_b], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], keep_training_booster=True, verbose_eval=100)\n            lgbm_params['learning_rate']=0.025\n            lgbm_params['num_iterations']=150\n        elif train_file != train_files[9]:\n            evals = {}\n            model_B_iter = lgb.train(lgbm_params,lgb_train_b, valid_sets=[lgb_eval_b, lgb_train_b], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], keep_training_booster=True, init_model=model_B, verbose_eval=100)\n            model_B = model_B_iter\n        #         lgbm_params['learning_rate']=lgbm_params['learning_rate']-0.002        \n        else:\n            evals = {}\n            model_B_iter = lgb.train(lgbm_params,lgb_train_b, valid_sets=[lgb_eval_b, lgb_train_b], valid_names=[\"eval\", \"train\"], callbacks = [lgb.record_evaluation(evals)], init_model=model_B, verbose_eval=100)\n            model_B = model_B_iter\n        del train_XB,train_yB,valid_XB,valid_yB\n        lgb.plot_metric(evals, title=\"Model B log loss during training\")\n        gc.collect()\n                    \n    print(f\"Finished round {n_iter}/{n_iters}\")","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:06:59.906875Z","iopub.execute_input":"2022-10-27T14:06:59.907884Z","iopub.status.idle":"2022-10-27T14:22:52.216210Z","shell.execute_reply.started":"2022-10-27T14:06:59.907811Z","shell.execute_reply":"2022-10-27T14:22:52.214442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"from pathlib import Path\ninput_path = Path('../input/fast-loading-high-compression-with-feather/feather_data')\ndef read_test():\n    return fe(pd.read_feather(input_path / 'test_compressed.ftr'))","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:22:52.217000Z","iopub.status.idle":"2022-10-27T14:22:52.217421Z","shell.execute_reply.started":"2022-10-27T14:22:52.217222Z","shell.execute_reply":"2022-10-27T14:22:52.217242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = read_test()\ntest = preprocess(test)","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:22:52.218623Z","iopub.status.idle":"2022-10-27T14:22:52.219015Z","shell.execute_reply.started":"2022-10-27T14:22:52.218819Z","shell.execute_reply":"2022-10-27T14:22:52.218845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X = test.drop([\"id\"],axis=1)\npredict_A = model_A.predict(test_X)#[:,1]\npredict_B = model_B.predict(test_X)#[:,1]\n\nprint(predict_A)\nprint(predict_B)","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:22:52.220476Z","iopub.status.idle":"2022-10-27T14:22:52.220852Z","shell.execute_reply.started":"2022-10-27T14:22:52.220663Z","shell.execute_reply":"2022-10-27T14:22:52.220680Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv(\"../input/tabular-playground-series-oct-2022/sample_submission.csv\")\nsubmission[\"team_A_scoring_within_10sec\"] = predict_A\nsubmission[\"team_B_scoring_within_10sec\"] = predict_B\n\ndisplay(submission)\n\nsubmission.to_csv(\"submission_feather_100_euclidian_100leaves_250_150iter_mirror_bpredyxz_swapplyr_2rounds_posvelangles.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2022-10-27T14:22:52.221952Z","iopub.status.idle":"2022-10-27T14:22:52.222358Z","shell.execute_reply.started":"2022-10-27T14:22:52.222166Z","shell.execute_reply":"2022-10-27T14:22:52.222185Z"},"trusted":true},"execution_count":null,"outputs":[]}]}