{"id":25260,"date":"2024-01-19T16:57:26","date_gmt":"2024-01-19T08:57:26","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=25260"},"modified":"2024-01-19T16:57:27","modified_gmt":"2024-01-19T08:57:27","slug":"%e8%a7%a3%e5%af%86%e7%96%be%e7%97%85%e9%a2%84%e6%b5%8b%e7%9a%84%e7%a5%9e%e5%a5%87%e4%b9%8b%e5%8a%9b%ef%bc%81%e7%94%a8r%e5%8c%85randomforest%e6%88%90%e4%b8%ba%e9%a2%84%e6%b5%8b%e5%a4%a7","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=25260","title":{"rendered":"\u89e3\u5bc6\u75be\u75c5\u9884\u6d4b\u7684\u795e\u5947\u4e4b\u529b\uff01\u7528R\u5305randomForest\u6210\u4e3a\u201c\u9884\u6d4b\u5927\u5e08\u201d"},"content":{"rendered":"<p><a id=\"post-25260-OLE_LINK2\"><\/a> \u5927\u5bb6\u597d\uff0c\u6211\u662f\u5c0f\u679c\uff0c\u4e00\u4e2a\u5bf9\u751f\u7269\u4fe1\u606f\u5b66\u5145\u6ee1\u70ed\u60c5\u7684\u5c0f\u4f19\u4f34\u3002\u4eca\u5929\uff0c\u6211\u8981\u548c\u5927\u5bb6\u5206\u4eab\u4e00\u9879\u4ee4\u4eba\u6fc0\u52a8\u7684\u6280\u672f\u2014\u2014\u4f7f\u7528R\u8bed\u8a00\u4e2d\u7684\u795e\u5947\u5305randomForest\u8fdb\u884c\u75be\u75c5\u9884\u6d4b\u3002\u901a\u8fc7\u8fd9\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u6570\u636e\u7684\u529b\u91cf\u6210\u4e3a\u771f\u6b63\u7684\u201c\u9884\u6d4b\u5927\u5e08\u201d\u3002\u8fd8\u7b49\u4ec0\u4e48\u5462\uff1f\u5feb\u6765\u63a2\u7d22\u8fd9\u4e2a\u795e\u5947\u7684\u9886\u57df\u5427\uff01<\/p>\n<p>\u75be\u75c5\u9884\u6d4b\u4e00\u76f4\u662f\u533b\u5b66\u9886\u57df\u7684\u91cd\u5927\u6311\u6218\uff0c\u800c\u73b0\u4ee3\u751f\u7269\u4fe1\u606f\u5b66\u6280\u672f\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u7a81\u7834\u7684\u673a\u4f1a\u3002randomForest\u5305\u7684\u51fa\u73b0\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u9884\u6d4b\u75be\u75c5\u7684\u53d1\u751f\u548c\u53d1\u5c55\u8d8b\u52bf\u3002<\/p>\n<p>randomForest\u662f\u4e00\u79cd\u96c6\u6210\u5b66\u4e60\u7b97\u6cd5\uff0c\u57fa\u4e8e\u51b3\u7b56\u6811\u7684\u601d\u60f3\u3002\u8fd9\u4e2a\u7b97\u6cd5\u7684\u5965\u5999\u4e4b\u5904\u5728\u4e8e\uff0c\u5b83\u901a\u8fc7\u7ec4\u5408\u591a\u4e2a\u51b3\u7b56\u6811\u7684\u9884\u6d4b\u7ed3\u679c\u6765\u63d0\u9ad8\u9884\u6d4b\u7684\u51c6\u786e\u6027\u3002\u5c31\u50cf\u68ee\u6797\u4e2d\u7684\u6811\u6728\u4e00\u6837\uff0c\u6bcf\u68f5\u51b3\u7b56\u6811\u90fd\u6709\u81ea\u5df1\u7684\u7279\u70b9\uff0c\u800c\u96c6\u6210\u540e\u7684\u7ed3\u679c\u5374\u6bd4\u5355\u4e2a\u6811\u66f4\u53ef\u9760\u3002<\/p>\n<p>\u5728R\u4e2d\uff0crandomForest\u5305\u63d0\u4f9b\u4e86\u591a\u4e2a\u51fd\u6570\u7528\u4e8e\u6784\u5efa\u548c\u5206\u6790\u968f\u673a\u68ee\u6797\u6a21\u578b\u3002\u4e0b\u9762\u662frandomForest\u5305\u4e2d\u5e38\u7528\u7684\u51fd\u6570\u53ca\u5176\u53c2\u6570\u7684\u89e3\u91ca\uff1a<\/p>\n<ul>\n<li>randomForest(): \u8fd9\u662f\u6784\u5efa\u968f\u673a\u68ee\u6797\u6a21\u578b\u7684\u4e3b\u8981\u51fd\u6570\u3002\u5b83\u7684\u4e3b\u8981\u53c2\u6570\u5305\u62ec\uff1a<\/li>\n<\/ul>\n<p>x: \u81ea\u53d8\u91cf\u77e9\u9635\u6216\u6570\u636e\u6846\uff0c\u5305\u542b\u7528\u4e8e\u8bad\u7ec3\u6a21\u578b\u7684\u7279\u5f81\u3002<\/p>\n<p>y: \u56e0\u53d8\u91cf\u5411\u91cf\uff0c\u5305\u542b\u4e0e\u81ea\u53d8\u91cf\u76f8\u5bf9\u5e94\u7684\u76ee\u6807\u53d8\u91cf\u3002<\/p>\n<p>ntree: \u51b3\u7b56\u6811\u7684\u6570\u91cf\uff0c\u5373\u968f\u673a\u68ee\u6797\u4e2d\u6811\u7684\u4e2a\u6570\u3002<\/p>\n<p>mtry: \u6bcf\u68f5\u51b3\u7b56\u6811\u4e2d\u968f\u673a\u9009\u62e9\u7684\u7279\u5f81\u6570\u91cf\u3002<\/p>\n<p>importance: \u662f\u5426\u8ba1\u7b97\u53d8\u91cf\u91cd\u8981\u6027\u3002<\/p>\n<p>&#8230;: \u5176\u4ed6\u53c2\u6570\u7528\u4e8e\u63a7\u5236\u6a21\u578b\u6784\u5efa\u8fc7\u7a0b\uff0c\u5982\u8282\u70b9\u5206\u88c2\u7684\u51c6\u5219\u3001\u6837\u672c\u62bd\u6837\u65b9\u5f0f\u7b49\u3002<\/p>\n<ul>\n<li>importance(): \u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5df2\u6784\u5efa\u968f\u673a\u68ee\u6797\u6a21\u578b\u4e2d\u7684\u53d8\u91cf\u91cd\u8981\u6027\u3002<\/li>\n<\/ul>\n<p>rf: \u968f\u673a\u68ee\u6797\u6a21\u578b\u5bf9\u8c61\u3002<\/p>\n<p>type: \u91cd\u8981\u6027\u5ea6\u91cf\u7684\u7c7b\u578b\uff0c\u5982MeanDecreaseAccuracy\uff08\u5e73\u5747\u51c6\u786e\u7387\u4e0b\u964d\uff09\u3001MeanDecreaseGini\uff08\u5e73\u5747Gini\u6307\u6570\u4e0b\u964d\uff09\u7b49\u3002<\/p>\n<ul>\n<li>predict(): \u7528\u4e8e\u5bf9\u65b0\u7684\u6570\u636e\u8fdb\u884c\u9884\u6d4b\u6216\u63a8\u65ad\u3002<\/li>\n<\/ul>\n<p>rf: \u968f\u673a\u68ee\u6797\u6a21\u578b\u5bf9\u8c61\u3002<\/p>\n<p>newdata: \u5305\u542b\u8981\u8fdb\u884c\u9884\u6d4b\u7684\u65b0\u6570\u636e\u7684\u77e9\u9635\u6216\u6570\u636e\u6846\u3002<\/p>\n<ul>\n<li>plot(): \u7528\u4e8e\u7ed8\u5236\u968f\u673a\u68ee\u6797\u6a21\u578b\u7684\u56fe\u5f62\uff0c\u5982\u53d8\u91cf\u91cd\u8981\u6027\u56fe\u3001\u8bef\u5dee\u56fe\u7b49\u3002<\/li>\n<\/ul>\n<p>x: \u968f\u673a\u68ee\u6797\u6a21\u578b\u5bf9\u8c61\u3002<\/p>\n<p>&#8230;: \u5176\u4ed6\u53c2\u6570\u7528\u4e8e\u63a7\u5236\u56fe\u5f62\u7684\u5916\u89c2\u548c\u5e03\u5c40\u3002<\/p>\n<p>\u8fd9\u4e9b\u662frandomForest\u5305\u4e2d\u7684\u4e00\u4e9b\u5e38\u7528\u51fd\u6570\u548c\u53c2\u6570\u3002\u5f53\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u6784\u5efa\u548c\u5206\u6790\u968f\u673a\u68ee\u6797\u6a21\u578b\u65f6\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u95ee\u9898\u548c\u9700\u8981\u6765\u8c03\u6574\u53c2\u6570\uff0c\u4ee5\u83b7\u5f97\u6700\u4f73\u7684\u7ed3\u679c\u548c\u7406\u89e3\u6a21\u578b\u7684\u5173\u952e\u7279\u5f81\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f7f\u7528randomForest\u5305\u8fdb\u884c\u7cd6\u5c3f\u75c5\u9884\u6d4b\u7684\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<p>\u4ee3\u7801\u5177\u4f53\u5305\u62ec\uff1a<\/p>\n<p>Step1 \u5bfc\u5165\u6570\u636e\u96c6\u4ee5\u53ca\u6570\u636e\u9884\u5904\u7406<\/p>\n<p># \u8fd9\u91cc\u7684&#8221;inputdata.txt&#8221;\u662f\u81ea\u884c\u51c6\u5907\u7684\u672c\u5730\u6587\u4ef6\uff0c\u5c0f\u679c\u7ed9\u5927\u5bb6\u9644\u5728\u6700\u540e\u3002<\/p>\n<p># 1.\u5bfc\u5165\u6570\u636e\u96c6\u4ee5\u53ca\u6570\u636e\u9884\u5904\u7406<\/p>\n<p># \u5b89\u88c5\u548c\u52a0\u8f7drandomForest\u5305<\/p>\n<p>#install.packages(&#8220;randomForest&#8221;)<\/p>\n<p>library(randomForest)<\/p>\n<p># \u5bfc\u5165\u6570\u636e\u96c6<\/p>\n<p>data &lt;- read.table(file = &#8220;D:\/wanglab\/life\/ziyuan\/20230628\/inputdata.txt&#8221;,header = T) # \u66ff\u6362\u4e3a\u5b9e\u9645\u6570\u636e\u96c6\u6587\u4ef6\u7684\u8def\u5f84<\/p>\n<p>data$diabetes &lt;- as.factor(data$diabetes)<\/p>\n<p>head(data)<\/p>\n<p><strong>\u8f93\u5165\u6570\u636e\u5c55\u793a<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"526\" height=\"115\" class=\"wp-image-25261\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-1.png?resize=526%2C115\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-1.png?w=526 526w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-1.png?resize=300%2C66 300w\" sizes=\"(max-width: 526px) 100vw, 526px\" data-recalc-dims=\"1\" \/><\/p>\n<p># \u5212\u5206\u6570\u636e\u96c6\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/p>\n<p>set.seed(123) # \u8bbe\u7f6e\u968f\u673a\u79cd\u5b50\uff0c\u4fdd\u8bc1\u7ed3\u679c\u53ef\u590d\u73b0<\/p>\n<p>indices &lt;- sample(1:nrow(data), nrow(data)*0.8) # 80%\u7684\u6570\u636e\u7528\u4e8e\u8bad\u7ec3\uff0c20%\u7684\u6570\u636e\u7528\u4e8e\u6d4b\u8bd5<\/p>\n<p>trainingset &lt;- data[indices, ]<\/p>\n<p>testingset &lt;- data[-indices, ]<\/p>\n<p><a id=\"post-25260-OLE_LINK1\"><\/a> Step2\u6784\u5efa\u968f\u673a\u68ee\u6797\u6a21\u578b<\/p>\n<p># 2.<a id=\"post-25260-OLE_LINK3\"><\/a>\u521b\u5efa\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b<\/p>\n<p><a id=\"post-25260-OLE_LINK4\"><\/a> # 2.\u6784\u5efa\u968f\u673a\u68ee\u6797\u6a21\u578b<\/p>\n<p>rf_model &lt;- randomForest(diabetes ~ ., data = trainingset, ntree = 500,mtry=2)<\/p>\n<p># \u67e5\u770b\u6a21\u578b\u7ed3\u679c<\/p>\n<p>print(rf_model)<\/p>\n<p><a id=\"post-25260-OLE_LINK5\"><\/a><strong>\u67e5\u770b\u6a21\u578b\u7ed3\u679c\u622a\u56fe<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"522\" height=\"183\" class=\"wp-image-25262\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-2.png?resize=522%2C183\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-2.png?w=522 522w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-2.png?resize=300%2C105 300w\" sizes=\"(max-width: 522px) 100vw, 522px\" data-recalc-dims=\"1\" \/><\/p>\n<p># \u53d8\u91cf\u91cd\u8981\u6027\u56fe<\/p>\n<p>varImpPlot(rf_model)<\/p>\n<p>rf_model$importance<\/p>\n<p><strong>\u53d8\u91cf\u91cd\u8981\u6027\u56fe<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"207\" height=\"146\" class=\"wp-image-25263\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-3.png?resize=207%2C146\" data-recalc-dims=\"1\" \/> <img decoding=\"async\" loading=\"lazy\" width=\"442\" height=\"379\" class=\"wp-image-25264\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-4.png?resize=442%2C379\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-4.png?w=442 442w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-4.png?resize=300%2C257 300w\" sizes=\"(max-width: 442px) 100vw, 442px\" data-recalc-dims=\"1\" \/><\/p>\n<p>randomForest\u6a21\u578b\u7684\u7ed3\u679c\u5c06\u663e\u793a\u51fa\u91cd\u8981\u7684\u53d8\u91cf\u3001\u6bcf\u4e2a\u53d8\u91cf\u7684\u91cd\u8981\u6027\u6307\u6807\u4ee5\u53ca\u9884\u6d4b\u51c6\u786e\u6027\u7684\u5ea6\u91cf\u3002\u8fd9\u4e9b\u4fe1\u606f\u6709\u52a9\u4e8e\u6211\u4eec\u7406\u89e3\u54ea\u4e9b\u56e0\u7d20\u5bf9\u4e8e\u75be\u75c5\u7684\u9884\u6d4b\u8d77\u7740\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n<p># \u7ed8\u5236\u8bef\u5dee\u56fe<\/p>\n<p>plot(rf_model, main = &#8220;Random Forest Model Error&#8221;, type = &#8220;o&#8221;)<\/p>\n<p><strong>\u8bef\u5dee\u56fe<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"607\" height=\"744\" class=\"wp-image-25265\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-5.png?resize=607%2C744\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-5.png?w=607 607w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-5.png?resize=245%2C300 245w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-5.png?resize=600%2C735 600w\" sizes=\"(max-width: 607px) 100vw, 607px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u5728\u8bef\u5dee\u56fe\u4e2d\uff0c\u6a2a\u8f74\u8868\u793a\u968f\u673a\u68ee\u6797\u4e2d\u7684\u6bcf\u4e2a\u51b3\u7b56\u6811\uff0c\u7eb5\u8f74\u8868\u793a\u8bef\u5dee\u6216\u635f\u5931\u5ea6\u91cf\u3002\u6bcf\u4e2a\u70b9\u4ee3\u8868\u4e00\u4e2a\u51b3\u7b56\u6811\u6a21\u578b\u7684\u8bef\u5dee\u6216\u635f\u5931\u503c\uff0c\u800c\u6574\u4f53\u7684\u7ebf\u6761\u6216\u66f2\u7ebf\u8868\u793a\u6240\u6709\u51b3\u7b56\u6811\u6a21\u578b\u7684\u5e73\u5747\u8bef\u5dee\u6216\u635f\u5931\u3002\u8bef\u5dee\u56fe\u4e2d\u7684\u4e0d\u540c\u989c\u8272\u7ebf\u6761\u4ee3\u8868\u4e86\u4e0d\u540c\u6837\u672c\u96c6\u751f\u6210\u7684\u6a21\u578b\u7684\u9884\u6d4b\u8bef\u5dee\u3002\u8fd9\u4e9b\u4e0d\u540c\u989c\u8272\u7684\u7ebf\u6761\u8868\u793a\u968f\u673a\u68ee\u6797\u4e2d\u7684\u4e0d\u540c\u51b3\u7b56\u6811\u6a21\u578b\u6216\u5b50\u6a21\u578b\u7684\u5e73\u5747\u8bef\u5dee\u503c\u3002\u4e0d\u540c\u989c\u8272\u7684\u7ebf\u6761\u8d8b\u4e8e\u5e73\u884c\u4e14\u76f8\u4e92\u9760\u8fd1\uff0c\u8868\u793a\u968f\u673a\u68ee\u6797\u4e2d\u7684\u5b50\u6a21\u578b\u5177\u6709\u76f8\u4f3c\u7684\u8bef\u5dee\u6c34\u5e73\uff0c\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\u6bd4\u8f83\u7a33\u5b9a\u3002<\/p>\n<p># \u7ed8\u5236\u5355\u68f5\u51b3\u7b56\u6811<\/p>\n<p>library(rpart.plot)<\/p>\n<p>plot(rf_model$forest[[1]], uniform = TRUE, main = &#8220;Decision Tree&#8221;)<\/p>\n<p><strong>\u5355\u68f5\u51b3\u7b56\u6811<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"607\" height=\"744\" class=\"wp-image-25266\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-6.png?resize=607%2C744\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-6.png?w=607 607w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-6.png?resize=245%2C300 245w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-6.png?resize=600%2C735 600w\" sizes=\"(max-width: 607px) 100vw, 607px\" data-recalc-dims=\"1\" \/><\/p>\n<p>Step3 \u7ed8\u5236AUC\u66f2\u7ebf\u8bc4\u4f30\u6a21\u578b<\/p>\n<p># 3.\u7ed8\u5236AUC\u66f2\u7ebf\u8bc4\u4f30\u6a21\u578b<\/p>\n<p>#\u5bf9\u6d4b\u8bd5\u96c6\u8fdb\u884c\u9884\u6d4b<\/p>\n<p>pre_ran &lt;- predict(rf_model,newdata=testingset)<\/p>\n<p>#\u5c06\u771f\u5b9e\u503c\u548c\u9884\u6d4b\u503c\u6574\u5408\u5230\u4e00\u8d77<\/p>\n<p>obs_p_ran = data.frame(prob=pre_ran,obs=testingset$diabetes)<\/p>\n<p>#\u8f93\u51fa\u6df7\u6dc6\u77e9\u9635<\/p>\n<p>table(testingset$diabetes,pre_ran,dnn=c(&#8220;\u771f\u5b9e\u503c&#8221;,&#8221;\u9884\u6d4b\u503c&#8221;))<\/p>\n<p>#\u7ed8\u5236ROC\u66f2\u7ebf<\/p>\n<p>ran_roc &lt;- roc(testingset$diabetes,as.numeric(pre_ran))<\/p>\n<p>plot(ran_roc, print.auc=TRUE, auc.polygon=TRUE, grid=c(0.1, 0.2),grid.col=c(&#8220;green&#8221;, &#8220;red&#8221;), max.auc.polygon=TRUE,auc.polygon.col=&#8221;skyblue&#8221;, print.thres=TRUE,main=&#8217;\u968f\u673a\u68ee\u6797\u6a21\u578bROC\u66f2\u7ebf,mtry=2,ntree=500&#8242;)<\/p>\n<p><strong>AUC\u66f2\u7ebf\u56fe<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"607\" height=\"744\" class=\"wp-image-25267\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-7.png?resize=607%2C744\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-7.png?w=607 607w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-7.png?resize=245%2C300 245w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25260-7.png?resize=600%2C735 600w\" sizes=\"(max-width: 607px) 100vw, 607px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u6ce8\uff1a<\/p>\n<p># \u8bf7\u786e\u4fdd\u5c06\u8def\u5f84&#8221;inputdata.txt&#8221;\u66ff\u6362\u4e3a\u5b9e\u9645\u6570\u636e\u96c6\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u5e76\u6839\u636e\u9700\u8981\u8c03\u6574\u6a21\u578b\u53c2\u6570\u548c\u5176\u4ed6\u914d\u7f6e\u3002<\/p>\n<p># \u5728\u7ed8\u5236AUC\u66f2\u7ebf\u4e4b\u524d\uff0c\u786e\u4fdd\u60a8\u7684\u6a21\u578b\u8f93\u51fa\u7684\u662f\u9884\u6d4b\u7684\u6982\u7387\u503c\uff0c\u800c\u4e0d\u662f\u7c7b\u522b\u6807\u7b7e\u3002<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5b89\u88c5\u5e76\u52a0\u8f7d\u4e86randomForest\u5305\u3002\u7136\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u793a\u4f8b\u6570\u636e\u96c6\uff0c\u5176\u4e2d\u5305\u542b\u5e74\u9f84\uff08age\uff09\u548c\u4f53\u8d28\u6307\u6570\uff08bmi\uff09\u4f5c\u4e3a\u81ea\u53d8\u91cf\uff0c\u75be\u75c5\u60c5\u51b5\uff08disease\uff09\u4f5c\u4e3a\u56e0\u53d8\u91cf\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528randomForest\u51fd\u6570\u6784\u5efa\u4e86\u4e00\u4e2a\u75be\u75c5\u9884\u6d4b\u6a21\u578b\uff0c\u5176\u4e2d\u81ea\u53d8\u91cf\u901a\u8fc7~\u7b26\u53f7\u4e0e\u56e0\u53d8\u91cf\u76f8\u8fde\u3002\u6700\u540e\uff0c\u6211\u4eec\u901a\u8fc7\u6253\u5370rf_model\u6765\u67e5\u770b\u9884\u6d4b\u7ed3\u679c\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u60f3\u544a\u8bc9\u5927\u5bb6\u4e00\u4e2a\u6709\u8da3\u7684\u4e8b\u5b9e\uff1a\u201c\u4f7f\u7528randomForest\u5305\u8fdb\u884c\u75be\u75c5\u9884\u6d4b\uff0c\u5c31\u50cf\u5728\u68ee\u6797\u4e2d\u5bfb\u627e\u79d8\u5bc6\u8def\u5f84\uff0c\u800c\u8fd9\u4e2a\u8def\u5f84\u5c06\u5e26\u9886\u6211\u4eec\u63ed\u5f00\u75be\u75c5\u7684\u9762\u7eb1\u3002\u201d\u662f\u4e0d\u662f\u8ba9\u4f60\u5fc3\u52a8\u4e0d\u5df2\u5462\uff1f<\/p>\n<p>\u6700\u540e\uff0c\u6211\u60f3\u5f3a\u8c03\u4e00\u4e0b\u4f7f\u7528\u516c\u4f17\u53f7\u5e73\u53f0\u8fdb\u884c\u6570\u636e\u5206\u6790\u7684\u4fbf\u5229\u6027\u3002\u4e91\u751f\u4fe1\u5e73\u53f0\uff08<a href=\"http:\/\/www.biocloudservice.com\/home.html\u3002\">http:\/\/www.biocloudservice.com\/home.html<\/a>\uff09\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u3001\u65b9\u4fbf\u3001\u5feb\u901f\u7684\u65b9\u5f0f\u6765\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u5206\u4eab\u7ed3\u679c\u3002\u4f60\u53ea\u9700\u8f7b\u677e\u70b9\u51fb\uff0c\u5373\u53ef\u638c\u63e1\u6570\u636e\u7684\u5965\u79d8\uff0c\u6210\u4e3a\u75be\u75c5\u9884\u6d4b\u7684\u9ad8\u624b\uff01<\/p>\n<p>\u8ba9\u6211\u4eec\u4e00\u8d77\u5229\u7528randomForest\u5305\uff0c\u501f\u52a9\u516c\u4f17\u53f7\u5e73\u53f0\u7684\u529b\u91cf\uff0c\u7528\u6570\u636e\u9a71\u52a8\u7684\u65b9\u6cd5\u6765\u63ed\u793a\u75be\u75c5\u7684\u79d8\u5bc6\uff0c\u4e3a\u533b\u5b66\u7814\u7a76\u8d21\u732e\u4e00\u4efd\u529b\u91cf\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u5c0f\u679c\uff0c\u4e00\u4e2a\u5bf9\u751f\u7269\u4fe1\u606f\u5b66\u5145\u6ee1\u70ed\u60c5\u7684\u5c0f\u4f19\u4f34\u3002\u4eca\u5929\uff0c\u6211\u8981\u548c\u5927\u5bb6\u5206\u4eab\u4e00\u9879\u4ee4\u4eba\u6fc0\u52a8\u7684\u6280\u672f\u2014\u2014\u4f7f\u7528R\u8bed\u8a00\u4e2d\u7684\u795e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25260"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25260"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25260\/revisions"}],"predecessor-version":[{"id":25268,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25260\/revisions\/25268"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}