{
  "id": 18934,
  "title": "CRPS scorer for R",
  "url": "/competitions/second-annual-data-science-bowl/discussion/18934",
  "author_name": "==>(AL)<==",
  "post_date": "2016-02-13T05:51:37.240000",
  "votes": 1,
  "comment_count": 0,
  "views": 534,
  "content": "<p>Here is the CRPS scorer for R:  </p>\n\n<p><strong>pred</strong> is a matrix Nx600 that contains predicted cdf(s)\n<strong>actual</strong> is a vector of true values</p>\n\n<pre><code>CRPS&lt;-function(pred, actual){\n\n  h&lt;-function(v, cdf) as.numeric(1:length(cdf)&gt;=v)\n\n  crps_ = mean(apply(cbind(actual, pred),1, function(x) mean((x[-1]-h(x[1],x[-1]))^2) ))\n\n  return (crps_)\n}\n</code></pre>",
  "messages": [
    {
      "id": 107858,
      "postDate": "2016-02-13T05:51:37.240Z",
      "content": "<p>Here is the CRPS scorer for R:  </p>\n\n<p><strong>pred</strong> is a matrix Nx600 that contains predicted cdf(s)\n<strong>actual</strong> is a vector of true values</p>\n\n<pre><code>CRPS&lt;-function(pred, actual){\n\n  h&lt;-function(v, cdf) as.numeric(1:length(cdf)&gt;=v)\n\n  crps_ = mean(apply(cbind(actual, pred),1, function(x) mean((x[-1]-h(x[1],x[-1]))^2) ))\n\n  return (crps_)\n}\n</code></pre>",
      "rawMarkdown": "Here is the CRPS scorer for R:  \r\n\r\n**pred** is a matrix Nx600 that contains predicted cdf(s)\r\n**actual** is a vector of true values\r\n\r\n    CRPS<-function(pred, actual){\r\n\r\n      h<-function(v, cdf) as.numeric(1:length(cdf)>=v)\r\n\r\n      crps_ = mean(apply(cbind(actual, pred),1, function(x) mean((x[-1]-h(x[1],x[-1]))^2) ))\r\n      \r\n      return (crps_)\r\n    }\r\n\r\n\r\n\r\n\r\n\r\n",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "107858": "Here is the CRPS scorer for R:  \r\n\r\n**pred** is a matrix Nx600 that contains predicted cdf(s)\r\n**actual** is a vector of true values\r\n\r\n    CRPS<-function(pred, actual){\r\n\r\n      h<-function(v, cdf) as.numeric(1:length(cdf)>=v)\r\n\r\n      crps_ = mean(apply(cbind(actual, pred),1, function(x) mean((x[-1]-h(x[1],x[-1]))^2) ))\r\n      \r\n      return (crps_)\r\n    }\r\n\r\n\r\n\r\n\r\n\r\n"
  }
}