{
  "id": 5282,
  "title": "Beating The Benchmark In Python (2230k MAE)",
  "url": "/competitions/ams-2014-solar-energy-prediction-contest/discussion/5282",
  "author_name": "",
  "post_date": "2013-08-02T23:50:19.430Z",
  "votes": 22,
  "comment_count": 47,
  "views": 15096,
  "content": "<p>Traditionally this is Foxtrot's job, but they don't seem to be in this competition. It went really well in the Amazon one when a bunch of people did this, so I figured I'd try it here.<br><br>The idea behind this approach is that instead of worrying about interpolating, just let your model figure it out. It uses Ridge Regression from scikit-learn to do that so you can kind of think of it as a form of linear interpolation of all of the GEFS gird data to each station that is learned by the model instead of using some heuristic like distance. Additionally it uses all of the data instead of only the 'usrwf_sfc' data.<br><br>I've built off of this code to get my current model. You can probably squeeze a bit more out of this code by trying different methods of merging the data or trying different subsets of the files to be used but I have a feeling that you can't get much better than 2200k error using a linear model like this on the raw data and need to move to either a non-linear model to do better (polynomial/rbf regression, support vector regression, random forest, GBM, neural net, etc...) or get clever with feature engineering/selection.<br><br>It takes about 15-20 minutes to run on a Core i7 laptop and shouldn't need more than a gig or so of RAM. <br><br>Let me know if you have any questions!</p>",
  "messages": [
    {
      "id": "28098",
      "postDate": "08/02/2013 23:50:19",
      "content": "<p>Traditionally this is Foxtrot's job, but they don't seem to be in this competition. It went really well in the Amazon one when a bunch of people did this, so I figured I'd try it here.<br><br>The idea behind this approach is that instead of worrying about interpolating, just let your model figure it out. It uses Ridge Regression from scikit-learn to do that so you can kind of think of it as a form of linear interpolation of all of the GEFS gird data to each station that is learned by the model instead of using some heuristic like distance. Additionally it uses all of the data instead of only the 'usrwf_sfc' data.<br><br>I've built off of this code to get my current model. You can probably squeeze a bit more out of this code by trying different methods of merging the data or trying different subsets of the files to be used but I have a feeling that you can't get much better than 2200k error using a linear model like this on the raw data and need to move to either a non-linear model to do better (polynomial/rbf regression, support vector regression, random forest, GBM, neural net, etc...) or get clever with feature engineering/selection.<br><br>It takes about 15-20 minutes to run on a Core i7 laptop and shouldn't need more than a gig or so of RAM. <br><br>Let me know if you have any questions!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28128",
      "postDate": "08/03/2013 13:31:04",
      "content": "<p>Thanks for the code!</p>\n<p>One comment, I did not run it yet and only just read it so apologies if I'm off-base, but wouldn't it be better to set a lower limit to your predictions when you run a linear regression with the GEFS data? I would imagine there would be a few predictions that are negative and below 0 doesn't make sense in this context.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28156",
      "postDate": "08/03/2013 21:12:10",
      "content": "<p>Good point, min/max clipping the predictions resulted in another 10K(ish) drop on the CV, but I'm out of submissions so I can't verify it. Really simple to implement, just after the model.predict() line add:<br><br>preds = np.clip(preds,np.min(trainY),np.max(trainY))</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28168",
      "postDate": "08/04/2013 09:22:27",
      "content": "<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28170",
      "postDate": "08/04/2013 09:40:36",
      "content": "<p>I was able to run it as is. Have you installed the netcdf4 package?</p>\n<p>Also, have you checked the files are in the correct location?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28171",
      "postDate": "08/04/2013 09:46:30",
      "content": "<p>Yes I installed netcdf4 package.</p>\n<p>And I put all the files in a folder called &quot;data&quot;...</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28172",
      "postDate": "08/04/2013 10:09:30",
      "content": "<p>I had to revert back to python 2.7 to run it (can't remember why) so I installed netcdf4 for 3.3 and 2.7</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28179",
      "postDate": "08/04/2013 18:05:29",
      "content": "<p>[quote=Adil;28168]</p>\n<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>\n<p>[/quote]<br><br>My&nbsp; guess is somehow the GEFS data you're loading doesn't follow the normal shape of (n,11,5,9,16) do you mind posting what shape X is before that line?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28199",
      "postDate": "08/05/2013 10:02:24",
      "content": "<p>[quote=Alec Radford;28098]</p>\n<p>The idea behind this approach is that instead of worrying about interpolating, just let your model figure it out.</p>\n<p>[/quote]</p>\n<p>Hello!</p>\n<p>Here's what I think is an interesting paper related to this idea:</p>\n<p>http://www.sciencedirect.com/science/article/pii/S1364815211001654</p>\n<p>Cheers, thanks for sharing!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28200",
      "postDate": "08/05/2013 10:10:00",
      "content": "<p>Thanks for paper. I used a Random Forest on Alec's code but I got a worse result than his linear model and it took ages to run. Having to rethink it.</p>\n<p>&nbsp;</p>\n<p>EDIT: Though I'm new to Python so might not have done it correctly!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28212",
      "postDate": "08/05/2013 15:34:51",
      "content": "<p>[quote=Alec Radford;28179]</p>\n<p>[quote=Adil;28168]</p>\n<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>\n<p>[/quote]<br><br>My&nbsp; guess is somehow the GEFS data you're loading doesn't follow the normal shape of (n,11,5,9,16) do you mind posting what shape X is before that line?</p>\n<p>[/quote]</p>\n<p>Thanks Alec.</p>\n<p>I could get the code to run. The problem was in:&nbsp;X = nc.Dataset(path,'r+').variables.values()[-1][:]</p>\n<p>The&nbsp;nc.Dataset(path,'r+').variables.values() is an unordered dictionary. Therefore if you take the last element using [-1], sometimes it takes the wrong element like 'lon'.</p>\n<p>I solved it by defining the write mapping between the file and the target element.</p>\n<p>mapping = {'dswrf_sfc' : 'Downward_Short-Wave_Rad_Flux',<br> 'dlwrf_sfc' : 'Downward_Long-Wave_Rad_Flux',<br> 'uswrf_sfc' : 'Upward_Short-Wave_Rad_Flux',<br> 'ulwrf_sfc' : 'Upward_Long-Wave_Rad_Flux_surface',<br> 'ulwrf_tatm': 'Upward_Long-Wave_Rad_Flux',<br> 'pwat_eatm' : 'Precipitable_water',<br> 'tcdc_eatm' : 'Total_cloud_cover',<br> 'apcp_sfc' : 'Total_precipitation',<br> 'pres_msl': 'Pressure',<br> 'spfh_2m' : 'Specific_humidity_height_above_ground',<br> 'tcolc_eatm' : 'Total_Column-Integrated_Condensate',<br> 'tmax_2m' : 'Maximum_temperature',<br> 'tmin_2m' : 'Minimum_temperature',<br> 'tmp_2m' : 'Temperature_height_above_ground',<br> 'tmp_sfc' : 'Temperature_surface'}</p>\n<p>X = nc.Dataset(path).variables[mapping[data_type]][:]</p>\n<p>&nbsp;</p>\n<p>Thanks again for sharing the code!!</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28440",
      "postDate": "08/08/2013 15:34:46",
      "content": "<p>More of a Python question. I've been trying to run other algorithms&nbsp; using your data transformation. Is there a way to change the shape as a lot of the algorithms complain about it? Newbie to Python, usually use R</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28466",
      "postDate": "08/08/2013 22:40:01",
      "content": "<p><a href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html\">Numpy.reshape</a> will reshape the arrays.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28719",
      "postDate": "08/15/2013 09:17:47",
      "content": "<p>In reply to DomCastro.</p>\n<p>It is expected. Linear models in general run faster than non-linear models like Random Forest. It will be unexpected if Random Forest runs faster than Ridge provided by Alec.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28720",
      "postDate": "08/15/2013 09:20:35",
      "content": "<p>[quote=Alec Radford;28156]</p>\n<p>Good point, min/max clipping the predictions resulted in another 10K(ish) drop on the CV, but I'm out of submissions so I can't verify it. Really simple to implement, just after the model.predict() line add:<br><br>preds = np.clip(preds,np.min(trainY),np.max(trainY))</p>\n<p>[/quote]</p>\n<p>Hi Alec, not sure if you have already tried it and submitted to leadership board? Did it decreased the MAE?</p>\n<p>Intuitively it should too (I will generate a submission later on to try), but it seems to be performing slightly worse than before from the cross validation.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28755",
      "postDate": "08/15/2013 19:22:58",
      "content": "<p>@Alec</p>\n<p>How to save X and the fitted values from this model into standard format? (I'm totally new to python for ML)</p>\n<p>,for X, I've tried to add these lines without success:</p>\n<p>writer = csv.writer(open(&quot;C:/Users/Herimanitra/Downloads/KAGGLE COMPETITION/AMS 2013 2014 Forecasting contest/train/&quot;, 'w'))<br> for row in X :<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.write(row)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28756",
      "postDate": "08/15/2013 19:32:30",
      "content": "<p>ofile&nbsp; = open('testtrans.csv', &quot;wb&quot;)&nbsp;&nbsp;</p>\n<p>&nbsp;writer = csv.writer(ofile, delimiter=',' )&nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;for row in testX:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;writer.writerow(row)&nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;ofile.close()</p>\n<p>&nbsp;</p>\n<p>and do for trainX as well</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "28761",
      "postDate": "08/15/2013 20:17:57",
      "content": "<p>Thanks a lot!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29156",
      "postDate": "08/21/2013 15:30:04",
      "content": "<p>Hi, @Alec</p>\n<p>I am new to Python and I roughly read your code, do you intend to do a ridge regression on Y = XB,</p>\n<p>Y = 5113x98,</p>\n<p>where 98 denotes mesonet locations of total solar energy output</p>\n<p>X = 5113x2160,&nbsp;</p>\n<p>where 2160 = 16*9*15, 15 different features (averaged measures) output at grid 16x9</p>\n<p>B = 2160x98</p>\n<p>regression weights to be used.</p>\n<p>Am I right ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29161",
      "postDate": "08/21/2013 16:40:20",
      "content": "<p>[quote=liubenyuan;29156]</p>\n<p>Hi, @Alec</p>\n<p>I am new to Python and I roughly read your code, do you intend to do a ridge regression on Y = XB, where</p>\n<p>Y = 5113x98,</p>\n<p>where 98 denotes mesonet locations of total solar energy output</p>\n<p>X = 5113x2160,&nbsp;</p>\n<p>where 2160 = 16*9*15, 15 different features output at grid 16x9</p>\n<p>B = 2160x98</p>\n<p>regression weights to be used.</p>\n<p>Am I right ?</p>\n<p>[/quote]</p>\n<p>Since Alec hasn't reply yet, I'll try to post my understanding here.</p>\n<p>I think your understanding is almost correct, with a few clarification worth mentioning : X is a 5113 days of <strong>the mean of summing all the values of the 11 ensembles and the 5 forecasts at each day</strong>&nbsp;at each 16x9 GEFS data points, rather than a single measurement. You may verify this in the code where he uses np.mean(...) to &quot;flatten&quot; the 11*5 values, and print the values out X.shape out.</p>\n<p>I hope this makes sense to you.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29200",
      "postDate": "08/21/2013 22:47:24",
      "content": "<p>Thanks ! I finally make the code run under ipython2 by installing netCDF4 package.</p>\n<p>Each X from a nc file is an averaged prediction on 9x16 grids flatterned each row to form 5113x114, and the 15 files are concatenate together to form the 5113x2160 training matrix.</p>\n<p>So there maybe more to do by extending the regression method and the formation of X :P</p>\n<p>PS: I found this challenge more alike the kaggle stoke exchange one .</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29201",
      "postDate": "08/21/2013 22:52:36",
      "content": "<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29282",
      "postDate": "08/23/2013 05:21:04",
      "content": "<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29288",
      "postDate": "08/23/2013 08:05:25",
      "content": "<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29289",
      "postDate": "08/23/2013 08:13:13",
      "content": "<p>[quote=Rainman;29288]</p>\n<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, I am doing that too !&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29310",
      "postDate": "08/23/2013 16:17:40",
      "content": "<p>[quote=liubenyuan;29289]</p>\n<p>[quote=Rainman;29288]</p>\n<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, I am doing that too !&nbsp;</p>\n<p>[/quote]</p>\n<p>Let's go!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29324",
      "postDate": "08/23/2013 17:12:46",
      "content": "<p>I think thie competition calls **really** creative / competive methods.</p>\n<p>1. I have tried ridge regression, Bayesian regression using Alec method ( 5113x144 submatrix for each file), the results are around 2200k.&nbsp;</p>\n<p>2. I also tried interp the 98 MESONETs from the 144 GEFS grid data and using RF as a regressor, the results are around 2100k.</p>\n<p>3. I googled some reference, that aside from MAE, relative MAE (rMAE) and ME can also be used as the performance metric. However, in the above two method, some rMAE for a given MESONET (i.e., idx = 2) are around 40~60%. while a acceptable rMAE should be around 12~20%, which indicates that the final ranking of MAE should be around 1600k. Well, still a long way to go !</p>\n<p>&nbsp;</p>\n<p>Liu</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29335",
      "postDate": "08/23/2013 19:01:56",
      "content": "<p>Liu,</p>\n<p>When you mention your results, you mean in your CV sets, right?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29340",
      "postDate": "08/23/2013 22:06:35",
      "content": "<p>[quote=BS Man;29335]</p>\n<p>Liu,</p>\n<p>When you mention your results, you mean in your CV sets, right?</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, 10 fold cv test with .8 split</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29447",
      "postDate": "08/25/2013 17:39:21",
      "content": "<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).</p>\n<p>By the way, I was also interpolating but so far has less fruitful results. (mean of the 11 ensembles x 5 forecasts, and mean of either axis, and even no mean). Could you share as to how you are interpolating?</p>\n<p>Thanks.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29459",
      "postDate": "08/26/2013 00:16:41",
      "content": "<p>[quote=Log0;29447]</p>\n<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).</p>\n<p>By the way, I was also interpolating but so far has less fruitful results. (mean of the 11 ensembles x 5 forecasts, and mean of either axis, and even no mean). Could you share as to how you are interpolating?</p>\n<p>Thanks.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>The interpolation is uniform. However, you could append the following features :</p>\n<p>penatration ratio : uswrf_sfc / dswrf_sfc, &nbsp;ulwrf_sfc / dlwrf_sfc</p>\n<p>And then as all the weather forecasts are ON the MESONET locations, you could concatenate 98 mesonet into one y = (5113*98)x1, x = (5113*98)x17, then do the Bayesian regression or RF.</p>\n<p>EDIT: I donnot think Interpolate might be a wise idea to use the weather forecasts ...&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29466",
      "postDate": "08/26/2013 04:08:39",
      "content": "<p>I tried both interpolating and not interpolating. So far, not interpolating has given better results for now - though if you said you are already doing 2.1M I am sure there's room of improvements on interpolating techniques... =]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29629",
      "postDate": "08/28/2013 08:21:31",
      "content": "<p>[quote=liubenyuan;29459]</p>\n<p>The interpolation is uniform. However, you could append the following features :</p>\n<p>penatration ratio : uswrf_sfc / dswrf_sfc, &nbsp;ulwrf_sfc / dlwrf_sfc</p>\n<p>And then as all the weather forecasts are ON the MESONET locations, you could concatenate 98 mesonet into one y = (5113*98)x1, x = (5113*98)x17, then do the Bayesian regression or RF.</p>\n<p>EDIT: I donnot think Interpolate might be a wise idea to use the weather forecasts ...&nbsp;</p>\n<p>[/quote]</p>\n<p>Hello Liu.I preprocessed&nbsp; data almost as you the difference being I didn't include 2 additional features. I used spline interpolation taken from benchmark code. Data transformation takes huge time so I used (500*98)x15 dataframe. It took 4-5 hours to run on 2GB, single core netbook. I got 2293K cv score using linear regression with polynomial features.. I have the following questions:</p>\n<ul>\n<li>How long did it take you to transform the dataframe?</li>\n<li><strong>How much discrepancy you get between your cv and leaderboard scores?</strong></li>\n<li>What is uniform interpolation that you used?</li>\n</ul>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29651",
      "postDate": "08/28/2013 15:53:14",
      "content": "<p>@Davit</p>\n<p>Hi, my CV test is 2106K and my onboard result is 2197k.&nbsp;</p>\n<ul>\n<li>it takes approximate 1hr to generate the interpolated data for 98 MESONETS</li>\n<li>the discrepancy was 90k</li>\n<li>I am using MATLAB interp2 command, the relevant code snipts are</li>\n</ul>\n<p><code> griddata = fdata(:,:,hour,ens,day); % 16lon(y) x 9lat(x)<br> [X,Y] = meshgrid(lat,lon);<br> fdata_new(:,hour,ens,day) = interp2(X,Y,griddata,xi,yi);<br></code></p>\n<p>and the regressor I am using is the matlab fitensemble method, codes are</p>\n<p><code> NLS = 24;<br> tic;<br>% t = RegressionTree.template(...<br>% 'MinParent',5);<br> bag = fitensemble(x,y,'Bag',NLS,'tree','Type','regression');<br> train_time = toc;<br> fprintf('FINISH ensemble training (%4d): CPU hoc=%f\\n',NLS,train_time);<br> yt_hat = bag.predict(xt);</code></p>\n<p>hope it helped.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29689",
      "postDate": "08/29/2013 02:48:26",
      "content": "<p>Hi liubenyuan,</p>\n<p>I am wondering if you can share to me your email - I thought I'd like to write to you a bit. Thanks. Alternatively, you may find my email on my profile, too.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29691",
      "postDate": "08/29/2013 04:28:48",
      "content": "<p>@log0</p>\n<p>The attachment is my implementation using interp method in matlab.</p>\n<p><a href=\"0823_mean_interp_bcs.zip\">0823_mean_interp_bcs.zip</a></p>\n<p>&nbsp;</p>\n<p>PS : I am learning python right now and I think python is a great tool for sci-computing and sharing :)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "29952",
      "postDate": "09/01/2013 19:09:49",
      "content": "<p>Thanks Liubenyuan, I was asking for your email because I'd like to discuss in depth more than just exchanging code. =]</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30337",
      "postDate": "09/06/2013 16:51:56",
      "content": "<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30340",
      "postDate": "09/06/2013 16:56:54",
      "content": "<p>[quote=Herimanitra;30337]</p>\n<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>\n<p>[/quote]</p>\n<p>You mean not using those 'far away' GEFS points right? I suppose you didn't interpolate in this case but used all the GEFS points (3:6, 7:12) as features?</p>\n<p>In that case, I got poor results as well... but I did not dive into it too much, since in my case it is still rather slow for any complex models...</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30346",
      "postDate": "09/06/2013 17:10:55",
      "content": "<p>[quote=Log0;30340]</p>\n<p>[quote=Herimanitra;30337]</p>\n<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>\n<p>[/quote]</p>\n<p>You mean not using those 'far away' GEFS points right? I suppose you didn't interpolate in this case but used all the GEFS points (3:6, 7:12) as features?</p>\n<p>In that case, I got poor results as well... but I did not dive into it too much, since in my case it is still rather slow for any complex models...</p>\n<p>[/quote]</p>\n<p>Yes, not using those 'far away' GEFS points.</p>\n<p>I did not interpolate but I'm looking for a code to do it</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30347",
      "postDate": "09/06/2013 17:13:32",
      "content": "<p>Not sure if you use Python. But Scipy's interpolation library <a href=\"docs.scipy.org/doc/scipy/reference/interpolate.html\">here</a>&nbsp;may help. So far you have not used interpolation at all to predict, but rather using the whole grid (9x16)?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30356",
      "postDate": "09/06/2013 17:36:05",
      "content": "<p>Thanks,</p>\n<p>My implementation is mainly based on Spline interpolation &nbsp;and features that I extracted</p>\n<p>from Alec's code.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30357",
      "postDate": "09/06/2013 17:39:31",
      "content": "<p>[quote=Herimanitra;30356]</p>\n<p>Thanks,</p>\n<p>My implementation is mainly based on Spline interpolation &nbsp;and features that I extracted</p>\n<p>from Alec's code.</p>\n<p>[/quote]</p>\n<p>Thanks for sharing. I'm curious to learn how to improve more, I just checked that Alec's code doesn't have any interpolation at all. You mean StormMiner's Python code?</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30358",
      "postDate": "09/06/2013 17:42:19",
      "content": "<p>Spline interpolation from admin's code</p>\n<p>My question is now how to change solarSplines.py in order to use just GEFS points (3:6, 7:12) ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30361",
      "postDate": "09/06/2013 17:52:29",
      "content": "<p>I don't have this solarSplines.py, but this is a piece of code interpolating via Scipy. See if this helps you get started? =]</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30362",
      "postDate": "09/06/2013 17:57:17",
      "content": "<p>solarSplines.py is the benchmark provided by Admin</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30367",
      "postDate": "09/06/2013 19:10:09",
      "content": "<p>Well, I have a better LB score (closely matching my CV score) right now with a simple linear model (using also the intra-day time series as features, and not averaging/summing them out as in the sample code). Nevertheless, I agree that you cannot get much better leaderboard score than about that with a linear model (maybe a few 10k improvement can be achieved). But who knows...</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30368",
      "postDate": "09/06/2013 19:12:46",
      "content": "<p>I meant to reply to liubenyuan, but it doesn't show</p>\n<p>--&gt;</p>\n<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).<br>By the way, I was also interpolating but so far has less fruitful <br>results. (mean of the 11 ensembles x 5 forecasts, and mean of either <br>axis, and even no mean). Could you share as to how you are <br>interpolating?<br>Thanks.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 28128,
      "author_name": "duffman",
      "author_url": "",
      "post_date": "08/03/2013 13:31:04",
      "content": "<p>Thanks for the code!</p>\n<p>One comment, I did not run it yet and only just read it so apologies if I'm off-base, but wouldn't it be better to set a lower limit to your predictions when you run a linear regression with the GEFS data? I would imagine there would be a few predictions that are negative and below 0 doesn't make sense in this context.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28156,
      "author_name": "alecradford",
      "author_url": "",
      "post_date": "08/03/2013 21:12:10",
      "content": "<p>Good point, min/max clipping the predictions resulted in another 10K(ish) drop on the CV, but I'm out of submissions so I can't verify it. Really simple to implement, just after the model.predict() line add:<br><br>preds = np.clip(preds,np.min(trainY),np.max(trainY))</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28168,
      "author_name": "adilmouja",
      "author_url": "",
      "post_date": "08/04/2013 09:22:27",
      "content": "<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28170,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "08/04/2013 09:40:36",
      "content": "<p>I was able to run it as is. Have you installed the netcdf4 package?</p>\n<p>Also, have you checked the files are in the correct location?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28171,
      "author_name": "adilmouja",
      "author_url": "",
      "post_date": "08/04/2013 09:46:30",
      "content": "<p>Yes I installed netcdf4 package.</p>\n<p>And I put all the files in a folder called &quot;data&quot;...</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28172,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "08/04/2013 10:09:30",
      "content": "<p>I had to revert back to python 2.7 to run it (can't remember why) so I installed netcdf4 for 3.3 and 2.7</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28179,
      "author_name": "alecradford",
      "author_url": "",
      "post_date": "08/04/2013 18:05:29",
      "content": "<p>[quote=Adil;28168]</p>\n<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>\n<p>[/quote]<br><br>My&nbsp; guess is somehow the GEFS data you're loading doesn't follow the normal shape of (n,11,5,9,16) do you mind posting what shape X is before that line?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28199,
      "author_name": "davidefiocco",
      "author_url": "",
      "post_date": "08/05/2013 10:02:24",
      "content": "<p>[quote=Alec Radford;28098]</p>\n<p>The idea behind this approach is that instead of worrying about interpolating, just let your model figure it out.</p>\n<p>[/quote]</p>\n<p>Hello!</p>\n<p>Here's what I think is an interesting paper related to this idea:</p>\n<p>http://www.sciencedirect.com/science/article/pii/S1364815211001654</p>\n<p>Cheers, thanks for sharing!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28200,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "08/05/2013 10:10:00",
      "content": "<p>Thanks for paper. I used a Random Forest on Alec's code but I got a worse result than his linear model and it took ages to run. Having to rethink it.</p>\n<p>&nbsp;</p>\n<p>EDIT: Though I'm new to Python so might not have done it correctly!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28212,
      "author_name": "adilmouja",
      "author_url": "",
      "post_date": "08/05/2013 15:34:51",
      "content": "<p>[quote=Alec Radford;28179]</p>\n<p>[quote=Adil;28168]</p>\n<p>Thank you Alec for sharing the code.</p>\n<p>I receive the following error when I run the code.</p>\n<h3>X = X.reshape(X.shape[0],55,9,16)&nbsp;<br>ValueError: total size of new array must be unchanged</h3>\n<p>It's from the&nbsp;load_GEFS_file function.</p>\n<p>I couldn't figure how to solve this problem. Any direction would be much appreciated.</p>\n<p>Thanks again!!</p>\n<p>[/quote]<br><br>My&nbsp; guess is somehow the GEFS data you're loading doesn't follow the normal shape of (n,11,5,9,16) do you mind posting what shape X is before that line?</p>\n<p>[/quote]</p>\n<p>Thanks Alec.</p>\n<p>I could get the code to run. The problem was in:&nbsp;X = nc.Dataset(path,'r+').variables.values()[-1][:]</p>\n<p>The&nbsp;nc.Dataset(path,'r+').variables.values() is an unordered dictionary. Therefore if you take the last element using [-1], sometimes it takes the wrong element like 'lon'.</p>\n<p>I solved it by defining the write mapping between the file and the target element.</p>\n<p>mapping = {'dswrf_sfc' : 'Downward_Short-Wave_Rad_Flux',<br> 'dlwrf_sfc' : 'Downward_Long-Wave_Rad_Flux',<br> 'uswrf_sfc' : 'Upward_Short-Wave_Rad_Flux',<br> 'ulwrf_sfc' : 'Upward_Long-Wave_Rad_Flux_surface',<br> 'ulwrf_tatm': 'Upward_Long-Wave_Rad_Flux',<br> 'pwat_eatm' : 'Precipitable_water',<br> 'tcdc_eatm' : 'Total_cloud_cover',<br> 'apcp_sfc' : 'Total_precipitation',<br> 'pres_msl': 'Pressure',<br> 'spfh_2m' : 'Specific_humidity_height_above_ground',<br> 'tcolc_eatm' : 'Total_Column-Integrated_Condensate',<br> 'tmax_2m' : 'Maximum_temperature',<br> 'tmin_2m' : 'Minimum_temperature',<br> 'tmp_2m' : 'Temperature_height_above_ground',<br> 'tmp_sfc' : 'Temperature_surface'}</p>\n<p>X = nc.Dataset(path).variables[mapping[data_type]][:]</p>\n<p>&nbsp;</p>\n<p>Thanks again for sharing the code!!</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28440,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "08/08/2013 15:34:46",
      "content": "<p>More of a Python question. I've been trying to run other algorithms&nbsp; using your data transformation. Is there a way to change the shape as a lot of the algorithms complain about it? Newbie to Python, usually use R</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28466,
      "author_name": "djgagne",
      "author_url": "",
      "post_date": "08/08/2013 22:40:01",
      "content": "<p><a href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html\">Numpy.reshape</a> will reshape the arrays.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28719,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/15/2013 09:17:47",
      "content": "<p>In reply to DomCastro.</p>\n<p>It is expected. Linear models in general run faster than non-linear models like Random Forest. It will be unexpected if Random Forest runs faster than Ridge provided by Alec.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28720,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/15/2013 09:20:35",
      "content": "<p>[quote=Alec Radford;28156]</p>\n<p>Good point, min/max clipping the predictions resulted in another 10K(ish) drop on the CV, but I'm out of submissions so I can't verify it. Really simple to implement, just after the model.predict() line add:<br><br>preds = np.clip(preds,np.min(trainY),np.max(trainY))</p>\n<p>[/quote]</p>\n<p>Hi Alec, not sure if you have already tried it and submitted to leadership board? Did it decreased the MAE?</p>\n<p>Intuitively it should too (I will generate a submission later on to try), but it seems to be performing slightly worse than before from the cross validation.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28755,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/15/2013 19:22:58",
      "content": "<p>@Alec</p>\n<p>How to save X and the fitted values from this model into standard format? (I'm totally new to python for ML)</p>\n<p>,for X, I've tried to add these lines without success:</p>\n<p>writer = csv.writer(open(&quot;C:/Users/Herimanitra/Downloads/KAGGLE COMPETITION/AMS 2013 2014 Forecasting contest/train/&quot;, 'w'))<br> for row in X :<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.write(row)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28756,
      "author_name": "domcastro",
      "author_url": "",
      "post_date": "08/15/2013 19:32:30",
      "content": "<p>ofile&nbsp; = open('testtrans.csv', &quot;wb&quot;)&nbsp;&nbsp;</p>\n<p>&nbsp;writer = csv.writer(ofile, delimiter=',' )&nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;for row in testX:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;writer.writerow(row)&nbsp;&nbsp;&nbsp;</p>\n<p>&nbsp;ofile.close()</p>\n<p>&nbsp;</p>\n<p>and do for trainX as well</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 28761,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/15/2013 20:17:57",
      "content": "<p>Thanks a lot!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29156,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/21/2013 15:30:04",
      "content": "<p>Hi, @Alec</p>\n<p>I am new to Python and I roughly read your code, do you intend to do a ridge regression on Y = XB,</p>\n<p>Y = 5113x98,</p>\n<p>where 98 denotes mesonet locations of total solar energy output</p>\n<p>X = 5113x2160,&nbsp;</p>\n<p>where 2160 = 16*9*15, 15 different features (averaged measures) output at grid 16x9</p>\n<p>B = 2160x98</p>\n<p>regression weights to be used.</p>\n<p>Am I right ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29161,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/21/2013 16:40:20",
      "content": "<p>[quote=liubenyuan;29156]</p>\n<p>Hi, @Alec</p>\n<p>I am new to Python and I roughly read your code, do you intend to do a ridge regression on Y = XB, where</p>\n<p>Y = 5113x98,</p>\n<p>where 98 denotes mesonet locations of total solar energy output</p>\n<p>X = 5113x2160,&nbsp;</p>\n<p>where 2160 = 16*9*15, 15 different features output at grid 16x9</p>\n<p>B = 2160x98</p>\n<p>regression weights to be used.</p>\n<p>Am I right ?</p>\n<p>[/quote]</p>\n<p>Since Alec hasn't reply yet, I'll try to post my understanding here.</p>\n<p>I think your understanding is almost correct, with a few clarification worth mentioning : X is a 5113 days of <strong>the mean of summing all the values of the 11 ensembles and the 5 forecasts at each day</strong>&nbsp;at each 16x9 GEFS data points, rather than a single measurement. You may verify this in the code where he uses np.mean(...) to &quot;flatten&quot; the 11*5 values, and print the values out X.shape out.</p>\n<p>I hope this makes sense to you.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29200,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/21/2013 22:47:24",
      "content": "<p>Thanks ! I finally make the code run under ipython2 by installing netCDF4 package.</p>\n<p>Each X from a nc file is an averaged prediction on 9x16 grids flatterned each row to form 5113x114, and the 15 files are concatenate together to form the 5113x2160 training matrix.</p>\n<p>So there maybe more to do by extending the regression method and the formation of X :P</p>\n<p>PS: I found this challenge more alike the kaggle stoke exchange one .</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29201,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/21/2013 22:52:36",
      "content": "<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29282,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/23/2013 05:21:04",
      "content": "<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29288,
      "author_name": "rainman",
      "author_url": "",
      "post_date": "08/23/2013 08:05:25",
      "content": "<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29289,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/23/2013 08:13:13",
      "content": "<p>[quote=Rainman;29288]</p>\n<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, I am doing that too !&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29310,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "08/23/2013 16:17:40",
      "content": "<p>[quote=liubenyuan;29289]</p>\n<p>[quote=Rainman;29288]</p>\n<p>[quote=Herimanitra;29282]</p>\n<p>[quote=liubenyuan;29201]</p>\n<p>BTW, we are only **average** but do not predict the weather change happened in a day, should that improves the results too. And I also think precise interpolation is not needed so long as the GEFS its self has errors.</p>\n<p>[/quote]</p>\n<p>What are you thinking? changing the mean by other statistics ?</p>\n<p>[/quote]</p>\n<p>I think he's suggesting investigating intraday weather changes in a different manner than the mean of all predictions summed together. I'm starting to look at that now too.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, I am doing that too !&nbsp;</p>\n<p>[/quote]</p>\n<p>Let's go!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29324,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/23/2013 17:12:46",
      "content": "<p>I think thie competition calls **really** creative / competive methods.</p>\n<p>1. I have tried ridge regression, Bayesian regression using Alec method ( 5113x144 submatrix for each file), the results are around 2200k.&nbsp;</p>\n<p>2. I also tried interp the 98 MESONETs from the 144 GEFS grid data and using RF as a regressor, the results are around 2100k.</p>\n<p>3. I googled some reference, that aside from MAE, relative MAE (rMAE) and ME can also be used as the performance metric. However, in the above two method, some rMAE for a given MESONET (i.e., idx = 2) are around 40~60%. while a acceptable rMAE should be around 12~20%, which indicates that the final ranking of MAE should be around 1600k. Well, still a long way to go !</p>\n<p>&nbsp;</p>\n<p>Liu</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29335,
      "author_name": "bensolucky",
      "author_url": "",
      "post_date": "08/23/2013 19:01:56",
      "content": "<p>Liu,</p>\n<p>When you mention your results, you mean in your CV sets, right?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29340,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/23/2013 22:06:35",
      "content": "<p>[quote=BS Man;29335]</p>\n<p>Liu,</p>\n<p>When you mention your results, you mean in your CV sets, right?</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>Yes, 10 fold cv test with .8 split</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29447,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/25/2013 17:39:21",
      "content": "<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).</p>\n<p>By the way, I was also interpolating but so far has less fruitful results. (mean of the 11 ensembles x 5 forecasts, and mean of either axis, and even no mean). Could you share as to how you are interpolating?</p>\n<p>Thanks.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29459,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/26/2013 00:16:41",
      "content": "<p>[quote=Log0;29447]</p>\n<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).</p>\n<p>By the way, I was also interpolating but so far has less fruitful results. (mean of the 11 ensembles x 5 forecasts, and mean of either axis, and even no mean). Could you share as to how you are interpolating?</p>\n<p>Thanks.</p>\n<p>[/quote]</p>\n<p>&nbsp;</p>\n<p>The interpolation is uniform. However, you could append the following features :</p>\n<p>penatration ratio : uswrf_sfc / dswrf_sfc, &nbsp;ulwrf_sfc / dlwrf_sfc</p>\n<p>And then as all the weather forecasts are ON the MESONET locations, you could concatenate 98 mesonet into one y = (5113*98)x1, x = (5113*98)x17, then do the Bayesian regression or RF.</p>\n<p>EDIT: I donnot think Interpolate might be a wise idea to use the weather forecasts ...&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29466,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/26/2013 04:08:39",
      "content": "<p>I tried both interpolating and not interpolating. So far, not interpolating has given better results for now - though if you said you are already doing 2.1M I am sure there's room of improvements on interpolating techniques... =]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29629,
      "author_name": "davminer",
      "author_url": "",
      "post_date": "08/28/2013 08:21:31",
      "content": "<p>[quote=liubenyuan;29459]</p>\n<p>The interpolation is uniform. However, you could append the following features :</p>\n<p>penatration ratio : uswrf_sfc / dswrf_sfc, &nbsp;ulwrf_sfc / dlwrf_sfc</p>\n<p>And then as all the weather forecasts are ON the MESONET locations, you could concatenate 98 mesonet into one y = (5113*98)x1, x = (5113*98)x17, then do the Bayesian regression or RF.</p>\n<p>EDIT: I donnot think Interpolate might be a wise idea to use the weather forecasts ...&nbsp;</p>\n<p>[/quote]</p>\n<p>Hello Liu.I preprocessed&nbsp; data almost as you the difference being I didn't include 2 additional features. I used spline interpolation taken from benchmark code. Data transformation takes huge time so I used (500*98)x15 dataframe. It took 4-5 hours to run on 2GB, single core netbook. I got 2293K cv score using linear regression with polynomial features.. I have the following questions:</p>\n<ul>\n<li>How long did it take you to transform the dataframe?</li>\n<li><strong>How much discrepancy you get between your cv and leaderboard scores?</strong></li>\n<li>What is uniform interpolation that you used?</li>\n</ul>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29651,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/28/2013 15:53:14",
      "content": "<p>@Davit</p>\n<p>Hi, my CV test is 2106K and my onboard result is 2197k.&nbsp;</p>\n<ul>\n<li>it takes approximate 1hr to generate the interpolated data for 98 MESONETS</li>\n<li>the discrepancy was 90k</li>\n<li>I am using MATLAB interp2 command, the relevant code snipts are</li>\n</ul>\n<p><code> griddata = fdata(:,:,hour,ens,day); % 16lon(y) x 9lat(x)<br> [X,Y] = meshgrid(lat,lon);<br> fdata_new(:,hour,ens,day) = interp2(X,Y,griddata,xi,yi);<br></code></p>\n<p>and the regressor I am using is the matlab fitensemble method, codes are</p>\n<p><code> NLS = 24;<br> tic;<br>% t = RegressionTree.template(...<br>% 'MinParent',5);<br> bag = fitensemble(x,y,'Bag',NLS,'tree','Type','regression');<br> train_time = toc;<br> fprintf('FINISH ensemble training (%4d): CPU hoc=%f\\n',NLS,train_time);<br> yt_hat = bag.predict(xt);</code></p>\n<p>hope it helped.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29689,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "08/29/2013 02:48:26",
      "content": "<p>Hi liubenyuan,</p>\n<p>I am wondering if you can share to me your email - I thought I'd like to write to you a bit. Thanks. Alternatively, you may find my email on my profile, too.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29691,
      "author_name": "liubenyuan",
      "author_url": "",
      "post_date": "08/29/2013 04:28:48",
      "content": "<p>@log0</p>\n<p>The attachment is my implementation using interp method in matlab.</p>\n<p><a href=\"0823_mean_interp_bcs.zip\">0823_mean_interp_bcs.zip</a></p>\n<p>&nbsp;</p>\n<p>PS : I am learning python right now and I think python is a great tool for sci-computing and sharing :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 29952,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "09/01/2013 19:09:49",
      "content": "<p>Thanks Liubenyuan, I was asking for your email because I'd like to discuss in depth more than just exchanging code. =]</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30337,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "09/06/2013 16:51:56",
      "content": "<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30340,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "09/06/2013 16:56:54",
      "content": "<p>[quote=Herimanitra;30337]</p>\n<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>\n<p>[/quote]</p>\n<p>You mean not using those 'far away' GEFS points right? I suppose you didn't interpolate in this case but used all the GEFS points (3:6, 7:12) as features?</p>\n<p>In that case, I got poor results as well... but I did not dive into it too much, since in my case it is still rather slow for any complex models...</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30346,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "09/06/2013 17:10:55",
      "content": "<p>[quote=Log0;30340]</p>\n<p>[quote=Herimanitra;30337]</p>\n<p>I've tried to use grids (3:6 , 7:12) &nbsp;which surround Mesonets (as depicted in the figure) but it seems to lower my score.</p>\n<p>What about you?</p>\n<p>[/quote]</p>\n<p>You mean not using those 'far away' GEFS points right? I suppose you didn't interpolate in this case but used all the GEFS points (3:6, 7:12) as features?</p>\n<p>In that case, I got poor results as well... but I did not dive into it too much, since in my case it is still rather slow for any complex models...</p>\n<p>[/quote]</p>\n<p>Yes, not using those 'far away' GEFS points.</p>\n<p>I did not interpolate but I'm looking for a code to do it</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30347,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "09/06/2013 17:13:32",
      "content": "<p>Not sure if you use Python. But Scipy's interpolation library <a href=\"docs.scipy.org/doc/scipy/reference/interpolate.html\">here</a>&nbsp;may help. So far you have not used interpolation at all to predict, but rather using the whole grid (9x16)?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30356,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "09/06/2013 17:36:05",
      "content": "<p>Thanks,</p>\n<p>My implementation is mainly based on Spline interpolation &nbsp;and features that I extracted</p>\n<p>from Alec's code.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30357,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "09/06/2013 17:39:31",
      "content": "<p>[quote=Herimanitra;30356]</p>\n<p>Thanks,</p>\n<p>My implementation is mainly based on Spline interpolation &nbsp;and features that I extracted</p>\n<p>from Alec's code.</p>\n<p>[/quote]</p>\n<p>Thanks for sharing. I'm curious to learn how to improve more, I just checked that Alec's code doesn't have any interpolation at all. You mean StormMiner's Python code?</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30358,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "09/06/2013 17:42:19",
      "content": "<p>Spline interpolation from admin's code</p>\n<p>My question is now how to change solarSplines.py in order to use just GEFS points (3:6, 7:12) ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30361,
      "author_name": "ericchio",
      "author_url": "",
      "post_date": "09/06/2013 17:52:29",
      "content": "<p>I don't have this solarSplines.py, but this is a piece of code interpolating via Scipy. See if this helps you get started? =]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30362,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "09/06/2013 17:57:17",
      "content": "<p>solarSplines.py is the benchmark provided by Admin</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30367,
      "author_name": "gdi90215",
      "author_url": "",
      "post_date": "09/06/2013 19:10:09",
      "content": "<p>Well, I have a better LB score (closely matching my CV score) right now with a simple linear model (using also the intra-day time series as features, and not averaging/summing them out as in the sample code). Nevertheless, I agree that you cannot get much better leaderboard score than about that with a linear model (maybe a few 10k improvement can be achieved). But who knows...</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30368,
      "author_name": "gdi90215",
      "author_url": "",
      "post_date": "09/06/2013 19:12:46",
      "content": "<p>I meant to reply to liubenyuan, but it doesn't show</p>\n<p>--&gt;</p>\n<p>I also tried linear models but that's 2.2M seems to be topping the maximum already (w.r.t. to Alec's feature representation).<br>By the way, I was also interpolating but so far has less fruitful <br>results. (mean of the 11 ensembles x 5 forecasts, and mean of either <br>axis, and even no mean). Could you share as to how you are <br>interpolating?<br>Thanks.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "28098": "",
    "28128": "",
    "28156": "",
    "28168": "",
    "28170": "",
    "28171": "",
    "28172": "",
    "28179": "",
    "28199": "",
    "28200": "",
    "28212": "",
    "28440": "",
    "28466": "",
    "28719": "",
    "28720": "",
    "28755": "",
    "28756": "",
    "28761": "",
    "29156": "",
    "29161": "",
    "29200": "",
    "29201": "",
    "29282": "",
    "29288": "",
    "29289": "",
    "29310": "",
    "29324": "",
    "29335": "",
    "29340": "",
    "29447": "",
    "29459": "",
    "29466": "",
    "29629": "",
    "29651": "",
    "29689": "",
    "29691": "",
    "29952": "",
    "30337": "",
    "30340": "",
    "30346": "",
    "30347": "",
    "30356": "",
    "30357": "",
    "30358": "",
    "30361": "",
    "30362": "",
    "30367": "",
    "30368": ""
  },
  "source": "meta"
}