ComeçarComece de graça

Generating a complex dataset - part 2

In this exercise, you will create a decision boundary for the dataset you created in the previous exercise. The boundary consists of two circles of radius 0.8 units with centers at x1 = -0.8, x2 = 0) and (x1 = 0.8, x2 = 0) that just touch each other at the origin. Define a binary classification variable y such that points that lie within either of the circles have y = -1 and those that lie outside both circle have y = 1.

The dataset created in the previous exercise is available in the dataframe df.

Este exercício faz parte do curso

Support Vector Machines in R

Ver curso

Instruções do exercício

  • Set radii and centers of circles.
  • Add a column to df containing the binary classification variable y.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

#set radius and centers
radius <- ___
center_1 <- c(___, ___)
center_2 <- c(___, ___)
radius_squared <- radius^2

#create binary classification variable
df$y <- factor(ifelse((df$x1-center_1[___])^2 + (df$x2-center_1[___])^2 < radius_squared|
                      (df$x1-center_2[___])^2 + (df$x2-center_2[___])^2 < radius_squared, ___, ___),
                      levels = c(-1, 1))
Editar e executar o código