0% found this document useful (0 votes)
21 views1 page

Contoh Kode R untuk Model Pohon

Uploaded by

Sulton Aulia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Contoh Kode R untuk Model Pohon

Uploaded by

Sulton Aulia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Contoh Kode R

```r
# Install package (jika belum ada)
# [Link]("rpart")
# [Link]("[Link]")
# [Link]("caret")

library(rpart)
library([Link])
library(caret)

data(iris)

[Link](123)
indeks <- createDataPartition(iris$Species, p = 0.7, list = FALSE)
train_data <- iris[indeks, ]
test_data <- iris[-indeks, ]

model_tree <- rpart(Species ~ ., data = train_data, method = "class")

print(model_tree)
[Link](model_tree, type = 3, extra = 104, [Link] = TRUE)

prediksi <- predict(model_tree, newdata = test_data, type = "class")

conf_matrix <- confusionMatrix(prediksi, test_data$Species)


print(conf_matrix)
```

You might also like