Skip to main content
added 129 characters in body
Source Link
Jack Ryan
  • 316
  • 2
  • 7

Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. I'll use the iris data set since it's readily available (and in the documentation):

data(iris)
d <- sort(sample(nrow(iris),nrow(iris)*.7))
(iris.rpart <- rpart(Species ~ . , data = iris, subset = d, method = "class"))
# n= 105 
# 
# node), split, n, loss, yval, (yprob)
# * denotes terminal node
# 
# 1) root 105 68 setosa (0.3523810 0.3333333 0.3142857)  
# 2) Petal.Length< 2.45 37  0 setosa (1.0000000 0.0000000 0.0000000) *
#   3) Petal.Length>=2.45 68 33 versicolor (0.0000000 0.5147059 0.4852941)  
# 6) Petal.Width< 1.75 40  5 versicolor (0.0000000 0.8750000 0.1250000) *
#   7) Petal.Width>=1.75 28  0 virginica (0.0000000 0.0000000 1.0000000) *

# this validation of your test data set (30% of records) shows that the 
# model predicted 44 of 45 correct.  Not bad.
table(predict(iris.rpart, iris[-d,], type = "class"), iris[-d, "Species"])
# setosa versicolor virginica
# setosa         15          0         0
# versicolor      0         15         1
# virginica       0          0        14

?predict.rpart

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. I'll use the iris data set since it's readily available (and in the documentation):

data(iris)
d <- sort(sample(nrow(iris),nrow(iris)*.7))
(iris.rpart <- rpart(Species ~ . , data = iris, subset = d, method = "class"))
# n= 105 
# 
# node), split, n, loss, yval, (yprob)
# * denotes terminal node
# 
# 1) root 105 68 setosa (0.3523810 0.3333333 0.3142857)  
# 2) Petal.Length< 2.45 37  0 setosa (1.0000000 0.0000000 0.0000000) *
#   3) Petal.Length>=2.45 68 33 versicolor (0.0000000 0.5147059 0.4852941)  
# 6) Petal.Width< 1.75 40  5 versicolor (0.0000000 0.8750000 0.1250000) *
#   7) Petal.Width>=1.75 28  0 virginica (0.0000000 0.0000000 1.0000000) *

table(predict(iris.rpart, iris[-d,], type = "class"), iris[-d, "Species"])
# setosa versicolor virginica
# setosa         15          0         0
# versicolor      0         15         1
# virginica       0          0        14

?predict.rpart

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. I'll use the iris data set since it's readily available (and in the documentation):

data(iris)
d <- sort(sample(nrow(iris),nrow(iris)*.7))
(iris.rpart <- rpart(Species ~ . , data = iris, subset = d, method = "class"))
# n= 105 
# 
# node), split, n, loss, yval, (yprob)
# * denotes terminal node
# 
# 1) root 105 68 setosa (0.3523810 0.3333333 0.3142857)  
# 2) Petal.Length< 2.45 37  0 setosa (1.0000000 0.0000000 0.0000000) *
#   3) Petal.Length>=2.45 68 33 versicolor (0.0000000 0.5147059 0.4852941)  
# 6) Petal.Width< 1.75 40  5 versicolor (0.0000000 0.8750000 0.1250000) *
#   7) Petal.Width>=1.75 28  0 virginica (0.0000000 0.0000000 1.0000000) *

# this validation of your test data set (30% of records) shows that the 
# model predicted 44 of 45 correct.  Not bad.
table(predict(iris.rpart, iris[-d,], type = "class"), iris[-d, "Species"])
# setosa versicolor virginica
# setosa         15          0         0
# versicolor      0         15         1
# virginica       0          0        14

?predict.rpart

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

added 1015 characters in body
Source Link
Jack Ryan
  • 316
  • 2
  • 7

Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. I'll use the iris data set since it's readily available (and in the documentation):

data(iris)
d <- sort(sample(nrow(iris),nrow(iris)*.7))
(iris.rpart <- rpart(Species ~ . , data = iris, subset = d, method = "class"))
# n= 105 
# 
# node), split, n, loss, yval, (yprob)
# * denotes terminal node
# 
# 1) root 105 68 setosa (0.3523810 0.3333333 0.3142857)  
# 2) Petal.Length< 2.45 37  0 setosa (1.0000000 0.0000000 0.0000000) *
#   3) Petal.Length>=2.45 68 33 versicolor (0.0000000 0.5147059 0.4852941)  
# 6) Petal.Width< 1.75 40  5 versicolor (0.0000000 0.8750000 0.1250000) *
#   7) Petal.Width>=1.75 28  0 virginica (0.0000000 0.0000000 1.0000000) *

table(predict(iris.rpart, iris[-d,], type = "class"), iris[-d, "Species"])
# setosa versicolor virginica
# setosa         15          0         0
# versicolor      0         15         1
# virginica       0          0        14

?predict.rpart

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. I'll use the iris data set since it's readily available (and in the documentation):

data(iris)
d <- sort(sample(nrow(iris),nrow(iris)*.7))
(iris.rpart <- rpart(Species ~ . , data = iris, subset = d, method = "class"))
# n= 105 
# 
# node), split, n, loss, yval, (yprob)
# * denotes terminal node
# 
# 1) root 105 68 setosa (0.3523810 0.3333333 0.3142857)  
# 2) Petal.Length< 2.45 37  0 setosa (1.0000000 0.0000000 0.0000000) *
#   3) Petal.Length>=2.45 68 33 versicolor (0.0000000 0.5147059 0.4852941)  
# 6) Petal.Width< 1.75 40  5 versicolor (0.0000000 0.8750000 0.1250000) *
#   7) Petal.Width>=1.75 28  0 virginica (0.0000000 0.0000000 1.0000000) *

table(predict(iris.rpart, iris[-d,], type = "class"), iris[-d, "Species"])
# setosa versicolor virginica
# setosa         15          0         0
# versicolor      0         15         1
# virginica       0          0        14

?predict.rpart

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

deleted 2 characters in body
Source Link
Jack Ryan
  • 316
  • 2
  • 7

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you.

Also Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you.

Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

This could be a comment but. . .

In all seriousness, probably the best help anyone can give you is "read the manual." Since we don't have access to your data, I am guessing that pages 39- 40 of the manual will help you. Also I could point you to the rattle package: this is a pretty simple point and click interface to the rpart package, along with several other modeling tools.

By the way: as noted on the 2nd page of the manual, CART is a trademarked name. "Recursive Partitioning" is a generic name, so you should probably describe your model accordingly.

I hope this helps.

Source Link
Jack Ryan
  • 316
  • 2
  • 7
Loading