{
  "id": 12329,
  "title": "Under-performing Random Forest code. What's wrong?",
  "url": "/competitions/digit-recognizer/discussion/12329",
  "author_name": "davider",
  "post_date": "2015-01-25T19:18:36.957000",
  "votes": 0,
  "comment_count": 3,
  "views": null,
  "content": "<p>Hello,</p>\n<p>instead using the RF Benchmark I tried to use&nbsp;cforest_unbiased.</p>\n<p>The performance is bad:&nbsp;0.69186 but I don't understand what's wrong. Any suggestions?</p>\n<p><code>set.seed(666)</code></p>\n<p><code></code><code>train &lt;- read.csv(&quot;data/train.csv&quot;, header=TRUE)<br>test &lt;- read.csv(&quot;data/test.csv&quot;, header=TRUE)</code></p>\n<p><code>fit &lt;- cforest(label ~ ., data=train, controls=cforest_unbiased(ntree=1000, mtry=3))</code></p>\n<p><code>Prediction &lt;- predict(fit, test, OOB=TRUE, type = &quot;response&quot;)<br></code></p>\n<p><code>submit &lt;- data.frame(ImageId = labels(Prediction), Label = Prediction)<br></code></p>\n<p><code>write.csv(submit, file = &quot;digit-rf.csv&quot;, row.names = FALSE)</code></p>",
  "messages": [
    {
      "id": 63225,
      "postDate": "2015-01-27T04:19:42.020Z",
      "content": "<p>From the package description <a href=\"http://cran.r-project.org/web/packages/party/party.pdf\">here</a>, mtry is the &quot;number of input variables randomly sampled as candidates at each node for random&nbsp;forest like algorithms.&quot;</p>\n<p>The random part of random forest is choosing variables randomly at each levels to capture variances. In this case, setting mtry=3, you are asking to only use 3 variables out of 784 values at each level. That's too few.</p>\n<p>You can try the package 'randomForest'. It might be easier to understand.</p>\n<p>If you want to use other algorithms, I wrote a blog about all the resources I find <a href=\"http://qiweili.com/2015/01/25/learning-artificial-neural-network/\">here</a>.</p>",
      "votes": 1
    },
    {
      "id": 63246,
      "postDate": "2015-01-27T19:23:55.487Z",
      "content": "<p>The default value is square root. I got around 95% with it. I do not know if it is the best. You can always tune this parameter using cross validation.</p>"
    },
    {
      "id": 63226,
      "postDate": "2015-01-27T06:42:46.810Z",
      "content": "<p>Thank you Qiwei, now it's clear. I found this interesting publication:</p>\n<p>http://www.math.u-psud.fr/~genuer/genuer-poggi-tuleau.rf-insights.pdf</p>\n<p>For this classification problem do you advise to use the square root of number of inputs (mtry=28)?</p>"
    },
    {
      "id": 63152,
      "postDate": "2015-01-25T19:18:36.957Z",
      "content": "<p>Hello,</p>\n<p>instead using the RF Benchmark I tried to use&nbsp;cforest_unbiased.</p>\n<p>The performance is bad:&nbsp;0.69186 but I don't understand what's wrong. Any suggestions?</p>\n<p><code>set.seed(666)</code></p>\n<p><code></code><code>train &lt;- read.csv(&quot;data/train.csv&quot;, header=TRUE)<br>test &lt;- read.csv(&quot;data/test.csv&quot;, header=TRUE)</code></p>\n<p><code>fit &lt;- cforest(label ~ ., data=train, controls=cforest_unbiased(ntree=1000, mtry=3))</code></p>\n<p><code>Prediction &lt;- predict(fit, test, OOB=TRUE, type = &quot;response&quot;)<br></code></p>\n<p><code>submit &lt;- data.frame(ImageId = labels(Prediction), Label = Prediction)<br></code></p>\n<p><code>write.csv(submit, file = &quot;digit-rf.csv&quot;, row.names = FALSE)</code></p>"
    }
  ],
  "comments": [
    {
      "id": 63225,
      "author_name": "",
      "author_url": "",
      "post_date": "2015-01-27T04:19:42.020000",
      "content": "<p>From the package description <a href=\"http://cran.r-project.org/web/packages/party/party.pdf\">here</a>, mtry is the &quot;number of input variables randomly sampled as candidates at each node for random&nbsp;forest like algorithms.&quot;</p>\n<p>The random part of random forest is choosing variables randomly at each levels to capture variances. In this case, setting mtry=3, you are asking to only use 3 variables out of 784 values at each level. That's too few.</p>\n<p>You can try the package 'randomForest'. It might be easier to understand.</p>\n<p>If you want to use other algorithms, I wrote a blog about all the resources I find <a href=\"http://qiweili.com/2015/01/25/learning-artificial-neural-network/\">here</a>.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 63246,
      "author_name": "",
      "author_url": "",
      "post_date": "2015-01-27T19:23:55.487000",
      "content": "<p>The default value is square root. I got around 95% with it. I do not know if it is the best. You can always tune this parameter using cross validation.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 63226,
      "author_name": "davider",
      "author_url": "",
      "post_date": "2015-01-27T06:42:46.810000",
      "content": "<p>Thank you Qiwei, now it's clear. I found this interesting publication:</p>\n<p>http://www.math.u-psud.fr/~genuer/genuer-poggi-tuleau.rf-insights.pdf</p>\n<p>For this classification problem do you advise to use the square root of number of inputs (mtry=28)?</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "63225": "",
    "63246": "",
    "63226": "",
    "63152": ""
  }
}