楼主: oliyiyi
2934 11

R - Decision Tree [推广有奖]

版主

泰斗

0%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
271951 个
通用积分
31269.3519
学术水平
1435 点
热心指数
1554 点
信用等级
1345 点
经验
383775 点
帖子
9598
精华
66
在线时间
5468 小时
注册时间
2007-5-21
最后登录
2024-4-18

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Install R Package

Use the below command in R console to install the package. You also have to install the dependent packages if any.

  1. install.packages("party")
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Decision CISI Tree CIS isi command package party

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html
沙发
oliyiyi 发表于 2017-2-22 22:09:07 |只看作者 |坛友微信交流群
Syntax

The basic syntax for creating a decision tree in R is −

  1. ctree(formula, data)
复制代码


缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

藤椅
oliyiyi 发表于 2017-2-22 22:09:45 |只看作者 |坛友微信交流群

the sample data.

  1. # Load the party package. It will automatically load other dependent packages.
  2. library(party)

  3. # Print some records from data set readingSkills.
  4. print(head(readingSkills))
复制代码


缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

板凳
oliyiyi 发表于 2017-2-22 22:10:16 |只看作者 |坛友微信交流群

When we execute the above code, it produces the following result and chart −

  1.   nativeSpeaker   age   shoeSize      score
  2. 1           yes     5   24.83189   32.29385
  3. 2           yes     6   25.95238   36.63105
  4. 3            no    11   30.42170   49.60593
  5. 4           yes     7   28.66450   40.28456
  6. 5           yes    11   31.88207   55.46085
  7. 6           yes    10   30.07843   52.83124
  8. Loading required package: methods
  9. Loading required package: grid
  10. ...............................
  11. ...............................
复制代码


缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

报纸
oliyiyi 发表于 2017-2-22 22:10:56 |只看作者 |坛友微信交流群
Example

We will use the ctree() function to create the decision tree and see its graph.

  1. # Load the party package. It will automatically load other dependent packages.
  2. library(party)

  3. # Create the input data frame.
  4. input.dat <- readingSkills[c(1:105),]

  5. # Give the chart file a name.
  6. png(file = "decision_tree.png")

  7. # Create the tree.
  8.   output.tree <- ctree(
  9.   nativeSpeaker ~ age + shoeSize + score,
  10.   data = input.dat)

  11. # Plot the tree.
  12. plot(output.tree)

  13. # Save the file.
  14. dev.off()
复制代码


缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

地板
oliyiyi 发表于 2017-2-22 22:11:27 |只看作者 |坛友微信交流群

When we execute the above code, it produces the following result −

  1. null device
  2.           1
  3. Loading required package: methods
  4. Loading required package: grid
  5. Loading required package: mvtnorm
  6. Loading required package: modeltools
  7. Loading required package: stats4
  8. Loading required package: strucchange
  9. Loading required package: zoo

  10. Attaching package: ‘zoo’

  11. The following objects are masked from ‘package:base’:

  12.     as.Date, as.Date.numeric

  13. Loading required package: sandwich
复制代码


缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

7
oliyiyi 发表于 2017-2-22 22:16:44 |只看作者 |坛友微信交流群

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

使用道具

8
oliyiyi 发表于 2017-2-22 22:17:16 |只看作者 |坛友微信交流群
From the decision tree shown above we can conclude that anyone whose readingSkills score is less than 38.3 and age is more than 6 is not a native Speaker.

使用道具

9
kkkm_db 发表于 2017-2-23 03:02:55 |只看作者 |坛友微信交流群
Thank you for sharing
已有 1 人评分论坛币 收起 理由
oliyiyi + 5 精彩帖子

总评分: 论坛币 + 5   查看全部评分

使用道具

10
franky_sas 发表于 2017-2-23 09:45:21 |只看作者 |坛友微信交流群

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 08:54