{
  "id": 289000,
  "title": "Novice questions about iter_test and forecasting horizon",
  "url": "/competitions/g-research-crypto-forecasting/discussion/289000",
  "author_name": "DataPlug",
  "post_date": "2021-11-18T21:41:40.461000",
  "votes": 7,
  "comment_count": 7,
  "views": 0,
  "content": "<p>This is my first Kaggle competition and I had some questions.</p>\n<p>My first question is about the <code>iter_test</code> generator. In the **Detailed API Introduction ** it says:</p>\n<blockquote>\n  <p><strong>iter_test function</strong><br>\n  This is a generator which loops through each timestamp in the test set. You have direct access to &gt; the example test rows for your convenience, but your code will only be able to get rows from the &gt; &gt; real test set via the API. Once you call predict you can continue on to the next batch.</p>\n</blockquote>\n<p>My question is that my model needs to have the last <code>x</code> timestamps (<code>window_size</code>) to make a prediction (say a <code>window_size</code> of 3 hours) but when I ran <code>iter_test</code> and looked at the <code>test_df</code> it only had a 14 rows/records (a single record for every <code>Asset_ID</code> in that specific <code>timestamp</code>). In the real testing of the competition will test_df have a lot more historic data of all <code>Asset_ID</code>'s? (If so, how much?)</p>\n<p>My second question is that it was a bit unclear as to what horizon we will be predicting and in what time frequency. For example, is the model meant to be predicting 15 timestamps into the future with a time frequency of minutes? I was a bit confused by this section in the <strong>Tutorial to the G-Research Crypto Competition</strong> notebook. It says:</p>\n<blockquote>\n  <p>In this competition, Kagglers are challenged to build machine learning models to predict the &gt; returns of 14 popular cryptocurrencies, in the time scale of minutes to hours.</p>\n</blockquote>\n<p>My final question is that I see in the Code-Requirements that you can use pre-trained models. Once I have my pickled model, where do I need to upload it to make sure I can load it into the notebook at compile time? Does it have to be in a certain folder path?</p>\n<p>Some guidance would be appreciated, thank you.</p>",
  "messages": [
    {
      "id": 1587704,
      "postDate": "2021-11-18T21:41:40.460Z",
      "content": "<p>This is my first Kaggle competition and I had some questions.</p>\n<p>My first question is about the <code>iter_test</code> generator. In the **Detailed API Introduction ** it says:</p>\n<blockquote>\n  <p><strong>iter_test function</strong><br>\n  This is a generator which loops through each timestamp in the test set. You have direct access to &gt; the example test rows for your convenience, but your code will only be able to get rows from the &gt; &gt; real test set via the API. Once you call predict you can continue on to the next batch.</p>\n</blockquote>\n<p>My question is that my model needs to have the last <code>x</code> timestamps (<code>window_size</code>) to make a prediction (say a <code>window_size</code> of 3 hours) but when I ran <code>iter_test</code> and looked at the <code>test_df</code> it only had a 14 rows/records (a single record for every <code>Asset_ID</code> in that specific <code>timestamp</code>). In the real testing of the competition will test_df have a lot more historic data of all <code>Asset_ID</code>'s? (If so, how much?)</p>\n<p>My second question is that it was a bit unclear as to what horizon we will be predicting and in what time frequency. For example, is the model meant to be predicting 15 timestamps into the future with a time frequency of minutes? I was a bit confused by this section in the <strong>Tutorial to the G-Research Crypto Competition</strong> notebook. It says:</p>\n<blockquote>\n  <p>In this competition, Kagglers are challenged to build machine learning models to predict the &gt; returns of 14 popular cryptocurrencies, in the time scale of minutes to hours.</p>\n</blockquote>\n<p>My final question is that I see in the Code-Requirements that you can use pre-trained models. Once I have my pickled model, where do I need to upload it to make sure I can load it into the notebook at compile time? Does it have to be in a certain folder path?</p>\n<p>Some guidance would be appreciated, thank you.</p>",
      "rawMarkdown": "This is my first Kaggle competition and I had some questions.\n\nMy first question is about the `iter_test` generator. In the **Detailed API Introduction ** it says:\n\n> **iter_test function**\n> This is a generator which loops through each timestamp in the test set. You have direct access to > the example test rows for your convenience, but your code will only be able to get rows from the > > real test set via the API. Once you call predict you can continue on to the next batch.\n\nMy question is that my model needs to have the last `x` timestamps (`window_size`) to make a prediction (say a `window_size` of 3 hours) but when I ran `iter_test` and looked at the `test_df` it only had a 14 rows/records (a single record for every `Asset_ID` in that specific `timestamp`). In the real testing of the competition will test_df have a lot more historic data of all `Asset_ID`'s? (If so, how much?)\n\nMy second question is that it was a bit unclear as to what horizon we will be predicting and in what time frequency. For example, is the model meant to be predicting 15 timestamps into the future with a time frequency of minutes? I was a bit confused by this section in the **Tutorial to the G-Research Crypto Competition** notebook. It says:\n\n> In this competition, Kagglers are challenged to build machine learning models to predict the > returns of 14 popular cryptocurrencies, in the time scale of minutes to hours.\n\nMy final question is that I see in the Code-Requirements that you can use pre-trained models. Once I have my pickled model, where do I need to upload it to make sure I can load it into the notebook at compile time? Does it have to be in a certain folder path?\n\n\nSome guidance would be appreciated, thank you.",
      "votes": 7
    },
    {
      "id": 1587744,
      "postDate": "2021-11-18T23:05:55.577Z",
      "content": "<p>Some brief hints:</p>\n<ol>\n<li>Keep track of historical data yourself (circular buffers are good for this; if you’re using Python, <code>collections.deque</code> could be your friend).</li>\n<li>Looking at the notebook, it’s the next fifteen minutes starting at the minute after your latest observation (eg., you buy an asset the next minute—t+1— and sell it 15 minutes later, at t+15+1=t+16). Check the notebook for the exact formula. (Actually calculating the target has some pitfalls; check the discussions if you’re interested.)</li>\n<li>Create a dataset for your saved model and attach it to your notebook. (If you update the dataset with a freshly trained model, your notebook will automatically use the updated dataset the next time you submit.)</li>\n</ol>",
      "rawMarkdown": "Some brief hints:\n\n1. Keep track of historical data yourself (circular buffers are good for this; if you’re using Python, `collections.deque` could be your friend).\n2. Looking at the notebook, it’s the next fifteen minutes starting at the minute after your latest observation (eg., you buy an asset the next minute—t+1— and sell it 15 minutes later, at t+15+1=t+16). Check the notebook for the exact formula. (Actually calculating the target has some pitfalls; check the discussions if you’re interested.)\n3. Create a dataset for your saved model and attach it to your notebook. (If you update the dataset with a freshly trained model, your notebook will automatically use the updated dataset the next time you submit.)",
      "votes": 3,
      "replies": [
        {
          "id": 1587886,
          "postDate": "2021-11-19T03:26:23.717Z",
          "content": "<p>Thanks for replying <a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> you cleared up my second question. Unfortunately for question 1 and 3 I'm still unsure. </p>\n<p>For Q3 I would like to know how I can store my trained model inside the Kaggle notebook for the competition so that I only need to load it and make predictions (not using the code to first train the model, then make predictions)</p>\n<p>For Q1 I would like to understand how much historic data will be available in the <code>iter_test</code> for my model to make use of. As stated in my question, per each <code>iter_test</code> iteration I only saw <code>test_df</code> (which is meant to be the test data when the competition ends and starts making inferences on) having a single timestamp and wanting a prediction from me.</p>\n<p>Im sorry if my questions are unclear–maybe I'm misunderstood.</p>\n<p>Thank you for your time!</p>",
          "rawMarkdown": "Thanks for replying @christoffer you cleared up my second question. Unfortunately for question 1 and 3 I'm still unsure. \n\nFor Q3 I would like to know how I can store my trained model inside the Kaggle notebook for the competition so that I only need to load it and make predictions (not using the code to first train the model, then make predictions)\n\nFor Q1 I would like to understand how much historic data will be available in the `iter_test` for my model to make use of. As stated in my question, per each `iter_test` iteration I only saw `test_df` (which is meant to be the test data when the competition ends and starts making inferences on) having a single timestamp and wanting a prediction from me.\n\nIm sorry if my questions are unclear–maybe I'm misunderstood.\n\nThank you for your time!",
          "votes": 2
        },
        {
          "id": 1588388,
          "postDate": "2021-11-19T11:24:32.733Z",
          "content": "<p>About your model: After you’ve trained your model and saved it, upload it to Kaggle as a dataset. For your submission, create a notebook for inference and and attach the dataset to it. You can then load the trained model from the dataset and use it for making predictions.</p>\n<p>About the test data: IIRC (I’m on the road so not easy for me to check), you get data one minute at a time. But I’ve seen it said that there won’t be any gaps (except for some missing data) between training data, supplemental data, and finally, the test data so it should be fairly easy to keep track of historical data. (If you need N minutes of data, keep track of the last N minutes of data and update it as you make predictions; if you need target values, you can replace them with your predictions for the new test data, for example).</p>",
          "rawMarkdown": "About your model: After you’ve trained your model and saved it, upload it to Kaggle as a dataset. For your submission, create a notebook for inference and and attach the dataset to it. You can then load the trained model from the dataset and use it for making predictions.\n\nAbout the test data: IIRC (I’m on the road so not easy for me to check), you get data one minute at a time. But I’ve seen it said that there won’t be any gaps (except for some missing data) between training data, supplemental data, and finally, the test data so it should be fairly easy to keep track of historical data. (If you need N minutes of data, keep track of the last N minutes of data and update it as you make predictions; if you need target values, you can replace them with your predictions for the new test data, for example).",
          "votes": 2
        },
        {
          "id": 1588605,
          "postDate": "2021-11-19T13:50:21.357Z",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> for the answers! Maybe, it would be a good idea to share an example code, how to do this? I will give my best and hopefully provide one at a later time:)</p>",
          "rawMarkdown": "Thank you @christoffer for the answers! Maybe, it would be a good idea to share an example code, how to do this? I will give my best and hopefully provide one at a later time:)",
          "votes": 1
        },
        {
          "id": 1588803,
          "postDate": "2021-11-19T16:43:21.683Z",
          "content": "<p><a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> Ahh I see–Thank you getting back to me and safe travels.</p>",
          "rawMarkdown": "@christoffer Ahh I see–Thank you getting back to me and safe travels.",
          "votes": 1
        }
      ]
    },
    {
      "id": 1590063,
      "postDate": "2021-11-20T21:31:13.190Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 1588604,
      "postDate": "2021-11-19T13:49:25.130Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1587744,
      "author_name": "Christoffer Karlsson",
      "author_url": "",
      "post_date": "2021-11-18T23:05:55.577000",
      "content": "<p>Some brief hints:</p>\n<ol>\n<li>Keep track of historical data yourself (circular buffers are good for this; if you’re using Python, <code>collections.deque</code> could be your friend).</li>\n<li>Looking at the notebook, it’s the next fifteen minutes starting at the minute after your latest observation (eg., you buy an asset the next minute—t+1— and sell it 15 minutes later, at t+15+1=t+16). Check the notebook for the exact formula. (Actually calculating the target has some pitfalls; check the discussions if you’re interested.)</li>\n<li>Create a dataset for your saved model and attach it to your notebook. (If you update the dataset with a freshly trained model, your notebook will automatically use the updated dataset the next time you submit.)</li>\n</ol>",
      "votes": 3,
      "replies": [
        {
          "id": 1587886,
          "author_name": "DataPlug",
          "author_url": "",
          "post_date": "2021-11-19T03:26:23.717000",
          "content": "<p>Thanks for replying <a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> you cleared up my second question. Unfortunately for question 1 and 3 I'm still unsure. </p>\n<p>For Q3 I would like to know how I can store my trained model inside the Kaggle notebook for the competition so that I only need to load it and make predictions (not using the code to first train the model, then make predictions)</p>\n<p>For Q1 I would like to understand how much historic data will be available in the <code>iter_test</code> for my model to make use of. As stated in my question, per each <code>iter_test</code> iteration I only saw <code>test_df</code> (which is meant to be the test data when the competition ends and starts making inferences on) having a single timestamp and wanting a prediction from me.</p>\n<p>Im sorry if my questions are unclear–maybe I'm misunderstood.</p>\n<p>Thank you for your time!</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1588388,
          "author_name": "Christoffer Karlsson",
          "author_url": "",
          "post_date": "2021-11-19T11:24:32.733000",
          "content": "<p>About your model: After you’ve trained your model and saved it, upload it to Kaggle as a dataset. For your submission, create a notebook for inference and and attach the dataset to it. You can then load the trained model from the dataset and use it for making predictions.</p>\n<p>About the test data: IIRC (I’m on the road so not easy for me to check), you get data one minute at a time. But I’ve seen it said that there won’t be any gaps (except for some missing data) between training data, supplemental data, and finally, the test data so it should be fairly easy to keep track of historical data. (If you need N minutes of data, keep track of the last N minutes of data and update it as you make predictions; if you need target values, you can replace them with your predictions for the new test data, for example).</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1588605,
          "author_name": "Ralf",
          "author_url": "",
          "post_date": "2021-11-19T13:50:21.357000",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> for the answers! Maybe, it would be a good idea to share an example code, how to do this? I will give my best and hopefully provide one at a later time:)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1588803,
          "author_name": "DataPlug",
          "author_url": "",
          "post_date": "2021-11-19T16:43:21.683000",
          "content": "<p><a href=\"https://www.kaggle.com/christoffer\" target=\"_blank\">@christoffer</a> Ahh I see–Thank you getting back to me and safe travels.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1590063,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-11-20T21:31:13.190000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1588604,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-11-19T13:49:25.130000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1587704": "This is my first Kaggle competition and I had some questions.\n\nMy first question is about the `iter_test` generator. In the **Detailed API Introduction ** it says:\n\n> **iter_test function**\n> This is a generator which loops through each timestamp in the test set. You have direct access to > the example test rows for your convenience, but your code will only be able to get rows from the > > real test set via the API. Once you call predict you can continue on to the next batch.\n\nMy question is that my model needs to have the last `x` timestamps (`window_size`) to make a prediction (say a `window_size` of 3 hours) but when I ran `iter_test` and looked at the `test_df` it only had a 14 rows/records (a single record for every `Asset_ID` in that specific `timestamp`). In the real testing of the competition will test_df have a lot more historic data of all `Asset_ID`'s? (If so, how much?)\n\nMy second question is that it was a bit unclear as to what horizon we will be predicting and in what time frequency. For example, is the model meant to be predicting 15 timestamps into the future with a time frequency of minutes? I was a bit confused by this section in the **Tutorial to the G-Research Crypto Competition** notebook. It says:\n\n> In this competition, Kagglers are challenged to build machine learning models to predict the > returns of 14 popular cryptocurrencies, in the time scale of minutes to hours.\n\nMy final question is that I see in the Code-Requirements that you can use pre-trained models. Once I have my pickled model, where do I need to upload it to make sure I can load it into the notebook at compile time? Does it have to be in a certain folder path?\n\n\nSome guidance would be appreciated, thank you.",
    "1587744": "Some brief hints:\n\n1. Keep track of historical data yourself (circular buffers are good for this; if you’re using Python, `collections.deque` could be your friend).\n2. Looking at the notebook, it’s the next fifteen minutes starting at the minute after your latest observation (eg., you buy an asset the next minute—t+1— and sell it 15 minutes later, at t+15+1=t+16). Check the notebook for the exact formula. (Actually calculating the target has some pitfalls; check the discussions if you’re interested.)\n3. Create a dataset for your saved model and attach it to your notebook. (If you update the dataset with a freshly trained model, your notebook will automatically use the updated dataset the next time you submit.)",
    "1590063": "",
    "1588604": ""
  }
}