Visualizing transformed radially separable data
In this exercise you will transform the radially separable dataset you created earlier in this chapter and visualize it in the x1^2-x2^2
plane. As a reminder, the separation boundary for the data is the circle x1^2 + x2^2 = 0.64
(radius = 0.8 units). The dataset has been loaded for you in the dataframe df
.
This exercise is part of the course
Support Vector Machines in R
Exercise instructions
- Transform data to x1^2-x2^2 plane.
- Visualize data in terms of transformed coordinates.
- Add a boundary that is linear in terms of transformed coordinates.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
#transform data
df1 <- data.frame(x1sq = df$x1^2, x2sq = ___, y = df$y)
#plot data points in the transformed space
plot_transformed <- ggplot(data = df1, aes(x = ___, y = x___, color = y)) +
geom_point()+ guides(color = "none") +
scale_color_manual(values = c("red", "blue"))
#add decision boundary and visualize
plot_decision <- plot_transformed + geom_abline(slope = -1, intercept = ___)
plot_decision