# This file produces a dataset called nuggets.train and nuggets.test # which is much like "nuggets2" from Will Welch's notes Chapt. 1 # It also produces a function "getNuggets" which can produce further test data # # Authors: # R.W. Oldford, 2004 # # # getNuggets <- function (n, prior) {# Get the class labels y <- matrix(rbinom(n, size=1, prob = prior),n,1) x1 <- matrix(apply(y,1,function(class) {if (class==0) (if (runif(1,0,1) < 1/3) runif(1,0,0.5) else runif(1, 0.5,1)) else if (runif(1,0,1) < 1/2) runif(1,0,0.4) else runif(1,0.6,0.9) }), n, 1) x2 <- matrix(apply(y,1,function(class) {if (class==0) runif(1,0,1) else if (runif(1,0,1) < 1/2) runif(1,0,0.4) else runif(1,0.6,0.9) }), n, 1) data.frame(x1 = x1, x2 = x2, y = y) } set.seed(5268) nuggets.train <- getNuggets(100, 3/4) nuggets.test <- getNuggets(100, 3/4)