{
  "id": 5114,
  "title": "baselines code ?",
  "url": "/competitions/ams-2014-solar-energy-prediction-contest/discussion/5114",
  "author_name": "",
  "post_date": "2013-07-16T12:39:50.717Z",
  "votes": null,
  "comment_count": 19,
  "views": 5807,
  "content": "<p>Hi there,</p>\r\n<p></p>\r\n<p>Do we have access to the code of the baselines ?</p>\r\n<p></p>\r\n<p>It would be super cool to start with something concrete, even naive rather than from scratch :)</p>\r\n<p></p>\r\n<p>Python would be a must !</p>\r\n<p></p>\r\n<p></p>",
  "messages": [
    {
      "id": "27271",
      "postDate": "07/16/2013 12:39:50",
      "content": "<p>Hi there,</p>\r\n<p></p>\r\n<p>Do we have access to the code of the baselines ?</p>\r\n<p></p>\r\n<p>It would be super cool to start with something concrete, even naive rather than from scratch :)</p>\r\n<p></p>\r\n<p>Python would be a must !</p>\r\n<p></p>\r\n<p></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27459",
      "postDate": "07/19/2013 20:32:06",
      "content": "<p>I have added the code for the Spline Interpolation baseline to my <a href=\"https://github.com/djgagne/solar_energy_prediction_contest\">github page</a>. It is in Python 2.7 and requires numpy and netCDF4-python to work. Feel free to fork the repository and make your own additions to the code if you want. Please make a note of it in your submission description if you use this code in your model.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27465",
      "postDate": "07/20/2013 06:03:13",
      "content": "<p>What about the R implementation?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27515",
      "postDate": "07/22/2013 15:19:23",
      "content": "<p>I do not have an R implementation of that code, but it should be fairly straightforward to translate the Python code to R or to run the Python code and then feed the CSV file output into R. If anyone wants to write an R version of the spline interpolation code and post it to this thread, it would be appreciated.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27643",
      "postDate": "07/25/2013 10:20:25",
      "content": "<p>I just translated your code in R and&nbsp; submit it to test and it works.</p>\n<p>Here it is :&nbsp; <a href=\"https://gist.github.com/dickoa/6078487\">gist</a></p>\n<p>Thanks again for providing this baselines code, it's really helpful.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27648",
      "postDate": "07/25/2013 12:57:44",
      "content": "<p>dickoa beat me to it by a couple hours. But here's my translation to R. My two submissions were broken versions of this, but it should be fixed (tested to be within rounding error of the python script). Also a couple other scripts that make a fairly ugly plot of all the stations on a google maps background.</p>\n<p>&nbsp;</p>\n<p>https://github.com/jlburkhead/solar/tree/master/R</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27681",
      "postDate": "07/26/2013 09:18:43",
      "content": "<p>Thanks dickoa, that's a good starting point! I wrote a parallelized version of this code. You find it here: <a href=\"https://gist.github.com/leobuettiker/6086889\">gist</a></p>\n<p>X</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27682",
      "postDate": "07/26/2013 09:38:17",
      "content": "<p>I also published a <a href=\"https://gist.github.com/leobuettiker/6087562\">gist</a>&nbsp;with another baseline. It does not take any weatherdata in calculation. It simply calculates the mean for each day of the year with the trainingdata and project them for the testset. Of course the reached score is way worse than the one reached with the Spline Interpolation code above, but I published it as it might help to understand the data.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28230",
      "postDate": "08/05/2013 22:21:02",
      "content": "<p>I have a couple of questions on the Spline interpolation baseline code:</p>\n<p>1. The return expression of the Catmull-Rom Spline function appears to be incorrect.&nbsp; From what I can tell, the second term should be +(y[2]-y[0])*xi, rather than +(y[2]-y[1])*xi as posted.&nbsp; Can you clarify?</p>\n<p>2. Why does the call to getDailyMeanSumGrid (from main()) pass date*100 instead of date?</p>\n<p>Also, pertaining to the thread 'understanding data', the first response by Alec Radford appears to have latitudes and longitudes exchanged; there are 9 latitudes and 16 longitudes.</p>\n<p>Thanks!</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28316",
      "postDate": "08/06/2013 20:53:08",
      "content": "<p>I determined the answer to my question 2.&nbsp; The variables intTime and intValidTime as stored as yyyymmddhh, with hh being 00 for the hour.</p>\n<p>&nbsp;</p>\n<p>I am fairly certain about my question 1, that the Catmull-Rom spline expression should use P2 and P0 for the second term and not P2 and P1.</p>\n<p>I will appreciate a response.&nbsp; This helps me know that my understanding in correct or not.</p>\n<p>I can overlook the latitude/longitude mixup, although clarity is always helpful.</p>\n<p>Thanks!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28335",
      "postDate": "08/07/2013 01:17:37",
      "content": "<p>I checked this a couple of days ago and I believe y[2]-y[0])*xi, is the correct formula.</p>\n<p>The score is slightly improved using the correct one.</p>\n<p>score:</p>\n<p>(y[2]-y[1])*xi : 2658583.47</p>\n<p>y[2]-y[0])*xi, : 2610072.35</p>\n<p>Hope this help.</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28385",
      "postDate": "08/07/2013 17:17:57",
      "content": "<p>I got the Catmull-Rom spline formula from the book <a href=\"http://www.springer.com/earth+sciences+and+geography/environmental+science+%26+engineering/book/978-94-007-4074-7\">Automating the Analysis of Spatial Grids</a> Eq. 2.13, which used y[1] in the second term. A quick Google search of other sources did turn up the alternative (correct) formula. I have updated the benchmark on the leaderboard with the fixed formula results.</p>\n<p>And you were correct on your second question about the datetimes.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28496",
      "postDate": "08/09/2013 18:42:14",
      "content": "<p>Out of memory when trying to run getDailyMeanSumGrid() function.</p>\n<p>Any hints?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28626",
      "postDate": "08/13/2013 05:34:19",
      "content": "<p>@dickoa&nbsp;</p>\n<p>&nbsp;Thanks for converting the code in R. It helps a lot. I am trying to understand the data &amp; what is being done in sample code. I see that you load &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot;</p>\n<p>line 65: &nbsp;data &lt;- loadData(file.path(data_path, &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot;)</p>\n<p>Can you please explain where is this &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot; coming from. I am getting an error when I source the code from your gist.</p>\n<p>Thanks in advance.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28665",
      "postDate": "08/14/2013 05:04:53",
      "content": "<p>@tduttaroy</p>\n<p>It is coming from <strong>gefs_test</strong> archive file</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28668",
      "postDate": "08/14/2013 06:30:49",
      "content": "<p>I would be rather grateful to either admin or others willing to explain a detail in python benchmark code posted by admin. Why do we need to scale the return value by GEFS time step in getDailyMeanSumGrid(data,date)?</p>\n<p><code>return data.variables.values()[-1][dateIdx,:,fIdx,:,:].sum(axis=2).mean(axis=1)[0] * <strong><em>3600 * 3?</em></strong></code></p>\n<p>Why do we need to multiply '<em>dswrf_sfc' </em>values with the number of seconds in 3 hours?</p>\n<p>Thanks</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28671",
      "postDate": "08/14/2013 07:53:17",
      "content": "<p>OK, I guess I know why is that so. Correct me if I am wrong, please, but I assume that <em>'dswrf_sfc'</em>&nbsp; values are also measured for&nbsp;3 hour period preceding each forecast hour like maximum and minimum temperature.&nbsp;'dswrf_sfc'&nbsp; values are summed over forecast hours and mean is&nbsp; taken over summed data. To get <strong>J m<sup>-2 </sup></strong> out of <strong>W m<sup>-2</sup></strong><sup>&nbsp;</sup>the result is multiplied with&nbsp;<em>3600 * 3 </em>seconds</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28718",
      "postDate": "08/15/2013 08:13:06",
      "content": "<p>I just need to extract fitted values from this model, how can I do that ? (I'm totally new to python for ML)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28835",
      "postDate": "08/16/2013 20:31:31",
      "content": "<p>@Herimanitra</p>\n<p>The script outputs the predictions to spline_submission.csv, so I would suggest working with that file. As for the memory issue, the Python script only used 50 mb of RAM at at a time, so unless you're running it on a really old computer, it should not be an issue.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28849",
      "postDate": "08/17/2013 05:30:04",
      "content": "<p>I was talking about R. Python works great.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 27459,
      "author_name": "djgagne",
      "author_url": "",
      "post_date": "07/19/2013 20:32:06",
      "content": "<p>I have added the code for the Spline Interpolation baseline to my <a href=\"https://github.com/djgagne/solar_energy_prediction_contest\">github page</a>. It is in Python 2.7 and requires numpy and netCDF4-python to work. Feel free to fork the repository and make your own additions to the code if you want. Please make a note of it in your submission description if you use this code in your model.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27465,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "07/20/2013 06:03:13",
      "content": "<p>What about the R implementation?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27515,
      "author_name": "djgagne",
      "author_url": "",
      "post_date": "07/22/2013 15:19:23",
      "content": "<p>I do not have an R implementation of that code, but it should be fairly straightforward to translate the Python code to R or to run the Python code and then feed the CSV file output into R. If anyone wants to write an R version of the spline interpolation code and post it to this thread, it would be appreciated.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27643,
      "author_name": "dickoa",
      "author_url": "",
      "post_date": "07/25/2013 10:20:25",
      "content": "<p>I just translated your code in R and&nbsp; submit it to test and it works.</p>\n<p>Here it is :&nbsp; <a href=\"https://gist.github.com/dickoa/6078487\">gist</a></p>\n<p>Thanks again for providing this baselines code, it's really helpful.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27648,
      "author_name": "foobarbazquux",
      "author_url": "",
      "post_date": "07/25/2013 12:57:44",
      "content": "<p>dickoa beat me to it by a couple hours. But here's my translation to R. My two submissions were broken versions of this, but it should be fixed (tested to be within rounding error of the python script). Also a couple other scripts that make a fairly ugly plot of all the stations on a google maps background.</p>\n<p>&nbsp;</p>\n<p>https://github.com/jlburkhead/solar/tree/master/R</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27681,
      "author_name": "leobuettiker",
      "author_url": "",
      "post_date": "07/26/2013 09:18:43",
      "content": "<p>Thanks dickoa, that's a good starting point! I wrote a parallelized version of this code. You find it here: <a href=\"https://gist.github.com/leobuettiker/6086889\">gist</a></p>\n<p>X</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27682,
      "author_name": "leobuettiker",
      "author_url": "",
      "post_date": "07/26/2013 09:38:17",
      "content": "<p>I also published a <a href=\"https://gist.github.com/leobuettiker/6087562\">gist</a>&nbsp;with another baseline. It does not take any weatherdata in calculation. It simply calculates the mean for each day of the year with the trainingdata and project them for the testset. Of course the reached score is way worse than the one reached with the Spline Interpolation code above, but I published it as it might help to understand the data.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28230,
      "author_name": "kksurugucchi",
      "author_url": "",
      "post_date": "08/05/2013 22:21:02",
      "content": "<p>I have a couple of questions on the Spline interpolation baseline code:</p>\n<p>1. The return expression of the Catmull-Rom Spline function appears to be incorrect.&nbsp; From what I can tell, the second term should be +(y[2]-y[0])*xi, rather than +(y[2]-y[1])*xi as posted.&nbsp; Can you clarify?</p>\n<p>2. Why does the call to getDailyMeanSumGrid (from main()) pass date*100 instead of date?</p>\n<p>Also, pertaining to the thread 'understanding data', the first response by Alec Radford appears to have latitudes and longitudes exchanged; there are 9 latitudes and 16 longitudes.</p>\n<p>Thanks!</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28316,
      "author_name": "kksurugucchi",
      "author_url": "",
      "post_date": "08/06/2013 20:53:08",
      "content": "<p>I determined the answer to my question 2.&nbsp; The variables intTime and intValidTime as stored as yyyymmddhh, with hh being 00 for the hour.</p>\n<p>&nbsp;</p>\n<p>I am fairly certain about my question 1, that the Catmull-Rom spline expression should use P2 and P0 for the second term and not P2 and P1.</p>\n<p>I will appreciate a response.&nbsp; This helps me know that my understanding in correct or not.</p>\n<p>I can overlook the latitude/longitude mixup, although clarity is always helpful.</p>\n<p>Thanks!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28335,
      "author_name": "kevinhwang",
      "author_url": "",
      "post_date": "08/07/2013 01:17:37",
      "content": "<p>I checked this a couple of days ago and I believe y[2]-y[0])*xi, is the correct formula.</p>\n<p>The score is slightly improved using the correct one.</p>\n<p>score:</p>\n<p>(y[2]-y[1])*xi : 2658583.47</p>\n<p>y[2]-y[0])*xi, : 2610072.35</p>\n<p>Hope this help.</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28385,
      "author_name": "djgagne",
      "author_url": "",
      "post_date": "08/07/2013 17:17:57",
      "content": "<p>I got the Catmull-Rom spline formula from the book <a href=\"http://www.springer.com/earth+sciences+and+geography/environmental+science+%26+engineering/book/978-94-007-4074-7\">Automating the Analysis of Spatial Grids</a> Eq. 2.13, which used y[1] in the second term. A quick Google search of other sources did turn up the alternative (correct) formula. I have updated the benchmark on the leaderboard with the fixed formula results.</p>\n<p>And you were correct on your second question about the datetimes.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28496,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/09/2013 18:42:14",
      "content": "<p>Out of memory when trying to run getDailyMeanSumGrid() function.</p>\n<p>Any hints?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28626,
      "author_name": "",
      "author_url": "",
      "post_date": "08/13/2013 05:34:19",
      "content": "<p>@dickoa&nbsp;</p>\n<p>&nbsp;Thanks for converting the code in R. It helps a lot. I am trying to understand the data &amp; what is being done in sample code. I see that you load &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot;</p>\n<p>line 65: &nbsp;data &lt;- loadData(file.path(data_path, &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot;)</p>\n<p>Can you please explain where is this &quot;dswrf_sfc_latlon_subset_20080101_20121130.nc&quot; coming from. I am getting an error when I source the code from your gist.</p>\n<p>Thanks in advance.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28665,
      "author_name": "davminer",
      "author_url": "",
      "post_date": "08/14/2013 05:04:53",
      "content": "<p>@tduttaroy</p>\n<p>It is coming from <strong>gefs_test</strong> archive file</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28668,
      "author_name": "davminer",
      "author_url": "",
      "post_date": "08/14/2013 06:30:49",
      "content": "<p>I would be rather grateful to either admin or others willing to explain a detail in python benchmark code posted by admin. Why do we need to scale the return value by GEFS time step in getDailyMeanSumGrid(data,date)?</p>\n<p><code>return data.variables.values()[-1][dateIdx,:,fIdx,:,:].sum(axis=2).mean(axis=1)[0] * <strong><em>3600 * 3?</em></strong></code></p>\n<p>Why do we need to multiply '<em>dswrf_sfc' </em>values with the number of seconds in 3 hours?</p>\n<p>Thanks</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28671,
      "author_name": "davminer",
      "author_url": "",
      "post_date": "08/14/2013 07:53:17",
      "content": "<p>OK, I guess I know why is that so. Correct me if I am wrong, please, but I assume that <em>'dswrf_sfc'</em>&nbsp; values are also measured for&nbsp;3 hour period preceding each forecast hour like maximum and minimum temperature.&nbsp;'dswrf_sfc'&nbsp; values are summed over forecast hours and mean is&nbsp; taken over summed data. To get <strong>J m<sup>-2 </sup></strong> out of <strong>W m<sup>-2</sup></strong><sup>&nbsp;</sup>the result is multiplied with&nbsp;<em>3600 * 3 </em>seconds</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28718,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/15/2013 08:13:06",
      "content": "<p>I just need to extract fitted values from this model, how can I do that ? (I'm totally new to python for ML)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28835,
      "author_name": "djgagne",
      "author_url": "",
      "post_date": "08/16/2013 20:31:31",
      "content": "<p>@Herimanitra</p>\n<p>The script outputs the predictions to spline_submission.csv, so I would suggest working with that file. As for the memory issue, the Python script only used 50 mb of RAM at at a time, so unless you're running it on a really old computer, it should not be an issue.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28849,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/17/2013 05:30:04",
      "content": "<p>I was talking about R. Python works great.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "27271": "",
    "27459": "",
    "27465": "",
    "27515": "",
    "27643": "",
    "27648": "",
    "27681": "",
    "27682": "",
    "28230": "",
    "28316": "",
    "28335": "",
    "28385": "",
    "28496": "",
    "28626": "",
    "28665": "",
    "28668": "",
    "28671": "",
    "28718": "",
    "28835": "",
    "28849": ""
  },
  "source": "meta"
}