Practical 6: Practical Implementation of Decision Tree using R Tool
Step1: install.packages("party")
Step2:
# Load the party package. It will automatically load other dependent
packages.
library(party)
# Print some records from data set readingSkills.
print(head(readingSkills))
Step3:
# Load the party package. It will automatically load other dependent
packages.
library(party)
# Create the input data frame.
input.dat <- readingSkills[c(1:105),]
# Give the chart file a name.
png(file = "decision_tree.png")
# Create the tree.
output.tree <- ctree(
nativeSpeaker ~ age + shoeSize + score,
data = input.dat)
# Plot the tree.
plot(output.tree)
# Save the file.
dev.off()
Comments
Post a Comment