{
  "id": 344659,
  "title": "Approximation of a Jockey’s Position",
  "url": "/competitions/big-data-derby-2022/discussion/344659",
  "author_name": "Lennart Haupts",
  "post_date": "2022-08-16T05:51:09.916000",
  "votes": 7,
  "comment_count": 9,
  "views": 0,
  "content": "<p>I wanted to build a function to keep track of a jockeys position throughout the race. First I needed to get the directions the jockeys moved in. The direction was calculated as the angle between a line from the coordinates at one trakus_id to another one and a horizontal line. The following figures show the directions(left) and change of directions(right) for a sample race. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe00ff5436620a1113bac7e5b2e55e282%2Faqu_race%20(1).png?generation=1660626721895657&amp;alt=media\" alt=\"\"><br>\nMy first idea was to build checkpoints from the available data. I tried to put checkpoints ahead of the jockeys by taking the average direction weighted by their distance travelled. This gave me very wonky checkpoints, so I tried to smooth it out by taking the average of the past directions. The results were slightly better but still unusable. This approach is shown in the next figure.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe831ae7c8dc55da7abf277351cad46ad%2Fself_ass_checkpoints.png?generation=1660626998303044&amp;alt=media\" alt=\"\"><br>\nThere are only a few tracks in the dataset, so instead of taking more time to automate something I could do by hand, I decided to quickly draw in some checkpoints. The following figure shows the result of this approach. I could have drawn in more checkpoints, and I could have been more careful with the placement, but this was more a proof of concept. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2F0211590ff65818aa81c27323a7523d48%2Ftrack_manual.png?generation=1660627334999999&amp;alt=media\" alt=\"\"><br>\nThe position was then caluclated by finding the next checkpoint for each jockey. If there were multiple jockeys moving to the same checkpoint, then they were sorted by their distance to this checkpoint.<br>\nThe next figure shows the positions for a sample race(left) and the rolling mean over 5 trakus_ids(right).<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fd80df5460e2f630a7fedd25ba580d2de%2Fposition0and5.png?generation=1660627454149708&amp;alt=media\" alt=\"\"><br>\nLastly a figure showing the rolling mean over 40 trakus_ids.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Ffdae880aeee41adb07b7090c8f9bde35%2Fposition40.png?generation=1660627502912593&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": 1900575,
      "postDate": "2022-08-16T05:51:09.917Z",
      "content": "<p>I wanted to build a function to keep track of a jockeys position throughout the race. First I needed to get the directions the jockeys moved in. The direction was calculated as the angle between a line from the coordinates at one trakus_id to another one and a horizontal line. The following figures show the directions(left) and change of directions(right) for a sample race. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe00ff5436620a1113bac7e5b2e55e282%2Faqu_race%20(1).png?generation=1660626721895657&amp;alt=media\" alt=\"\"><br>\nMy first idea was to build checkpoints from the available data. I tried to put checkpoints ahead of the jockeys by taking the average direction weighted by their distance travelled. This gave me very wonky checkpoints, so I tried to smooth it out by taking the average of the past directions. The results were slightly better but still unusable. This approach is shown in the next figure.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe831ae7c8dc55da7abf277351cad46ad%2Fself_ass_checkpoints.png?generation=1660626998303044&amp;alt=media\" alt=\"\"><br>\nThere are only a few tracks in the dataset, so instead of taking more time to automate something I could do by hand, I decided to quickly draw in some checkpoints. The following figure shows the result of this approach. I could have drawn in more checkpoints, and I could have been more careful with the placement, but this was more a proof of concept. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2F0211590ff65818aa81c27323a7523d48%2Ftrack_manual.png?generation=1660627334999999&amp;alt=media\" alt=\"\"><br>\nThe position was then caluclated by finding the next checkpoint for each jockey. If there were multiple jockeys moving to the same checkpoint, then they were sorted by their distance to this checkpoint.<br>\nThe next figure shows the positions for a sample race(left) and the rolling mean over 5 trakus_ids(right).<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fd80df5460e2f630a7fedd25ba580d2de%2Fposition0and5.png?generation=1660627454149708&amp;alt=media\" alt=\"\"><br>\nLastly a figure showing the rolling mean over 40 trakus_ids.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Ffdae880aeee41adb07b7090c8f9bde35%2Fposition40.png?generation=1660627502912593&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "I wanted to build a function to keep track of a jockeys position throughout the race. First I needed to get the directions the jockeys moved in. The direction was calculated as the angle between a line from the coordinates at one trakus_id to another one and a horizontal line. The following figures show the directions(left) and change of directions(right) for a sample race. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe00ff5436620a1113bac7e5b2e55e282%2Faqu_race%20(1).png?generation=1660626721895657&alt=media)\nMy first idea was to build checkpoints from the available data. I tried to put checkpoints ahead of the jockeys by taking the average direction weighted by their distance travelled. This gave me very wonky checkpoints, so I tried to smooth it out by taking the average of the past directions. The results were slightly better but still unusable. This approach is shown in the next figure.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe831ae7c8dc55da7abf277351cad46ad%2Fself_ass_checkpoints.png?generation=1660626998303044&alt=media)\nThere are only a few tracks in the dataset, so instead of taking more time to automate something I could do by hand, I decided to quickly draw in some checkpoints. The following figure shows the result of this approach. I could have drawn in more checkpoints, and I could have been more careful with the placement, but this was more a proof of concept. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2F0211590ff65818aa81c27323a7523d48%2Ftrack_manual.png?generation=1660627334999999&alt=media)\nThe position was then caluclated by finding the next checkpoint for each jockey. If there were multiple jockeys moving to the same checkpoint, then they were sorted by their distance to this checkpoint.\nThe next figure shows the positions for a sample race(left) and the rolling mean over 5 trakus_ids(right).\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fd80df5460e2f630a7fedd25ba580d2de%2Fposition0and5.png?generation=1660627454149708&alt=media)\nLastly a figure showing the rolling mean over 40 trakus_ids.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Ffdae880aeee41adb07b7090c8f9bde35%2Fposition40.png?generation=1660627502912593&alt=media)\n",
      "votes": 7
    },
    {
      "id": 1914086,
      "postDate": "2022-08-25T18:02:07.177Z",
      "content": "<p>Классно, интересный у вас подход</p>",
      "rawMarkdown": "Классно, интересный у вас подход",
      "votes": 1
    },
    {
      "id": 1900935,
      "postDate": "2022-08-16T11:13:39.833Z",
      "content": "<p>Good job, thanks.<br>\nBut I didn't know why they didn't provide the finishing place of horses. So, we could compare with the odds of the horses before the race. If we use the lat-long data it will be an approximation because it is sampled every 0.25 seconds and a horse can win a race by milliseconds of difference. </p>",
      "rawMarkdown": "Good job, thanks.\nBut I didn't know why they didn't provide the finishing place of horses. So, we could compare with the odds of the horses before the race. If we use the lat-long data it will be an approximation because it is sampled every 0.25 seconds and a horse can win a race by milliseconds of difference. ",
      "votes": 2,
      "replies": [
        {
          "id": 1901308,
          "postDate": "2022-08-16T15:08:41.500Z",
          "content": "<blockquote>\n  <p>But I didn't know why they didn't provide the finishing place of horses.</p>\n</blockquote>\n<p>I agree, it's basic information which would've made it much easier. I'm currently looking if I can source it from somewhere else. My approach of approximating the position isn’t optimal for getting the final placing. I think the approximated positions throughout the race are interesting when one tries to analyze different strategies.</p>",
          "rawMarkdown": "> But I didn't know why they didn't provide the finishing place of horses.\n\nI agree, it's basic information which would've made it much easier. I'm currently looking if I can source it from somewhere else. My approach of approximating the position isn’t optimal for getting the final placing. I think the approximated positions throughout the race are interesting when one tries to analyze different strategies.",
          "votes": 1
        },
        {
          "id": 1909742,
          "postDate": "2022-08-22T21:56:04.297Z",
          "content": "<p>This notebook should give you a start to figuring out the finishing place of the horses in a race. <a href=\"https://www.kaggle.com/code/mlconsult/determine-who-won-the-races-in-the-data\" target=\"_blank\">https://www.kaggle.com/code/mlconsult/determine-who-won-the-races-in-the-data</a></p>",
          "rawMarkdown": "This notebook should give you a start to figuring out the finishing place of the horses in a race. https://www.kaggle.com/code/mlconsult/determine-who-won-the-races-in-the-data",
          "votes": 2
        },
        {
          "id": 1909862,
          "postDate": "2022-08-23T02:11:16.283Z",
          "content": "<p>Or just use <a href=\"https://www.kaggle.com/datasets/themarkgreen/big-data-derby-2022-global-horse-ids-and-places\" target=\"_blank\">https://www.kaggle.com/datasets/themarkgreen/big-data-derby-2022-global-horse-ids-and-places</a></p>",
          "rawMarkdown": "Or just use https://www.kaggle.com/datasets/themarkgreen/big-data-derby-2022-global-horse-ids-and-places",
          "votes": 4
        }
      ]
    },
    {
      "id": 1912464,
      "postDate": "2022-08-24T18:33:28.520Z",
      "content": "<p>Did you draw the checkpoints with python?</p>",
      "rawMarkdown": "Did you draw the checkpoints with python?",
      "replies": [
        {
          "id": 1913780,
          "postDate": "2022-08-25T14:00:17.937Z",
          "content": "<p>I used Google Earth and QGIS to build the checkpoints.</p>",
          "rawMarkdown": "I used Google Earth and QGIS to build the checkpoints."
        }
      ]
    },
    {
      "id": 1901404,
      "postDate": "2022-08-16T16:16:09.300Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 1901408,
          "postDate": "2022-08-16T16:18:38.640Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1914086,
      "author_name": "Mihail Titov",
      "author_url": "",
      "post_date": "2022-08-25T18:02:07.177000",
      "content": "<p>Классно, интересный у вас подход</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1900935,
      "author_name": "FML",
      "author_url": "",
      "post_date": "2022-08-16T11:13:39.833000",
      "content": "<p>Good job, thanks.<br>\nBut I didn't know why they didn't provide the finishing place of horses. So, we could compare with the odds of the horses before the race. If we use the lat-long data it will be an approximation because it is sampled every 0.25 seconds and a horse can win a race by milliseconds of difference. </p>",
      "votes": 2,
      "replies": [
        {
          "id": 1901308,
          "author_name": "Lennart Haupts",
          "author_url": "",
          "post_date": "2022-08-16T15:08:41.500000",
          "content": "<blockquote>\n  <p>But I didn't know why they didn't provide the finishing place of horses.</p>\n</blockquote>\n<p>I agree, it's basic information which would've made it much easier. I'm currently looking if I can source it from somewhere else. My approach of approximating the position isn’t optimal for getting the final placing. I think the approximated positions throughout the race are interesting when one tries to analyze different strategies.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1909742,
          "author_name": "Ken Miller",
          "author_url": "",
          "post_date": "2022-08-22T21:56:04.297000",
          "content": "<p>This notebook should give you a start to figuring out the finishing place of the horses in a race. <a href=\"https://www.kaggle.com/code/mlconsult/determine-who-won-the-races-in-the-data\" target=\"_blank\">https://www.kaggle.com/code/mlconsult/determine-who-won-the-races-in-the-data</a></p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1909862,
          "author_name": "Mark Green",
          "author_url": "",
          "post_date": "2022-08-23T02:11:16.283000",
          "content": "<p>Or just use <a href=\"https://www.kaggle.com/datasets/themarkgreen/big-data-derby-2022-global-horse-ids-and-places\" target=\"_blank\">https://www.kaggle.com/datasets/themarkgreen/big-data-derby-2022-global-horse-ids-and-places</a></p>",
          "votes": 4,
          "replies": []
        }
      ]
    },
    {
      "id": 1912464,
      "author_name": "Ken Miller",
      "author_url": "",
      "post_date": "2022-08-24T18:33:28.520000",
      "content": "<p>Did you draw the checkpoints with python?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1913780,
          "author_name": "Lennart Haupts",
          "author_url": "",
          "post_date": "2022-08-25T14:00:17.937000",
          "content": "<p>I used Google Earth and QGIS to build the checkpoints.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1901404,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-08-16T16:16:09.300000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 1901408,
          "author_name": "",
          "author_url": "",
          "post_date": "2022-08-16T16:18:38.640000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1900575": "I wanted to build a function to keep track of a jockeys position throughout the race. First I needed to get the directions the jockeys moved in. The direction was calculated as the angle between a line from the coordinates at one trakus_id to another one and a horizontal line. The following figures show the directions(left) and change of directions(right) for a sample race. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe00ff5436620a1113bac7e5b2e55e282%2Faqu_race%20(1).png?generation=1660626721895657&alt=media)\nMy first idea was to build checkpoints from the available data. I tried to put checkpoints ahead of the jockeys by taking the average direction weighted by their distance travelled. This gave me very wonky checkpoints, so I tried to smooth it out by taking the average of the past directions. The results were slightly better but still unusable. This approach is shown in the next figure.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fe831ae7c8dc55da7abf277351cad46ad%2Fself_ass_checkpoints.png?generation=1660626998303044&alt=media)\nThere are only a few tracks in the dataset, so instead of taking more time to automate something I could do by hand, I decided to quickly draw in some checkpoints. The following figure shows the result of this approach. I could have drawn in more checkpoints, and I could have been more careful with the placement, but this was more a proof of concept. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2F0211590ff65818aa81c27323a7523d48%2Ftrack_manual.png?generation=1660627334999999&alt=media)\nThe position was then caluclated by finding the next checkpoint for each jockey. If there were multiple jockeys moving to the same checkpoint, then they were sorted by their distance to this checkpoint.\nThe next figure shows the positions for a sample race(left) and the rolling mean over 5 trakus_ids(right).\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Fd80df5460e2f630a7fedd25ba580d2de%2Fposition0and5.png?generation=1660627454149708&alt=media)\nLastly a figure showing the rolling mean over 40 trakus_ids.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7370712%2Ffdae880aeee41adb07b7090c8f9bde35%2Fposition40.png?generation=1660627502912593&alt=media)\n",
    "1914086": "Классно, интересный у вас подход",
    "1900935": "Good job, thanks.\nBut I didn't know why they didn't provide the finishing place of horses. So, we could compare with the odds of the horses before the race. If we use the lat-long data it will be an approximation because it is sampled every 0.25 seconds and a horse can win a race by milliseconds of difference. ",
    "1912464": "Did you draw the checkpoints with python?",
    "1901404": ""
  }
}