{
  "id": 15533,
  "title": "Data leakage and future data -Will disqualify?",
  "url": "/competitions/grasp-and-lift-eeg-detection/discussion/15533",
  "author_name": "",
  "post_date": "2015-07-25T07:35:30.320Z",
  "votes": null,
  "comment_count": 6,
  "views": 894,
  "content": "<p>As described in instructions, Isn't use of <em>scaler= StandardScaler()</em> for test data <strong>invalid and will disqualifies the modal?</strong> \nSimilarly filtering complete signal at once, is it allowed.  As most of scripts scoring 0.8+ are using it and getting score in leader board</p>\n\n<p>Can admin help to understand this?</p>\n\n<hr>\n\n<p><strong>When predicting, you may not use data from the future!</strong> In other words, if you are predicting labels for id subj1_series9_11, you may not incorporate any frame after 11 of series 9 from subject 1.</p>\n\n<p><strong>You must be careful not to include data leakage.</strong> For example, you may not center the signals for subj1_series9_11 based on the mean of all frames for subj1_series9. Instead, you must use the mean based on frame 0 to 10.</p>\n\n<hr>",
  "messages": [
    {
      "id": "86916",
      "postDate": "07/25/2015 07:35:30",
      "content": "<p>As described in instructions, Isn't use of <em>scaler= StandardScaler()</em> for test data <strong>invalid and will disqualifies the modal?</strong> \nSimilarly filtering complete signal at once, is it allowed.  As most of scripts scoring 0.8+ are using it and getting score in leader board</p>\n\n<p>Can admin help to understand this?</p>\n\n<hr>\n\n<p><strong>When predicting, you may not use data from the future!</strong> In other words, if you are predicting labels for id subj1_series9_11, you may not incorporate any frame after 11 of series 9 from subject 1.</p>\n\n<p><strong>You must be careful not to include data leakage.</strong> For example, you may not center the signals for subj1_series9_11 based on the mean of all frames for subj1_series9. Instead, you must use the mean based on frame 0 to 10.</p>\n\n<hr>",
      "rawMarkdown": "As described in instructions, Isn't use of *scaler= StandardScaler()* for test data **invalid and will disqualifies the modal?** \r\nSimilarly filtering complete signal at once, is it allowed.  As most of scripts scoring 0.8+ are using it and getting score in leader board\r\n\r\nCan admin help to understand this?\r\n___ \r\n**When predicting, you may not use data from the future!** In other words, if you are predicting labels for id subj1_series9_11, you may not incorporate any frame after 11 of series 9 from subject 1.\r\n\r\n**You must be careful not to include data leakage.** For example, you may not center the signals for subj1_series9_11 based on the mean of all frames for subj1_series9. Instead, you must use the mean based on frame 0 to 10.\r\n___",
      "votes": null
    },
    {
      "id": "86951",
      "postDate": "07/25/2015 15:10:37",
      "content": "<p>The way I understand it is your classifier must be CAUSAL when classifying series 9 and 10.</p>\n\n<p>It's ok to train your algorithm on all the training data but when predicting series 9 and 10 you can't use data from time k+1,... to classify the events at time k.</p>\n\n<p>As such you can apply a causal filter (no filtfilt) to your whole signal as long as when using this filtered signal for classification, your predictor for the output at time k only uses the filtered signal from times 1 to k.</p>\n\n<p>So basically your predictor for y(k) = function(x(1),...,x(k))</p>",
      "rawMarkdown": "The way I understand it is your classifier must be CAUSAL when classifying series 9 and 10.\r\n\r\nIt's ok to train your algorithm on all the training data but when predicting series 9 and 10 you can't use data from time k+1,... to classify the events at time k.\r\n\r\nAs such you can apply a causal filter (no filtfilt) to your whole signal as long as when using this filtered signal for classification, your predictor for the output at time k only uses the filtered signal from times 1 to k.\r\n\r\nSo basically your predictor for y(k) = function(x(1),...,x(k))",
      "votes": null
    },
    {
      "id": "86952",
      "postDate": "07/25/2015 15:47:54",
      "content": "<p>yes, filter should be causal and as butterworth filter is used its great, what about <em>scaler= StandardScaler()</em>  this normalize the signal by  mean and variance.</p>",
      "rawMarkdown": "yes, filter should be causal and as butterworth filter is used its great, what about *scaler= StandardScaler()*  this normalize the signal by  mean and variance.",
      "votes": null
    },
    {
      "id": "86967",
      "postDate": "07/25/2015 20:28:38",
      "content": "<p>Scaling the whole dataset by its mean and variance is obviously not OK for series 9 and 10 since the scaled data will be a function of the whole dataset.</p>\n\n<p>That being said, I'd say it's OK to do it for fitting the model on series 1-8 and then using the same scaling values for series 9-10.</p>",
      "rawMarkdown": "Scaling the whole dataset by its mean and variance is obviously not OK for series 9 and 10 since the scaled data will be a function of the whole dataset.\r\n\r\nThat being said, I'd say it's OK to do it for fitting the model on series 1-8 and then using the same scaling values for series 9-10.",
      "votes": null
    },
    {
      "id": "86970",
      "postDate": "07/25/2015 20:50:42",
      "content": "<p>As far as I can see a butterworth filter would also violate the rules, no? While it does not have long tails in the time domain it should still have some leakage into the future, or am I missing something?</p>",
      "rawMarkdown": "As far as I can see a butterworth filter would also violate the rules, no? While it does not have long tails in the time domain it should still have some leakage into the future, or am I missing something?",
      "votes": null
    },
    {
      "id": "86979",
      "postDate": "07/25/2015 23:11:00",
      "content": "<p>It will depend on your language of choice but for instance in matlab whenever you use the filter function, no matter what coefficients you pass it (for a butterworth, chebychev, elliptical, FIR,...) you'll always get a causal filter.</p>\n\n<p>It basically depends how the filter is implemented. If you take a FIR filter b(q^-1) and &quot;correct&quot; the lag by b(q^-1)*q^(N/2), you get a noncausal filter.</p>\n\n<p>If you're in doubt how your software is implementing the filter try computing its inpulse response. You can pass it a kronecker delta u=[0,...,0,1,0,...] and if the filtered response is zero before the index of the 1 your filter is by definition causal. I.e., you should get y=[0,..,0,h(0),h(1),...]</p>",
      "rawMarkdown": "It will depend on your language of choice but for instance in matlab whenever you use the filter function, no matter what coefficients you pass it (for a butterworth, chebychev, elliptical, FIR,...) you'll always get a causal filter.\r\n\r\nIt basically depends how the filter is implemented. If you take a FIR filter b(q^-1) and \"correct\" the lag by b(q^-1)*q^(N/2), you get a noncausal filter.\r\n\r\nIf you're in doubt how your software is implementing the filter try computing its inpulse response. You can pass it a kronecker delta u=[0,...,0,1,0,...] and if the filtered response is zero before the index of the 1 your filter is by definition causal. I.e., you should get y=[0,..,0,h(0),h(1),...]",
      "votes": null
    },
    {
      "id": "88354",
      "postDate": "08/04/2015 12:59:48",
      "content": "<p>If you are using python, using the lfilter from scipy is okay with the competition rules.</p>\n\n<p><a href=\"http://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt\">http://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt</a></p>",
      "rawMarkdown": "If you are using python, using the lfilter from scipy is okay with the competition rules.\r\n\r\nhttp://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 86951,
      "author_name": "ajoo88",
      "author_url": "",
      "post_date": "07/25/2015 15:10:37",
      "content": "<p>The way I understand it is your classifier must be CAUSAL when classifying series 9 and 10.</p>\n\n<p>It's ok to train your algorithm on all the training data but when predicting series 9 and 10 you can't use data from time k+1,... to classify the events at time k.</p>\n\n<p>As such you can apply a causal filter (no filtfilt) to your whole signal as long as when using this filtered signal for classification, your predictor for the output at time k only uses the filtered signal from times 1 to k.</p>\n\n<p>So basically your predictor for y(k) = function(x(1),...,x(k))</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 86952,
      "author_name": "nikeshbajaj",
      "author_url": "",
      "post_date": "07/25/2015 15:47:54",
      "content": "<p>yes, filter should be causal and as butterworth filter is used its great, what about <em>scaler= StandardScaler()</em>  this normalize the signal by  mean and variance.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 86967,
      "author_name": "ajoo88",
      "author_url": "",
      "post_date": "07/25/2015 20:28:38",
      "content": "<p>Scaling the whole dataset by its mean and variance is obviously not OK for series 9 and 10 since the scaled data will be a function of the whole dataset.</p>\n\n<p>That being said, I'd say it's OK to do it for fitting the model on series 1-8 and then using the same scaling values for series 9-10.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 86970,
      "author_name": "hasselmann",
      "author_url": "",
      "post_date": "07/25/2015 20:50:42",
      "content": "<p>As far as I can see a butterworth filter would also violate the rules, no? While it does not have long tails in the time domain it should still have some leakage into the future, or am I missing something?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 86979,
      "author_name": "ajoo88",
      "author_url": "",
      "post_date": "07/25/2015 23:11:00",
      "content": "<p>It will depend on your language of choice but for instance in matlab whenever you use the filter function, no matter what coefficients you pass it (for a butterworth, chebychev, elliptical, FIR,...) you'll always get a causal filter.</p>\n\n<p>It basically depends how the filter is implemented. If you take a FIR filter b(q^-1) and &quot;correct&quot; the lag by b(q^-1)*q^(N/2), you get a noncausal filter.</p>\n\n<p>If you're in doubt how your software is implementing the filter try computing its inpulse response. You can pass it a kronecker delta u=[0,...,0,1,0,...] and if the filtered response is zero before the index of the 1 your filter is by definition causal. I.e., you should get y=[0,..,0,h(0),h(1),...]</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 88354,
      "author_name": "mrbeer",
      "author_url": "",
      "post_date": "08/04/2015 12:59:48",
      "content": "<p>If you are using python, using the lfilter from scipy is okay with the competition rules.</p>\n\n<p><a href=\"http://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt\">http://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "86916": "As described in instructions, Isn't use of *scaler= StandardScaler()* for test data **invalid and will disqualifies the modal?** \r\nSimilarly filtering complete signal at once, is it allowed.  As most of scripts scoring 0.8+ are using it and getting score in leader board\r\n\r\nCan admin help to understand this?\r\n___ \r\n**When predicting, you may not use data from the future!** In other words, if you are predicting labels for id subj1_series9_11, you may not incorporate any frame after 11 of series 9 from subject 1.\r\n\r\n**You must be careful not to include data leakage.** For example, you may not center the signals for subj1_series9_11 based on the mean of all frames for subj1_series9. Instead, you must use the mean based on frame 0 to 10.\r\n___",
    "86951": "The way I understand it is your classifier must be CAUSAL when classifying series 9 and 10.\r\n\r\nIt's ok to train your algorithm on all the training data but when predicting series 9 and 10 you can't use data from time k+1,... to classify the events at time k.\r\n\r\nAs such you can apply a causal filter (no filtfilt) to your whole signal as long as when using this filtered signal for classification, your predictor for the output at time k only uses the filtered signal from times 1 to k.\r\n\r\nSo basically your predictor for y(k) = function(x(1),...,x(k))",
    "86952": "yes, filter should be causal and as butterworth filter is used its great, what about *scaler= StandardScaler()*  this normalize the signal by  mean and variance.",
    "86967": "Scaling the whole dataset by its mean and variance is obviously not OK for series 9 and 10 since the scaled data will be a function of the whole dataset.\r\n\r\nThat being said, I'd say it's OK to do it for fitting the model on series 1-8 and then using the same scaling values for series 9-10.",
    "86970": "As far as I can see a butterworth filter would also violate the rules, no? While it does not have long tails in the time domain it should still have some leakage into the future, or am I missing something?",
    "86979": "It will depend on your language of choice but for instance in matlab whenever you use the filter function, no matter what coefficients you pass it (for a butterworth, chebychev, elliptical, FIR,...) you'll always get a causal filter.\r\n\r\nIt basically depends how the filter is implemented. If you take a FIR filter b(q^-1) and \"correct\" the lag by b(q^-1)*q^(N/2), you get a noncausal filter.\r\n\r\nIf you're in doubt how your software is implementing the filter try computing its inpulse response. You can pass it a kronecker delta u=[0,...,0,1,0,...] and if the filtered response is zero before the index of the 1 your filter is by definition causal. I.e., you should get y=[0,..,0,h(0),h(1),...]",
    "88354": "If you are using python, using the lfilter from scipy is okay with the competition rules.\r\n\r\nhttp://dsp.stackexchange.com/questions/19084/applying-filter-in-scipy-signal-use-lfilter-or-filtfilt"
  },
  "source": "meta"
}