0
A
回答
2
我以前用過rpart,這很方便。我通過分割訓練和測試集來用於預測建模。這是代碼。希望這會給你一些想法...
library(rpart)
library(rattle)
library(rpart.plot)
### Build the training/validate/test...
data(iris)
nobs <- nrow(iris)
train <- sample(nrow(iris), 0.7*nobs)
test <- setdiff(seq_len(nrow(iris)), train)
colnames(iris)
### The following variable selections have been noted.
input <- c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")
numeric <- c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")
categoric <- NULL
target <-"Species"
risk <- NULL
ident <- NULL
ignore <- NULL
weights <- NULL
#set.seed(500)
# Build the Decision Tree model.
rpart <- rpart(Species~.,
data=iris[train, ],
method="class",
parms=list(split="information"),
control=rpart.control(minsplit=12,
usesurrogate=0,
maxsurrogate=0))
# Generate a textual view of the Decision Tree model.
print(rpart)
printcp(rpart)
# Decision Tree Plot...
prp(rpart)
dev.new()
fancyRpartPlot(rpart, main="Decision Tree Graph")
相關問題
- 1. 用r在r上繪製決策樹
- 2. 在R(插圖)中繪製決策樹
- 3. 如何在R編程中的決策樹中指定分割?
- 4. 如何設置決策樹
- 5. 如何計算決策樹
- 6. 決策樹在樹決策中保持使用Y變量
- 7. 如何在MS Bot Framework上做決策樹?
- 8. 如何縮小r studio中的決策樹圖?
- 9. 如何在決策樹中使用rpart決定'minsplit'?
- 10. 解析決策樹(來自WEKA分類器)在R中繪圖?
- 11. 在R中使用tm和rpart:文本數據的決策樹?
- 12. 決策樹問題解決
- 13. 執行決策樹
- 14. 決策樹修剪
- 15. 修剪決策樹
- 16. 決策樹組件
- 17. weka決策樹java
- 18. 建模決策樹
- 19. 在R中的決策樹錯誤:擬合不是樹,只是一個根
- 20. R中決策樹中的節點 - 需要更多節點
- 21. R從partykit決策樹中提取終端節點信息
- 22. 決策樹中的決策節點和機會節點定義
- 23. 在R中繪製決策邊界
- 24. 如何在引導程序中構建交互式決策樹
- 25. 如何在matlab中存儲和檢索多個決策樹
- 26. 修剪C++決策樹
- 27. Weka軟件決策樹
- 28. 快速排序決策樹
- 29. 與sklearn決策樹圖
- 30. 使用決策樹的熵
我已經用過去的派對,它是相當不錯的。以下是我的一個項目中使用示例的鏈接:https://github.com/fiedukow/SejMOWaKlasyfikacja/blob/master/prediction_models.r – Yester
我已標記此問題以關閉。我認爲這主要是基於意見的,因爲*更好*可以取決於幾個因素,甚至是關於編程風格的個人品味。 – SabDeM