#============================== # Create synthetic classes #============================== create.synthetic <- function(data.size) { # Set up samples X <- runif(data.size, -1, 1) Y <- runif(data.size, -1, 1) data <- cbind(X,Y) # create an array of them # Set the target values tp <- matrix(0, data.size, 8) tp[,1] <- (X[]>=0)*1 # 1 LHP, 0 otherwise tp[,2] <- (X[]*Y[]>=0)*1 # 1 1st&4th Quad, 0 otherwise tp[,3] <- (X[]>=0)*1+ (X[]>=0 & Y[]>=0)*1 # 2 1st Quad, 1, 4th quad, 0 otherwise tp[,4] <- (X[]>=-Y[])*1 # 1 to right of y = -x, 0 otherwise tp[,5] <- (X[]>=-Y[])&(X[]>=Y[])|(X[]<=-Y[])&(X[]<=Y[])*1 # tp[,6] <- (X[]>=-Y[])*1+ ((X[]>=-Y[]) & X[]>=Y[])*1 # rotated 2 1st Quad, 1, 4th quad, 0 otherwise tp[,7] <- (X[]^2+Y[]^2>=.25)*1 # 1 to right of y = -x, 0 otherwise tp[,8] <- (Y[]>=X[]^2+.25)*1 # 1 to above of y = x^2, 0 otherwise return(list(tp, data)) }