{"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 pandas as pd\nimport numpy as np\nimport plotly.express as px\nimport seaborn as sns\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\n#!pip install raceplotly\n#from raceplotly.plots import barplot","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2021-07-27T18:34:56.155883Z","iopub.execute_input":"2021-07-27T18:34:56.156329Z","iopub.status.idle":"2021-07-27T18:34:58.654071Z","shell.execute_reply.started":"2021-07-27T18:34:56.156241Z","shell.execute_reply":"2021-07-27T18:34:58.653190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players = pd.read_csv('../input/mlb-player-digital-engagement-forecasting/players.csv')\nseasons = pd.read_csv('../input/mlb-player-digital-engagement-forecasting/seasons.csv')\nawards = pd.read_csv('../input/mlb-player-digital-engagement-forecasting/awards.csv')\nteams = pd.read_csv('../input/mlb-player-digital-engagement-forecasting/teams.csv')\ntrain = pd.read_csv('../input/mlb-player-digital-engagement-forecasting/train.csv')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:34:58.656924Z","iopub.execute_input":"2021-07-27T18:34:58.657486Z","iopub.status.idle":"2021-07-27T18:36:21.629520Z","shell.execute_reply.started":"2021-07-27T18:34:58.657451Z","shell.execute_reply":"2021-07-27T18:36:21.628104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:21.632088Z","iopub.execute_input":"2021-07-27T18:36:21.632437Z","iopub.status.idle":"2021-07-27T18:36:21.688094Z","shell.execute_reply.started":"2021-07-27T18:36:21.632396Z","shell.execute_reply":"2021-07-27T18:36:21.686952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:21.690205Z","iopub.execute_input":"2021-07-27T18:36:21.690652Z","iopub.status.idle":"2021-07-27T18:36:21.721233Z","shell.execute_reply.started":"2021-07-27T18:36:21.690605Z","shell.execute_reply":"2021-07-27T18:36:21.720056Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:21.722491Z","iopub.execute_input":"2021-07-27T18:36:21.722786Z","iopub.status.idle":"2021-07-27T18:36:21.951787Z","shell.execute_reply.started":"2021-07-27T18:36:21.722757Z","shell.execute_reply":"2021-07-27T18:36:21.950761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"I am using an unnested dataset created by @Ml_Bear link of the original [kernel](https://www.kaggle.com/naotaka1128/creating-unnested-dataset) do check it out","metadata":{}},{"cell_type":"code","source":"train_next_day = pd.read_pickle('../input/mlb-unnested/train_nextDayPlayerEngagement.pickle')\ntrain_next_day.engagementMetricsDate = train_next_day.engagementMetricsDate.astype('datetime64')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:21.953013Z","iopub.execute_input":"2021-07-27T18:36:21.953302Z","iopub.status.idle":"2021-07-27T18:36:24.716862Z","shell.execute_reply.started":"2021-07-27T18:36:21.953274Z","shell.execute_reply":"2021-07-27T18:36:24.715893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_next_day","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:24.718190Z","iopub.execute_input":"2021-07-27T18:36:24.718505Z","iopub.status.idle":"2021-07-27T18:36:24.744705Z","shell.execute_reply.started":"2021-07-27T18:36:24.718474Z","shell.execute_reply":"2021-07-27T18:36:24.743671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_next_day.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:24.747224Z","iopub.execute_input":"2021-07-27T18:36:24.747732Z","iopub.status.idle":"2021-07-27T18:36:24.762352Z","shell.execute_reply.started":"2021-07-27T18:36:24.747697Z","shell.execute_reply":"2021-07-27T18:36:24.761227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_date = list(train_next_day.engagementMetricsDate.unique())\ntarget1_lis = []\ntarget2_lis = []\ntarget3_lis = []\ntarget4_lis = []\nfor i in unique_date:\n    df = train_next_day[train_next_day['engagementMetricsDate']==i]\n    target1 = (df['target1'].sum())/len(df)\n    target2 = (df['target2'].sum())/len(df)\n    target3 = (df['target3'].sum())/len(df)\n    target4 = (df['target4'].sum())/len(df)\n    target1_lis.append(target1)\n    target2_lis.append(target2)\n    target3_lis.append(target3)\n    target4_lis.append(target4)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:24.764533Z","iopub.execute_input":"2021-07-27T18:36:24.765014Z","iopub.status.idle":"2021-07-27T18:36:36.201278Z","shell.execute_reply.started":"2021-07-27T18:36:24.764942Z","shell.execute_reply":"2021-07-27T18:36:36.200330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(x=unique_date,y=target1_lis,title='target 1 over time')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:36.202582Z","iopub.execute_input":"2021-07-27T18:36:36.202868Z","iopub.status.idle":"2021-07-27T18:36:37.546901Z","shell.execute_reply.started":"2021-07-27T18:36:36.202839Z","shell.execute_reply":"2021-07-27T18:36:37.545763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(x=unique_date,y=target2_lis,title='target 2 over time')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.548628Z","iopub.execute_input":"2021-07-27T18:36:37.549071Z","iopub.status.idle":"2021-07-27T18:36:37.667066Z","shell.execute_reply.started":"2021-07-27T18:36:37.549026Z","shell.execute_reply":"2021-07-27T18:36:37.665923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(x=unique_date,y=target3_lis,title='target 3 over time')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.668863Z","iopub.execute_input":"2021-07-27T18:36:37.669322Z","iopub.status.idle":"2021-07-27T18:36:37.787483Z","shell.execute_reply.started":"2021-07-27T18:36:37.669266Z","shell.execute_reply":"2021-07-27T18:36:37.786251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(x=unique_date,y=target4_lis,title='target 4 over time')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.789123Z","iopub.execute_input":"2021-07-27T18:36:37.789547Z","iopub.status.idle":"2021-07-27T18:36:37.910451Z","shell.execute_reply.started":"2021-07-27T18:36:37.789505Z","shell.execute_reply":"2021-07-27T18:36:37.909275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"team_twitter = pd.read_pickle('../input/mlb-unnested/train_teamTwitterFollowers.pickle')\nteam_twitter","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.911884Z","iopub.execute_input":"2021-07-27T18:36:37.912222Z","iopub.status.idle":"2021-07-27T18:36:37.949154Z","shell.execute_reply.started":"2021-07-27T18:36:37.912188Z","shell.execute_reply":"2021-07-27T18:36:37.948078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#my_raceplot = barplot(team_twitter,  item_column='teamName', value_column='numberOfFollowers', time_column='date')\n#my_raceplot.plot(item_label = 'team name', value_label = 'number of followers', frame_duration = 800)","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.950714Z","iopub.execute_input":"2021-07-27T18:36:37.951157Z","iopub.status.idle":"2021-07-27T18:36:37.955417Z","shell.execute_reply.started":"2021-07-27T18:36:37.951109Z","shell.execute_reply":"2021-07-27T18:36:37.954482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"standings = pd.read_pickle('../input/mlb-unnested/train_standings.pickle')\ntransactions = pd.read_pickle('../input/mlb-unnested/train_transactions.pickle')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:37.956952Z","iopub.execute_input":"2021-07-27T18:36:37.957517Z","iopub.status.idle":"2021-07-27T18:36:38.190883Z","shell.execute_reply.started":"2021-07-27T18:36:37.957465Z","shell.execute_reply":"2021-07-27T18:36:38.189939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#my_raceplot = barplot(standings,  item_column='teamName',value_column='wins', time_column='dailyDataDate',top_entries=10)\n#my_raceplot.plot(item_label = 'team name', value_label = 'current wins', frame_duration = 800)","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.192258Z","iopub.execute_input":"2021-07-27T18:36:38.192571Z","iopub.status.idle":"2021-07-27T18:36:38.195910Z","shell.execute_reply.started":"2021-07-27T18:36:38.192540Z","shell.execute_reply":"2021-07-27T18:36:38.195061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions = transactions.dropna()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.197246Z","iopub.execute_input":"2021-07-27T18:36:38.197534Z","iopub.status.idle":"2021-07-27T18:36:38.291056Z","shell.execute_reply.started":"2021-07-27T18:36:38.197505Z","shell.execute_reply":"2021-07-27T18:36:38.290005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.292630Z","iopub.execute_input":"2021-07-27T18:36:38.293062Z","iopub.status.idle":"2021-07-27T18:36:38.326131Z","shell.execute_reply.started":"2021-07-27T18:36:38.293017Z","shell.execute_reply":"2021-07-27T18:36:38.325077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"most_transaction_team=transactions.groupby('fromTeamName')['toTeamName'].count().reset_index(name='Count').sort_values('Count',ascending=False)\npx.bar(most_transaction_team.head(10),x='fromTeamName',y='Count')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.327643Z","iopub.execute_input":"2021-07-27T18:36:38.328075Z","iopub.status.idle":"2021-07-27T18:36:38.416912Z","shell.execute_reply.started":"2021-07-27T18:36:38.328030Z","shell.execute_reply":"2021-07-27T18:36:38.415944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"most_transaction_player=transactions.groupby('playerName')['toTeamName'].count().reset_index(name='Count').sort_values('Count',ascending=False)\npx.bar(most_transaction_player.head(10),x='playerName',y='Count')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.418366Z","iopub.execute_input":"2021-07-27T18:36:38.418668Z","iopub.status.idle":"2021-07-27T18:36:38.485184Z","shell.execute_reply.started":"2021-07-27T18:36:38.418636Z","shell.execute_reply":"2021-07-27T18:36:38.484247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.486495Z","iopub.execute_input":"2021-07-27T18:36:38.486805Z","iopub.status.idle":"2021-07-27T18:36:38.504570Z","shell.execute_reply.started":"2021-07-27T18:36:38.486774Z","shell.execute_reply":"2021-07-27T18:36:38.503636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.info()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.508006Z","iopub.execute_input":"2021-07-27T18:36:38.508325Z","iopub.status.idle":"2021-07-27T18:36:38.529520Z","shell.execute_reply.started":"2021-07-27T18:36:38.508292Z","shell.execute_reply":"2021-07-27T18:36:38.528430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(players,x='birthCountry',color='birthCountry')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.531507Z","iopub.execute_input":"2021-07-27T18:36:38.531811Z","iopub.status.idle":"2021-07-27T18:36:38.763575Z","shell.execute_reply.started":"2021-07-27T18:36:38.531781Z","shell.execute_reply":"2021-07-27T18:36:38.762498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.scatter(players,x='weight',y='heightInches')","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:38.765125Z","iopub.execute_input":"2021-07-27T18:36:38.765444Z","iopub.status.idle":"2021-07-27T18:36:38.845980Z","shell.execute_reply.started":"2021-07-27T18:36:38.765412Z","shell.execute_reply":"2021-07-27T18:36:38.844955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"playerid = list(awards['playerId'])\naward_count = []\nfor i in playerid:\n    award_count.append(len(awards[awards['playerId']==i]))\naward_count = pd.DataFrame({\"playerId\":playerid,\"award_count\":award_count})\nplayers = pd.merge(players,award_count,on='playerId')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:38.847320Z","iopub.execute_input":"2021-07-27T18:36:38.847625Z","iopub.status.idle":"2021-07-27T18:36:47.360582Z","shell.execute_reply.started":"2021-07-27T18:36:38.847594Z","shell.execute_reply":"2021-07-27T18:36:47.359423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"postition_list = list(players['primaryPositionName'].unique())\naward_count_sum = []\nfor i in postition_list:\n    award_count_sum.append(players[players['primaryPositionName']==i]['award_count'].sum()) ","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:47.361945Z","iopub.execute_input":"2021-07-27T18:36:47.362276Z","iopub.status.idle":"2021-07-27T18:36:47.399057Z","shell.execute_reply.started":"2021-07-27T18:36:47.362244Z","shell.execute_reply":"2021-07-27T18:36:47.398113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(x=postition_list,y=award_count_sum)","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:47.400580Z","iopub.execute_input":"2021-07-27T18:36:47.401050Z","iopub.status.idle":"2021-07-27T18:36:47.466853Z","shell.execute_reply.started":"2021-07-27T18:36:47.401003Z","shell.execute_reply":"2021-07-27T18:36:47.465923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"most_award = awards['playerId'].mode()\nprint(f\"playerID: {most_award.values}\")\nawards[awards['playerId'] == 405395]","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:47.468115Z","iopub.execute_input":"2021-07-27T18:36:47.468409Z","iopub.status.idle":"2021-07-27T18:36:47.494119Z","shell.execute_reply.started":"2021-07-27T18:36:47.468379Z","shell.execute_reply":"2021-07-27T18:36:47.492949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(awards,y='awardName',category_orders=awards['awardName'])","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:47.495362Z","iopub.execute_input":"2021-07-27T18:36:47.495644Z","iopub.status.idle":"2021-07-27T18:36:47.665505Z","shell.execute_reply.started":"2021-07-27T18:36:47.495616Z","shell.execute_reply":"2021-07-27T18:36:47.664724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_preiction = pd.read_pickle('../input/mlb-unnested/example_sample_submission.pickle')\nexample_test_games = pd.read_pickle('../input/mlb-unnested/example_test_games.pickle')\ntrain_games = pd.read_pickle('../input/mlb-unnested/train_games.pickle')\ntrain_next_day = pd.read_pickle('../input/mlb-unnested/train_nextDayPlayerEngagement.pickle')\ntrain_next_day['year'] = pd.DatetimeIndex(train_next_day['engagementMetricsDate']).year","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2021-07-27T18:36:47.666540Z","iopub.execute_input":"2021-07-27T18:36:47.666947Z","iopub.status.idle":"2021-07-27T18:36:49.409508Z","shell.execute_reply.started":"2021-07-27T18:36:47.666915Z","shell.execute_reply":"2021-07-27T18:36:49.408450Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"year = train_next_day.year.unique()\nweight=[0.05,0.05,0.1,0.8]#Experiment here with different values","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:49.411061Z","iopub.execute_input":"2021-07-27T18:36:49.411503Z","iopub.status.idle":"2021-07-27T18:36:49.434866Z","shell.execute_reply.started":"2021-07-27T18:36:49.411457Z","shell.execute_reply":"2021-07-27T18:36:49.433894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def weighted_median(df, val, weight):\n    df_sorted = df.sort_values(val)\n    cumsum = df_sorted[weight].cumsum()\n    cutoff = df_sorted[weight].sum() / 2.\n    return df_sorted[cumsum >= cutoff][val].iloc[0]","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:49.436406Z","iopub.execute_input":"2021-07-27T18:36:49.436860Z","iopub.status.idle":"2021-07-27T18:36:49.443247Z","shell.execute_reply.started":"2021-07-27T18:36:49.436817Z","shell.execute_reply":"2021-07-27T18:36:49.442213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def preprocess(df,weight,year):\n    for i in range(len(year)):\n        df.loc[df['year']==year[i],'weight'] = weight[i]\npreprocess(train_next_day,weight,year)","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:49.445304Z","iopub.execute_input":"2021-07-27T18:36:49.445591Z","iopub.status.idle":"2021-07-27T18:36:49.560909Z","shell.execute_reply.started":"2021-07-27T18:36:49.445563Z","shell.execute_reply":"2021-07-27T18:36:49.559818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_next_day.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:49.562208Z","iopub.execute_input":"2021-07-27T18:36:49.562487Z","iopub.status.idle":"2021-07-27T18:36:49.577500Z","shell.execute_reply.started":"2021-07-27T18:36:49.562459Z","shell.execute_reply":"2021-07-27T18:36:49.576724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"playerId = train_next_day['playerId'].unique()\nfor i in playerId:\n    df=train_next_day[train_next_day['playerId']==i]\n    wm1 = weighted_median(df,'target1','weight')\n    wm2 = weighted_median(df,'target2','weight')\n    wm3 = weighted_median(df,'target3','weight')\n    wm4 = weighted_median(df,'target4','weight')\n    train_next_day.loc[train_next_day['playerId']==i,'target1'] = wm1\n    train_next_day.loc[train_next_day['playerId']==i,'target2'] = wm2\n    train_next_day.loc[train_next_day['playerId']==i,'target3'] = wm3\n    train_next_day.loc[train_next_day['playerId']==i,'target4'] = wm4","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:36:49.578598Z","iopub.execute_input":"2021-07-27T18:36:49.579064Z","iopub.status.idle":"2021-07-27T18:38:37.955045Z","shell.execute_reply.started":"2021-07-27T18:36:49.579023Z","shell.execute_reply":"2021-07-27T18:38:37.954001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_mean = train_next_day.groupby([\"playerId\"])[[\"target1\",\"target2\",\"target3\",\"target4\"]].median().reset_index()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2021-07-27T18:38:37.956558Z","iopub.execute_input":"2021-07-27T18:38:37.956988Z","iopub.status.idle":"2021-07-27T18:38:38.320517Z","shell.execute_reply.started":"2021-07-27T18:38:37.956928Z","shell.execute_reply":"2021-07-27T18:38:38.319333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_mean.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:38:38.322031Z","iopub.execute_input":"2021-07-27T18:38:38.322342Z","iopub.status.idle":"2021-07-27T18:38:38.334277Z","shell.execute_reply.started":"2021-07-27T18:38:38.322313Z","shell.execute_reply":"2021-07-27T18:38:38.333140Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def process_pred(df):\n    df[\"playerId\"] = df[\"date_playerId\"].apply(lambda x: int( x.split(\"_\")[1] ) )\n    df.drop([\"target1\",\"target2\",\"target3\",\"target4\"], axis=1, inplace=True)\n    df = df.merge(train_mean, on=\"playerId\", how=\"left\")\n    df.drop(\"playerId\", axis=1, inplace=True)\n    df = df.fillna(0.)\n    return df","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:38:38.335515Z","iopub.execute_input":"2021-07-27T18:38:38.335876Z","iopub.status.idle":"2021-07-27T18:38:38.346049Z","shell.execute_reply.started":"2021-07-27T18:38:38.335843Z","shell.execute_reply":"2021-07-27T18:38:38.345214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import mlb\nenv = mlb.make_env() # initialize the environment\niter_test = env.iter_test() # iterator which loops over each date in test set\n\nfor (test_df, sample_prediction_df) in iter_test:\n    sample_prediction_df = process_pred(sample_prediction_df)\n    env.predict(sample_prediction_df)","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:38:38.347255Z","iopub.execute_input":"2021-07-27T18:38:38.347793Z","iopub.status.idle":"2021-07-27T18:38:40.106483Z","shell.execute_reply.started":"2021-07-27T18:38:38.347758Z","shell.execute_reply":"2021-07-27T18:38:40.105636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_prediction_df.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-27T18:38:40.107663Z","iopub.execute_input":"2021-07-27T18:38:40.108189Z","iopub.status.idle":"2021-07-27T18:38:40.121394Z","shell.execute_reply.started":"2021-07-27T18:38:40.108140Z","shell.execute_reply":"2021-07-27T18:38:40.120318Z"},"trusted":true},"execution_count":null,"outputs":[]}]}