{
  "id": 386204,
  "title": "Metric Explanation: Mean Angular Error",
  "url": "/competitions/icecube-neutrinos-in-deep-ice/discussion/386204",
  "author_name": "",
  "post_date": "2023-02-11T18:57:32.734471800Z",
  "votes": 7,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Mean Angular Error or Angular distance is a measure of the difference in direction between two points on a sphere, such as a planet or star (if we really belive it's spherical). It is defined as the angle between two lines connecting the center of the sphere to the two points. Angular distance is used in a variety of applications, including astronomy, navigation, and geographic information systems (GIS).</p>\n<p>In astronomical applications, angular distance is used to measure the separation between celestial objects, such as stars, galaxies, and quasars. And that's what we do: tryiong to find out where does neutrion comes from!</p>\n<p>Angular distance is typically measured in units of degrees, radians, or arcseconds. It is an important concept in spherical geometry and is used in a variety of mathematical and computational models in these fields. </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F173638da9d87d803e2b936cd4521f9e0%2F3D_Spherical.png?generation=1676140789343966&amp;alt=media\" alt=\"\"></p>\n<p>Where <br>\nφ  is called azimuth <br>\n𝜃 and is called zenith</p>\n<p>The original formula of the metric is the following:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F95d5f7bd959113ea714e7a2dfaeaba0d%2Fshort.png?generation=1676233721324185&amp;alt=media\" alt=\"\"></p>\n<p>But <a href=\"https://www.kaggle.com/code/sohier/mean-angular-error\" target=\"_blank\">host uses</a> another form:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F079fdab610efb2ee3170482aac134efb%2Flong.png?generation=1676233738659438&amp;alt=media\" alt=\"\"></p>\n<p>As far as I see, it helps numeric stability as far as we have limited <strong>reception angle</strong>.</p>",
  "messages": [
    {
      "id": "2140451",
      "postDate": "02/11/2023 18:57:32",
      "content": "<p>Mean Angular Error or Angular distance is a measure of the difference in direction between two points on a sphere, such as a planet or star (if we really belive it's spherical). It is defined as the angle between two lines connecting the center of the sphere to the two points. Angular distance is used in a variety of applications, including astronomy, navigation, and geographic information systems (GIS).</p>\n<p>In astronomical applications, angular distance is used to measure the separation between celestial objects, such as stars, galaxies, and quasars. And that's what we do: tryiong to find out where does neutrion comes from!</p>\n<p>Angular distance is typically measured in units of degrees, radians, or arcseconds. It is an important concept in spherical geometry and is used in a variety of mathematical and computational models in these fields. </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F173638da9d87d803e2b936cd4521f9e0%2F3D_Spherical.png?generation=1676140789343966&amp;alt=media\" alt=\"\"></p>\n<p>Where <br>\nφ  is called azimuth <br>\n𝜃 and is called zenith</p>\n<p>The original formula of the metric is the following:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F95d5f7bd959113ea714e7a2dfaeaba0d%2Fshort.png?generation=1676233721324185&amp;alt=media\" alt=\"\"></p>\n<p>But <a href=\"https://www.kaggle.com/code/sohier/mean-angular-error\" target=\"_blank\">host uses</a> another form:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F079fdab610efb2ee3170482aac134efb%2Flong.png?generation=1676233738659438&amp;alt=media\" alt=\"\"></p>\n<p>As far as I see, it helps numeric stability as far as we have limited <strong>reception angle</strong>.</p>",
      "rawMarkdown": "Mean Angular Error or Angular distance is a measure of the difference in direction between two points on a sphere, such as a planet or star (if we really belive it's spherical). It is defined as the angle between two lines connecting the center of the sphere to the two points. Angular distance is used in a variety of applications, including astronomy, navigation, and geographic information systems (GIS).\n\nIn astronomical applications, angular distance is used to measure the separation between celestial objects, such as stars, galaxies, and quasars. And that's what we do: tryiong to find out where does neutrion comes from!\n\nAngular distance is typically measured in units of degrees, radians, or arcseconds. It is an important concept in spherical geometry and is used in a variety of mathematical and computational models in these fields. \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F173638da9d87d803e2b936cd4521f9e0%2F3D_Spherical.png?generation=1676140789343966&alt=media)\n\nWhere \nφ  is called azimuth \n𝜃 and is called zenith\n\n\nThe original formula of the metric is the following:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F95d5f7bd959113ea714e7a2dfaeaba0d%2Fshort.png?generation=1676233721324185&alt=media)\n\nBut [host uses](https://www.kaggle.com/code/sohier/mean-angular-error) another form:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F079fdab610efb2ee3170482aac134efb%2Flong.png?generation=1676233738659438&alt=media)\n\nAs far as I see, it helps numeric stability as far as we have limited **reception angle**.",
      "votes": null
    },
    {
      "id": "2140920",
      "postDate": "02/12/2023 09:31:15",
      "content": "<p>The metric that organizers use is based on the following idea. A unit vector in a spherical coordinate system has the following components:<br>\n$$<br>\n\\mathbf{n} = (n_x,\\, n_y, \\,n_z)=(\\sin\\theta\\cos\\phi,~\\sin\\theta\\sin\\phi,~\\cos\\theta) .<br>\n$$<br>\nThe angles in the picture <strong>do not match</strong> the angles in your formulas. According to the picture, the zenith angle is theta, since I wrote it.</p>\n<p>The cosine of the angle between two unit vectors is equal to their dot product:<br>\n$$<br>\n\\cos(\\text{score}) = \\mathbf{n} \\hat{\\mathbf{n} } = n_x\\hat{n}_x + n_y\\hat{n}_y + n_z\\hat{n}_z = \\sin\\theta\\,\\sin\\hat{\\theta}\\, (\\cos\\phi \\,\\cos\\hat{\\phi} +\\sin\\phi\\,\\sin\\hat{\\phi} )+ \\cos\\theta \\cos\\hat{\\theta}.<br>\n$$<br>\nYou can simplify this expression with the cosine identity of the angle difference. In principle, this will slightly speed up the calculations, but it is unlikely to increase their stability.</p>\n<p>I note that in models you <strong>should not work in terms of angles</strong>. The model must predict the three components of the unit vector. It is clear that:<br>\n$$<br>\n\\theta+\\pi \\equiv \\theta,\\,\\,\\,\\,\\,\\,\\phi+2\\pi \\equiv \\phi<br>\n$$ <br>\nNot every model will like it.  :)  </p>",
      "rawMarkdown": "The metric that organizers use is based on the following idea. A unit vector in a spherical coordinate system has the following components:\n$$\n\\mathbf{n} = (n_x,\\, n_y, \\,n_z)=(\\sin\\theta\\cos\\phi,~\\sin\\theta\\sin\\phi,~\\cos\\theta) .\n$$\nThe angles in the picture **do not match** the angles in your formulas. According to the picture, the zenith angle is theta, since I wrote it.\n\nThe cosine of the angle between two unit vectors is equal to their dot product:\n$$\n\\cos(\\text{score}) = \\mathbf{n} \\hat{\\mathbf{n} } = n_x\\hat{n}_x + n_y\\hat{n}_y + n_z\\hat{n}_z = \\sin\\theta\\,\\sin\\hat{\\theta}\\, (\\cos\\phi \\,\\cos\\hat{\\phi} +\\sin\\phi\\,\\sin\\hat{\\phi} )+ \\cos\\theta \\cos\\hat{\\theta}.\n$$\nYou can simplify this expression with the cosine identity of the angle difference. In principle, this will slightly speed up the calculations, but it is unlikely to increase their stability.\n\nI note that in models you **should not work in terms of angles**. The model must predict the three components of the unit vector. It is clear that:\n$$\n\\theta+\\pi \\equiv \\theta,\\,\\,\\,\\,\\,\\,\\phi+2\\pi \\equiv \\phi\n$$ \nNot every model will like it.  :)",
      "votes": null
    },
    {
      "id": "2141574",
      "postDate": "02/12/2023 21:33:21",
      "content": "<p>Thank you for your message!<br>\nIt helped me fix the issue and better understand the metric.<br>\nI've done some experiments on the stability of metric and it doesn't really seem to make sense. After futher analysis I found out it has fading error. <br>\nSo the longer form is still a mystery to me. This transformation looks so obvious to me.</p>\n<p>You say we should not work in terms of angles in models. <br>\nI have an ituition that special form of output can be used to match such a thing. <br>\nWouldn't <code>sin(logits)</code> work for example? If not, why?</p>",
      "rawMarkdown": "Thank you for your message!\nIt helped me fix the issue and better understand the metric.\nI've done some experiments on the stability of metric and it doesn't really seem to make sense. After futher analysis I found out it has fading error. \nSo the longer form is still a mystery to me. This transformation looks so obvious to me.\n\nYou say we should not work in terms of angles in models. \nI have an ituition that special form of output can be used to match such a thing. \nWouldn't `sin(logits) ` work for example? If not, why?",
      "votes": null
    },
    {
      "id": "2142345",
      "postDate": "02/13/2023 13:15:18",
      "content": "<p>It's amazing how this metric is widely used in various fields such as astronomy, navigation, and GIS. </p>\n<p>A question I have, how does this metric compare to other metrics in terms of its usefulness and accuracy in measuring the difference in direction between two points?</p>",
      "rawMarkdown": "It's amazing how this metric is widely used in various fields such as astronomy, navigation, and GIS. \n\nA question I have, how does this metric compare to other metrics in terms of its usefulness and accuracy in measuring the difference in direction between two points?",
      "votes": null
    },
    {
      "id": "2161486",
      "postDate": "02/27/2023 14:42:52",
      "content": "<p>Nice explanation, thanks! </p>",
      "rawMarkdown": "Nice explanation, thanks!",
      "votes": null
    },
    {
      "id": "2163039",
      "postDate": "02/28/2023 14:49:21",
      "content": "<p>I didn't have notifications set up and I just now saw your question.</p>\n<p>We use the final model layer with three outputs - direction components. You can, of course, take a sine from them. This at least regularizes the length of the vector. But I have not experimented with this option.</p>\n<p>More important is not the output, but what loss is then minimized.<br>\nI'll try to post a little later about the various choices of loss.</p>\n<p>Good luck!</p>",
      "rawMarkdown": "I didn't have notifications set up and I just now saw your question.\n\nWe use the final model layer with three outputs - direction components. You can, of course, take a sine from them. This at least regularizes the length of the vector. But I have not experimented with this option.\n\nMore important is not the output, but what loss is then minimized.\nI'll try to post a little later about the various choices of loss.\n\nGood luck!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2140920,
      "author_name": "synset",
      "author_url": "",
      "post_date": "02/12/2023 09:31:15",
      "content": "<p>The metric that organizers use is based on the following idea. A unit vector in a spherical coordinate system has the following components:<br>\n$$<br>\n\\mathbf{n} = (n_x,\\, n_y, \\,n_z)=(\\sin\\theta\\cos\\phi,~\\sin\\theta\\sin\\phi,~\\cos\\theta) .<br>\n$$<br>\nThe angles in the picture <strong>do not match</strong> the angles in your formulas. According to the picture, the zenith angle is theta, since I wrote it.</p>\n<p>The cosine of the angle between two unit vectors is equal to their dot product:<br>\n$$<br>\n\\cos(\\text{score}) = \\mathbf{n} \\hat{\\mathbf{n} } = n_x\\hat{n}_x + n_y\\hat{n}_y + n_z\\hat{n}_z = \\sin\\theta\\,\\sin\\hat{\\theta}\\, (\\cos\\phi \\,\\cos\\hat{\\phi} +\\sin\\phi\\,\\sin\\hat{\\phi} )+ \\cos\\theta \\cos\\hat{\\theta}.<br>\n$$<br>\nYou can simplify this expression with the cosine identity of the angle difference. In principle, this will slightly speed up the calculations, but it is unlikely to increase their stability.</p>\n<p>I note that in models you <strong>should not work in terms of angles</strong>. The model must predict the three components of the unit vector. It is clear that:<br>\n$$<br>\n\\theta+\\pi \\equiv \\theta,\\,\\,\\,\\,\\,\\,\\phi+2\\pi \\equiv \\phi<br>\n$$ <br>\nNot every model will like it.  :)  </p>",
      "votes": null,
      "replies": [
        {
          "id": 2141574,
          "author_name": "asimandia",
          "author_url": "",
          "post_date": "02/12/2023 21:33:21",
          "content": "<p>Thank you for your message!<br>\nIt helped me fix the issue and better understand the metric.<br>\nI've done some experiments on the stability of metric and it doesn't really seem to make sense. After futher analysis I found out it has fading error. <br>\nSo the longer form is still a mystery to me. This transformation looks so obvious to me.</p>\n<p>You say we should not work in terms of angles in models. <br>\nI have an ituition that special form of output can be used to match such a thing. <br>\nWouldn't <code>sin(logits)</code> work for example? If not, why?</p>",
          "votes": null,
          "replies": [
            {
              "id": 2163039,
              "author_name": "synset",
              "author_url": "",
              "post_date": "02/28/2023 14:49:21",
              "content": "<p>I didn't have notifications set up and I just now saw your question.</p>\n<p>We use the final model layer with three outputs - direction components. You can, of course, take a sine from them. This at least regularizes the length of the vector. But I have not experimented with this option.</p>\n<p>More important is not the output, but what loss is then minimized.<br>\nI'll try to post a little later about the various choices of loss.</p>\n<p>Good luck!</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2142345,
      "author_name": "giranntu",
      "author_url": "",
      "post_date": "02/13/2023 13:15:18",
      "content": "<p>It's amazing how this metric is widely used in various fields such as astronomy, navigation, and GIS. </p>\n<p>A question I have, how does this metric compare to other metrics in terms of its usefulness and accuracy in measuring the difference in direction between two points?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2161486,
      "author_name": "yanasem",
      "author_url": "",
      "post_date": "02/27/2023 14:42:52",
      "content": "<p>Nice explanation, thanks! </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2140451": "Mean Angular Error or Angular distance is a measure of the difference in direction between two points on a sphere, such as a planet or star (if we really belive it's spherical). It is defined as the angle between two lines connecting the center of the sphere to the two points. Angular distance is used in a variety of applications, including astronomy, navigation, and geographic information systems (GIS).\n\nIn astronomical applications, angular distance is used to measure the separation between celestial objects, such as stars, galaxies, and quasars. And that's what we do: tryiong to find out where does neutrion comes from!\n\nAngular distance is typically measured in units of degrees, radians, or arcseconds. It is an important concept in spherical geometry and is used in a variety of mathematical and computational models in these fields. \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F173638da9d87d803e2b936cd4521f9e0%2F3D_Spherical.png?generation=1676140789343966&alt=media)\n\nWhere \nφ  is called azimuth \n𝜃 and is called zenith\n\n\nThe original formula of the metric is the following:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F95d5f7bd959113ea714e7a2dfaeaba0d%2Fshort.png?generation=1676233721324185&alt=media)\n\nBut [host uses](https://www.kaggle.com/code/sohier/mean-angular-error) another form:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1046338%2F079fdab610efb2ee3170482aac134efb%2Flong.png?generation=1676233738659438&alt=media)\n\nAs far as I see, it helps numeric stability as far as we have limited **reception angle**.",
    "2140920": "The metric that organizers use is based on the following idea. A unit vector in a spherical coordinate system has the following components:\n$$\n\\mathbf{n} = (n_x,\\, n_y, \\,n_z)=(\\sin\\theta\\cos\\phi,~\\sin\\theta\\sin\\phi,~\\cos\\theta) .\n$$\nThe angles in the picture **do not match** the angles in your formulas. According to the picture, the zenith angle is theta, since I wrote it.\n\nThe cosine of the angle between two unit vectors is equal to their dot product:\n$$\n\\cos(\\text{score}) = \\mathbf{n} \\hat{\\mathbf{n} } = n_x\\hat{n}_x + n_y\\hat{n}_y + n_z\\hat{n}_z = \\sin\\theta\\,\\sin\\hat{\\theta}\\, (\\cos\\phi \\,\\cos\\hat{\\phi} +\\sin\\phi\\,\\sin\\hat{\\phi} )+ \\cos\\theta \\cos\\hat{\\theta}.\n$$\nYou can simplify this expression with the cosine identity of the angle difference. In principle, this will slightly speed up the calculations, but it is unlikely to increase their stability.\n\nI note that in models you **should not work in terms of angles**. The model must predict the three components of the unit vector. It is clear that:\n$$\n\\theta+\\pi \\equiv \\theta,\\,\\,\\,\\,\\,\\,\\phi+2\\pi \\equiv \\phi\n$$ \nNot every model will like it.  :)",
    "2141574": "Thank you for your message!\nIt helped me fix the issue and better understand the metric.\nI've done some experiments on the stability of metric and it doesn't really seem to make sense. After futher analysis I found out it has fading error. \nSo the longer form is still a mystery to me. This transformation looks so obvious to me.\n\nYou say we should not work in terms of angles in models. \nI have an ituition that special form of output can be used to match such a thing. \nWouldn't `sin(logits) ` work for example? If not, why?",
    "2142345": "It's amazing how this metric is widely used in various fields such as astronomy, navigation, and GIS. \n\nA question I have, how does this metric compare to other metrics in terms of its usefulness and accuracy in measuring the difference in direction between two points?",
    "2161486": "Nice explanation, thanks!",
    "2163039": "I didn't have notifications set up and I just now saw your question.\n\nWe use the final model layer with three outputs - direction components. You can, of course, take a sine from them. This at least regularizes the length of the vector. But I have not experimented with this option.\n\nMore important is not the output, but what loss is then minimized.\nI'll try to post a little later about the various choices of loss.\n\nGood luck!"
  },
  "source": "meta"
}