{
  "id": 131539,
  "title": "How to score 0 and why you should not do this",
  "url": "/competitions/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/discussion/131539",
  "author_name": "Roman",
  "post_date": "2020-02-20T09:23:05.079000",
  "votes": 22,
  "comment_count": 7,
  "views": 0,
  "content": "<p>First of all, those of you who just joined this competition and are not dived deep into the data yet, I want to warn that current LB does not reflect the situation in the competition and does not help you tune your model in any way.</p>\n\n<p>This is because the true labels for the current submission file are provided in data itself.</p>\n\n<p>In this data we have results of all the games played by the teams since 1985 and up until now (2019 is the last season we have data for).  What we will need to do on stage 2 of the competition is to <strong>predict 2020 season results</strong> using all of this data.</p>\n\n<p>So the wise thing is to create your custom validation, using all of the provided true labels, and train you model using it. </p>\n\n<p>That being said I'm providing a code to fill the true labels into the submission file.</p>\n\n<p><em>Loading sample submission file and file with tourney results</em>\n```\nsub = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv')</p>\n\n<p>MNCAATourneyCompactResults = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyCompactResults.csv')\n```</p>\n\n<p><em>Expand ID field into columns of Season and Team's IDs</em>\n<code>\nsub = pd.concat([sub, sub['ID'].str.split('_', expand=True).rename(columns={0: 'Season', 1: 'Team1', 2: 'Team2'}).astype(np.int64)], axis=1)\n</code></p>\n\n<p><em>Pay attention that we merge on left (submission file), so Team1 id will always be &lt; than Team2 id</em>\n<code>\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team1', 'Team2'], right_on=['Season', 'WTeamID', 'LTeamID'])\n</code></p>\n\n<p><em>So all of this results are wins by first team</em>\n<code>\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 1\n</code></p>\n\n<p><em>And vice versa</em>\n<code>\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team2', 'Team1'], right_on=['Season', 'WTeamID', 'LTeamID'])\n</code></p>\n\n<p><em>Now all of the results are losses by first team</em>\n<code>\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 0\n</code></p>\n\n<p><em>Removing columns which we don't need any longer</em>\n<code>\nsub = sub.drop(['Season', 'Team1', 'Team2'], axis=1)\n</code></p>\n\n<p>And this is it. Now in sub DataFrame you have true labels for all the games been played. Only 335 rows of it matters, since we have to predict any possible game between any of the teams participated in the tournament. But, of course, only few of them were really played.</p>",
  "messages": [
    {
      "id": 751559,
      "postDate": "2020-02-20T09:23:05.080Z",
      "content": "<p>First of all, those of you who just joined this competition and are not dived deep into the data yet, I want to warn that current LB does not reflect the situation in the competition and does not help you tune your model in any way.</p>\n\n<p>This is because the true labels for the current submission file are provided in data itself.</p>\n\n<p>In this data we have results of all the games played by the teams since 1985 and up until now (2019 is the last season we have data for).  What we will need to do on stage 2 of the competition is to <strong>predict 2020 season results</strong> using all of this data.</p>\n\n<p>So the wise thing is to create your custom validation, using all of the provided true labels, and train you model using it. </p>\n\n<p>That being said I'm providing a code to fill the true labels into the submission file.</p>\n\n<p><em>Loading sample submission file and file with tourney results</em>\n```\nsub = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv')</p>\n\n<p>MNCAATourneyCompactResults = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyCompactResults.csv')\n```</p>\n\n<p><em>Expand ID field into columns of Season and Team's IDs</em>\n<code>\nsub = pd.concat([sub, sub['ID'].str.split('_', expand=True).rename(columns={0: 'Season', 1: 'Team1', 2: 'Team2'}).astype(np.int64)], axis=1)\n</code></p>\n\n<p><em>Pay attention that we merge on left (submission file), so Team1 id will always be &lt; than Team2 id</em>\n<code>\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team1', 'Team2'], right_on=['Season', 'WTeamID', 'LTeamID'])\n</code></p>\n\n<p><em>So all of this results are wins by first team</em>\n<code>\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 1\n</code></p>\n\n<p><em>And vice versa</em>\n<code>\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team2', 'Team1'], right_on=['Season', 'WTeamID', 'LTeamID'])\n</code></p>\n\n<p><em>Now all of the results are losses by first team</em>\n<code>\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 0\n</code></p>\n\n<p><em>Removing columns which we don't need any longer</em>\n<code>\nsub = sub.drop(['Season', 'Team1', 'Team2'], axis=1)\n</code></p>\n\n<p>And this is it. Now in sub DataFrame you have true labels for all the games been played. Only 335 rows of it matters, since we have to predict any possible game between any of the teams participated in the tournament. But, of course, only few of them were really played.</p>",
      "rawMarkdown": "First of all, those of you who just joined this competition and are not dived deep into the data yet, I want to warn that current LB does not reflect the situation in the competition and does not help you tune your model in any way.\n\nThis is because the true labels for the current submission file are provided in data itself.\n\nIn this data we have results of all the games played by the teams since 1985 and up until now (2019 is the last season we have data for).  What we will need to do on stage 2 of the competition is to **predict 2020 season results** using all of this data.\n\nSo the wise thing is to create your custom validation, using all of the provided true labels, and train you model using it. \n\nThat being said I'm providing a code to fill the true labels into the submission file.\n\n*Loading sample submission file and file with tourney results*\n```\nsub = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv')\n\nMNCAATourneyCompactResults = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyCompactResults.csv')\n```\n\n*Expand ID field into columns of Season and Team's IDs*\n```\nsub = pd.concat([sub, sub['ID'].str.split('_', expand=True).rename(columns={0: 'Season', 1: 'Team1', 2: 'Team2'}).astype(np.int64)], axis=1)\n```\n\n*Pay attention that we merge on left (submission file), so Team1 id will always be &lt; than Team2 id*\n```\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team1', 'Team2'], right_on=['Season', 'WTeamID', 'LTeamID'])\n```\n\n*So all of this results are wins by first team*\n```\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 1\n```\n\n*And vice versa*\n```\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team2', 'Team1'], right_on=['Season', 'WTeamID', 'LTeamID'])\n```\n\n*Now all of the results are losses by first team*\n```\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 0\n```\n\n*Removing columns which we don't need any longer*\n```\nsub = sub.drop(['Season', 'Team1', 'Team2'], axis=1)\n```\n\nAnd this is it. Now in sub DataFrame you have true labels for all the games been played. Only 335 rows of it matters, since we have to predict any possible game between any of the teams participated in the tournament. But, of course, only few of them were really played.",
      "votes": 22
    },
    {
      "id": 752012,
      "postDate": "2020-02-20T17:48:08.943Z",
      "content": "<p>Great</p>",
      "rawMarkdown": "Great",
      "votes": 12
    },
    {
      "id": 752693,
      "postDate": "2020-02-21T10:04:27.377Z",
      "content": "<p>Good</p>",
      "rawMarkdown": "Good"
    },
    {
      "id": 752181,
      "postDate": "2020-02-20T19:30:19.877Z",
      "content": "<p>Nice</p>",
      "rawMarkdown": "Nice"
    },
    {
      "id": 751625,
      "postDate": "2020-02-20T10:49:48.773Z",
      "content": "<p>very nice!!</p>",
      "rawMarkdown": "very nice!!"
    },
    {
      "id": 762456,
      "postDate": "2020-03-03T14:25:53.700Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 753416,
      "postDate": "2020-02-22T06:32:21.503Z",
      "content": "<p>oo thank you so much , nice write up</p>",
      "rawMarkdown": "oo thank you so much , nice write up",
      "votes": 1
    },
    {
      "id": 753515,
      "postDate": "2020-02-22T10:01:37.833Z",
      "content": "<p>Thanks for sharing！</p>",
      "rawMarkdown": "Thanks for sharing！"
    }
  ],
  "comments": [
    {
      "id": 752012,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-02-20T17:48:08.943000",
      "content": "<p>Great</p>",
      "votes": 12,
      "replies": []
    },
    {
      "id": 752693,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-02-21T10:04:27.377000",
      "content": "<p>Good</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 752181,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-02-20T19:30:19.877000",
      "content": "<p>Nice</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 751625,
      "author_name": "Victor Menuzzo",
      "author_url": "",
      "post_date": "2020-02-20T10:49:48.773000",
      "content": "<p>very nice!!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 762456,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-03-03T14:25:53.700000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 753416,
      "author_name": "Deepak Deepu",
      "author_url": "",
      "post_date": "2020-02-22T06:32:21.503000",
      "content": "<p>oo thank you so much , nice write up</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 753515,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-02-22T10:01:37.833000",
      "content": "<p>Thanks for sharing！</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "751559": "First of all, those of you who just joined this competition and are not dived deep into the data yet, I want to warn that current LB does not reflect the situation in the competition and does not help you tune your model in any way.\n\nThis is because the true labels for the current submission file are provided in data itself.\n\nIn this data we have results of all the games played by the teams since 1985 and up until now (2019 is the last season we have data for).  What we will need to do on stage 2 of the competition is to **predict 2020 season results** using all of this data.\n\nSo the wise thing is to create your custom validation, using all of the provided true labels, and train you model using it. \n\nThat being said I'm providing a code to fill the true labels into the submission file.\n\n*Loading sample submission file and file with tourney results*\n```\nsub = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv')\n\nMNCAATourneyCompactResults = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyCompactResults.csv')\n```\n\n*Expand ID field into columns of Season and Team's IDs*\n```\nsub = pd.concat([sub, sub['ID'].str.split('_', expand=True).rename(columns={0: 'Season', 1: 'Team1', 2: 'Team2'}).astype(np.int64)], axis=1)\n```\n\n*Pay attention that we merge on left (submission file), so Team1 id will always be &lt; than Team2 id*\n```\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team1', 'Team2'], right_on=['Season', 'WTeamID', 'LTeamID'])\n```\n\n*So all of this results are wins by first team*\n```\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 1\n```\n\n*And vice versa*\n```\nmerge = pd.merge(sub, MNCAATourneyCompactResults[['Season', 'WTeamID', 'LTeamID']], how='left', left_on=['Season', 'Team2', 'Team1'], right_on=['Season', 'WTeamID', 'LTeamID'])\n```\n\n*Now all of the results are losses by first team*\n```\nsub.loc[~merge['WTeamID'].isnull(), 'Pred'] = 0\n```\n\n*Removing columns which we don't need any longer*\n```\nsub = sub.drop(['Season', 'Team1', 'Team2'], axis=1)\n```\n\nAnd this is it. Now in sub DataFrame you have true labels for all the games been played. Only 335 rows of it matters, since we have to predict any possible game between any of the teams participated in the tournament. But, of course, only few of them were really played.",
    "752012": "Great",
    "752693": "Good",
    "752181": "Nice",
    "751625": "very nice!!",
    "762456": "",
    "753416": "oo thank you so much , nice write up",
    "753515": "Thanks for sharing！"
  }
}