Skip to content

Instantly share code, notes, and snippets.

@lundquist-ecology-lab
Last active January 16, 2023 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lundquist-ecology-lab/10dd9b7b8ab62da98e81d05598b1c4fb to your computer and use it in GitHub Desktop.
Save lundquist-ecology-lab/10dd9b7b8ab62da98e81d05598b1c4fb to your computer and use it in GitHub Desktop.
Decision tree using the Iris datas in R
library(rpart)
# Load data
data <- iris
# Build decision tree
fit <- rpart(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = data, method = "class")
# Plot the decision tree
library(rpart.plot)
rpart.plot(fit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment