Support Vector Machines in R
Kailash Awati
Instructor
ggplot()
.drink_samples
dataframe.# Specify dataframe, set plot aesthetics in geom_point (note y = 0) p <- ggplot(drink_samples) + geom_point(aes(sugar_content, 0))
# Label each point with sugar content value, adjust text size and location p <- p + geom_text(aes(sugar_content, 0, label = sugar_content), size = 2.5, vjust = 2, hjust = 0.5) # Display plot p
# Define data frame containing decision boundaries
d_bounds <- data.frame(sep = c(9.1, 9.7))
geom_point()
# Add decision boundaries to previous plot
p <- p +
geom_point(data = d_bounds,
aes(sep, 0),
color = "red",
size = 3) +
geom_text(data = d_bounds,
aes(sep, 0, label = sep),
size = 2.5,
vjust = 2,
hjust = 0.5,
color = "red")
# Display plot
p
# Create data frame with maximal margin separator mm_sep <- data.frame(sep = c((8.8 + 10) / 2))
# Add mm boundary to previous plot p <- p + geom_point(data = mm_sep, aes(sep, 0), color = "blue", size = 4) # Display plot p
Support Vector Machines in R