{
  "id": 3567,
  "title": "Coding a Random Forest",
  "url": "/competitions/digit-recognizer/discussion/3567",
  "author_name": "",
  "post_date": "2013-01-10T03:14:01.713000",
  "votes": 4,
  "comment_count": 14,
  "views": null,
  "content": "<p>I'd like to code&nbsp;this myself instead of using a package so I can fully configure it. &nbsp;Any tips?</p>",
  "messages": [
    {
      "id": 19305,
      "postDate": "2013-01-14T22:22:16.110Z",
      "content": "<p>Hi YaoPau and Sean</p>\r\n<p>Yes, I did implement a Random Forest from scratch in Java. If you look at the leaderboard, you see that my implementation doesn't perform as well as the random forest benchmark (<span>0.96229 vs&nbsp;<span>0.96829). If I have some more free time, I'll play around\r\n a bit more on the parameters...</span></span></p>\r\n<p><span><span>From your text I think that you might be some confusion between a CART and a random forest.</span></span></p>\r\n<p>I recommend reading either&nbsp;<a href=\"http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm\">http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm</a>&nbsp;(from Breiman, the inventor of random forest) or my personal favorite&nbsp;<a href=\"http://research.microsoft.com/apps/pubs/default.aspx?id=155552\">http://research.microsoft.com/apps/pubs/default.aspx?id=155552</a>&nbsp;(from\r\n Microsoft Research, it describes how the Kinect works).<br>\r\nIn my opinion the random forest algorithm is one of the easier understandable algorithms in machine learning, because it doesn't involve any complicated math.</p>\r\n<p><span><span>For example, you don't test all 784 dimensions, only a random subset of those (if I remember correctly Breiman talks about the square root of the total dimensions, e.g. around 25 dimensions). Also, you don't prune the trees, you either let it\r\n grow until everything is classified (Breiman) or you stop after a predefined depth (Microsoft). You also don't need to crossvalidate every single tree. This saves you a lot of computation. Depending on the settings (number of dimensions to test, tree depth,\r\n etc.) it took me a couple of minutes to generate a tree. The process is also easy parallelizable. I generated around 100 trees for the result I submitted (the random forest benchmark on the leaderboard used 1000 trees).</span></span></p>\r\n<p>Also a comment to Sean: you don't need to do any dimensionality reduction if you use Random Forests, they inherently converge to mainly use the important dimensions. Breiman even explains how to find out which are the most important dimensions (something\r\n akin to PCA) on the website.</p>",
      "votes": 4
    },
    {
      "id": 19142,
      "postDate": "2013-01-10T03:14:01.713Z",
      "content": "<p>I'd like to code&nbsp;this myself instead of using a package so I can fully configure it. &nbsp;Any tips?</p>",
      "votes": 4
    },
    {
      "id": 217222,
      "postDate": "2017-08-29T20:05:01.613Z",
      "content": "<p>Hi,\nI want code for random forest in java or python. can you please send me to my email: a.shakori.com@gmail.com</p>",
      "rawMarkdown": "Hi,\nI want code for random forest in java or python. can you please send me to my email: a.shakori.com@gmail.com"
    },
    {
      "id": 163115,
      "postDate": "2017-02-22T17:56:29.950Z",
      "content": "<p>can you send the code please? its very urgent.\nmail id- dearsonu2020@gmail.com</p>",
      "rawMarkdown": "can you send the code please? its very urgent.\nmail id- dearsonu2020@gmail.com"
    },
    {
      "id": 143286,
      "postDate": "2016-11-07T22:19:34.900Z",
      "content": "<p>Please send the Random Forest Algorithm and Code on tushark26@gmail.com\nThank You</p>",
      "rawMarkdown": "Please send the Random Forest Algorithm and Code on tushark26@gmail.com\r\nThank You"
    },
    {
      "id": 87732,
      "postDate": "2015-07-31T09:22:42.670Z",
      "content": "<p>Hi All,</p>\n\n<p>Does anyone have a coded version of the random forest implementation that they would be willing to share? Would appreciate a resource to look over as I attempt to code it.</p>\n\n<p>Thanks.</p>",
      "rawMarkdown": "Hi All,\r\n\r\nDoes anyone have a coded version of the random forest implementation that they would be willing to share? Would appreciate a resource to look over as I attempt to code it.\r\n\r\nThanks."
    },
    {
      "id": 84262,
      "postDate": "2015-07-13T09:30:05.943Z",
      "content": "<p>Plz, send me Random forest alog. .java on pradumna.88@gmail.com</p>\n\n<p>Thanks</p>",
      "rawMarkdown": "Plz, send me Random forest alog. .java on pradumna.88@gmail.com\r\n\r\nThanks"
    },
    {
      "id": 77567,
      "postDate": "2015-05-08T04:22:57.607Z",
      "content": "<p>i also need code for random forest algorithm .java, please send me to my email qiqifauziah@gmail.com..Thanx</p>"
    },
    {
      "id": 69791,
      "postDate": "2015-04-06T11:39:33.773Z",
      "content": "<p>Hi,</p>\n<p>I also need code for random forest algorithm. Can you please send to my mail id: gunjan.kapse@gmail.com</p>\n<p>Thanks</p>"
    },
    {
      "id": 63295,
      "postDate": "2015-01-29T08:34:34.573Z",
      "content": "<p>hi</p>\n<p>i want code for random forest in java.can you please send me to my e-mail. pujithagupta@gmail.com</p>\n<p>kindly send me as early as possible.</p>\n<p>i am sending a sample dataset</p>"
    },
    {
      "id": 38596,
      "postDate": "2014-02-10T21:40:15.643Z",
      "content": "<p>Hi Furstenwald,</p>\n<p>please send me random forest implementation code in java.my email id:<strong>bhura2parul@gmail.com</strong>..Thanx</p>"
    },
    {
      "id": 37945,
      "postDate": "2014-01-26T12:17:45.427Z",
      "content": "<p>Hi</p>\n<p>I want coding of Random Forest algorithm in Java will u help me</p>"
    },
    {
      "id": 33300,
      "postDate": "2013-11-06T04:30:52.593Z",
      "content": "<p>Hi Furstenwald,</p>\n<p>&nbsp;</p>\n<p>i am new to java and trying to code the ML algorithm in java.</p>\n<p>Could you please share your complete java code for this problem</p>\n<p>&nbsp;</p>\n<p>thanks</p>\n<p>Aman</p>"
    },
    {
      "id": 19153,
      "postDate": "2013-01-10T14:47:36.103Z",
      "content": "<p>just have a look at the source(s). to get idea of complexity</p>\r\n<p>memory requirements: a few things i would raise... can the algorithm handle byte data ( arguably MNIST could be thresholded without distortion)</p>\r\n<p>I don't know the random forest algorithm but i am wondering from your description whether its worth rotating the coordinates eg PCA or HAAR features, in hope you don't have to search all 784 points etc?</p>"
    },
    {
      "id": 166848,
      "postDate": "2017-03-11T12:44:10.830Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 19305,
      "author_name": "Folli",
      "author_url": "",
      "post_date": "2013-01-14T22:22:16.110000",
      "content": "<p>Hi YaoPau and Sean</p>\r\n<p>Yes, I did implement a Random Forest from scratch in Java. If you look at the leaderboard, you see that my implementation doesn't perform as well as the random forest benchmark (<span>0.96229 vs&nbsp;<span>0.96829). If I have some more free time, I'll play around\r\n a bit more on the parameters...</span></span></p>\r\n<p><span><span>From your text I think that you might be some confusion between a CART and a random forest.</span></span></p>\r\n<p>I recommend reading either&nbsp;<a href=\"http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm\">http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm</a>&nbsp;(from Breiman, the inventor of random forest) or my personal favorite&nbsp;<a href=\"http://research.microsoft.com/apps/pubs/default.aspx?id=155552\">http://research.microsoft.com/apps/pubs/default.aspx?id=155552</a>&nbsp;(from\r\n Microsoft Research, it describes how the Kinect works).<br>\r\nIn my opinion the random forest algorithm is one of the easier understandable algorithms in machine learning, because it doesn't involve any complicated math.</p>\r\n<p><span><span>For example, you don't test all 784 dimensions, only a random subset of those (if I remember correctly Breiman talks about the square root of the total dimensions, e.g. around 25 dimensions). Also, you don't prune the trees, you either let it\r\n grow until everything is classified (Breiman) or you stop after a predefined depth (Microsoft). You also don't need to crossvalidate every single tree. This saves you a lot of computation. Depending on the settings (number of dimensions to test, tree depth,\r\n etc.) it took me a couple of minutes to generate a tree. The process is also easy parallelizable. I generated around 100 trees for the result I submitted (the random forest benchmark on the leaderboard used 1000 trees).</span></span></p>\r\n<p>Also a comment to Sean: you don't need to do any dimensionality reduction if you use Random Forests, they inherently converge to mainly use the important dimensions. Breiman even explains how to find out which are the most important dimensions (something\r\n akin to PCA) on the website.</p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 217222,
      "author_name": "azam84",
      "author_url": "",
      "post_date": "2017-08-29T20:05:01.613000",
      "content": "<p>Hi,\nI want code for random forest in java or python. can you please send me to my email: a.shakori.com@gmail.com</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 163115,
      "author_name": "ChandrishaKhaskel",
      "author_url": "",
      "post_date": "2017-02-22T17:56:29.950000",
      "content": "<p>can you send the code please? its very urgent.\nmail id- dearsonu2020@gmail.com</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 143286,
      "author_name": "TusharKamble",
      "author_url": "",
      "post_date": "2016-11-07T22:19:34.900000",
      "content": "<p>Please send the Random Forest Algorithm and Code on tushark26@gmail.com\nThank You</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 87732,
      "author_name": "DataNovice1",
      "author_url": "",
      "post_date": "2015-07-31T09:22:42.670000",
      "content": "<p>Hi All,</p>\n\n<p>Does anyone have a coded version of the random forest implementation that they would be willing to share? Would appreciate a resource to look over as I attempt to code it.</p>\n\n<p>Thanks.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 84262,
      "author_name": "PradumnaPanditrao",
      "author_url": "",
      "post_date": "2015-07-13T09:30:05.943000",
      "content": "<p>Plz, send me Random forest alog. .java on pradumna.88@gmail.com</p>\n\n<p>Thanks</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 77567,
      "author_name": "fauziahrizqi",
      "author_url": "",
      "post_date": "2015-05-08T04:22:57.607000",
      "content": "<p>i also need code for random forest algorithm .java, please send me to my email qiqifauziah@gmail.com..Thanx</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 69791,
      "author_name": "vaidehi1",
      "author_url": "",
      "post_date": "2015-04-06T11:39:33.773000",
      "content": "<p>Hi,</p>\n<p>I also need code for random forest algorithm. Can you please send to my mail id: gunjan.kapse@gmail.com</p>\n<p>Thanks</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 63295,
      "author_name": "Pujitha Doreti",
      "author_url": "",
      "post_date": "2015-01-29T08:34:34.573000",
      "content": "<p>hi</p>\n<p>i want code for random forest in java.can you please send me to my e-mail. pujithagupta@gmail.com</p>\n<p>kindly send me as early as possible.</p>\n<p>i am sending a sample dataset</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 38596,
      "author_name": "bhura parul",
      "author_url": "",
      "post_date": "2014-02-10T21:40:15.643000",
      "content": "<p>Hi Furstenwald,</p>\n<p>please send me random forest implementation code in java.my email id:<strong>bhura2parul@gmail.com</strong>..Thanx</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 37945,
      "author_name": "Bhoopathy janan",
      "author_url": "",
      "post_date": "2014-01-26T12:17:45.427000",
      "content": "<p>Hi</p>\n<p>I want coding of Random Forest algorithm in Java will u help me</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 33300,
      "author_name": "amenem",
      "author_url": "",
      "post_date": "2013-11-06T04:30:52.593000",
      "content": "<p>Hi Furstenwald,</p>\n<p>&nbsp;</p>\n<p>i am new to java and trying to code the ML algorithm in java.</p>\n<p>Could you please share your complete java code for this problem</p>\n<p>&nbsp;</p>\n<p>thanks</p>\n<p>Aman</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 19153,
      "author_name": "Sean",
      "author_url": "",
      "post_date": "2013-01-10T14:47:36.103000",
      "content": "<p>just have a look at the source(s). to get idea of complexity</p>\r\n<p>memory requirements: a few things i would raise... can the algorithm handle byte data ( arguably MNIST could be thresholded without distortion)</p>\r\n<p>I don't know the random forest algorithm but i am wondering from your description whether its worth rotating the coordinates eg PCA or HAAR features, in hope you don't have to search all 784 points etc?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 166848,
      "author_name": "",
      "author_url": "",
      "post_date": "2017-03-11T12:44:10.830000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "19305": "",
    "19142": "",
    "217222": "Hi,\nI want code for random forest in java or python. can you please send me to my email: a.shakori.com@gmail.com",
    "163115": "can you send the code please? its very urgent.\nmail id- dearsonu2020@gmail.com",
    "143286": "Please send the Random Forest Algorithm and Code on tushark26@gmail.com\r\nThank You",
    "87732": "Hi All,\r\n\r\nDoes anyone have a coded version of the random forest implementation that they would be willing to share? Would appreciate a resource to look over as I attempt to code it.\r\n\r\nThanks.",
    "84262": "Plz, send me Random forest alog. .java on pradumna.88@gmail.com\r\n\r\nThanks",
    "77567": "",
    "69791": "",
    "63295": "",
    "38596": "",
    "37945": "",
    "33300": "",
    "19153": "",
    "166848": ""
  }
}