Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Support Vector Machines in R

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

#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
Code bewerken en uitvoeren