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. R中的決策樹公式
- 5. R中決策樹的參數
- 6. 如何計算決策樹
- 7. 如何設置決策樹
- 8. 如何存儲決策樹
- 9. 決策樹在樹決策中保持使用Y變量
- 10. 如何在MS Bot Framework上做決策樹?
- 11. 如何根據R中的決策樹模型測試數據?
- 12. 如何縮小r studio中的決策樹圖?
- 13. 無法在R中使用「派對」包實施決策樹。怎麼做?
- 14. J48決策樹
- 15. 決策樹jQuery
- 16. 如何在我用C構建決策樹時存儲決策樹?
- 17. 決策樹。噪聲策略
- 18. 由Weka在決策樹中運行R中的統計測試
- 19. Adaboost決策樹/樹樁
- 20. 如何在決策樹中使用rpart決定'minsplit'?
- 21. 在R中使用tm和rpart:文本數據的決策樹?
- 22. 解析決策樹(來自WEKA分類器)在R中繪圖?
- 23. 決策樹問題解決
- 24. 決策樹:細化
- 25. 決策樹結果
- 26. weka決策樹java
- 27. 建模決策樹
- 28. 決策樹修剪
- 29. 修剪決策樹
- 30. Python決策樹GraphViz
我已經用過去的派對,它是相當不錯的。以下是我的一個項目中使用示例的鏈接:https://github.com/fiedukow/SejMOWaKlasyfikacja/blob/master/prediction_models.r – Yester
我已標記此問題以關閉。我認爲這主要是基於意見的,因爲*更好*可以取決於幾個因素,甚至是關於編程風格的個人品味。 – SabDeM