R-Language random forest algorithm

Source: Internet
Author: User

Install.packages ("Randomforest") #安装R包

Library (Party) #输入数据

Library (randomforest) #引入分析包

Output.forest <-Randomforest (nativespeaker ~ Age + shoesize + score,
data = readingskills) #创建随机森林
Print (output.forest) #查看
Print (Importance (Output.forest,type = 2)) #Gini指数

The Gini index indicates the purity of the node, and the greater the Gini index, the lower the purity. The average reduction of the Gini value indicates the average reduction of the purity of the variable partition nodes of all trees. For the variable importance measure, the steps are described earlier, the variable data is disturbed, and the mean value of the Gini exponential change is measured as the important degree of the variable.

The results are as follows:

Varimpplot (output.forest) #可视化

From the random forest shown above, we can conclude that shoe codes and grades are important factors in determining if someone is a native speaker or not a mother tongue. Furthermore, the model has only 1%~2% errors, which means we can predict the accuracy to be 98%.

R-Language random forest algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.