require(datanugget)
require(rstiefel)
#2-d small example with visualization
X = rbind.data.frame(matrix(rnorm(10^4, sd = 0.3), ncol = 2),
matrix(rnorm(10^4, mean = 1, sd = 0.3), ncol = 2))
#create data nuggets
my.DN = create.DN(x = X,
R = 500,
delete.percent = .1,
DN.num1 = 500,
DN.num2 = 250,
no.cores = 0,
make.pbs = FALSE)
#refine data nuggets
my.DN2 = refine.DN(x = X,
DN = my.DN,
EV.tol = .9,
min.nugget.size = 2,
max.splits = 5,
no.cores = 0,
make.pbs = FALSE)
#get nugget centers, weights, and scales
nugg = my.DN2$`Data Nuggets`[,2:(ncol(X)+1)]
weight = my.DN2$`Data Nuggets`$Weight
scale = my.DN2$`Data Nuggets`$Scale
#plot raw large dataset
plot(X)
#plot data nuggets in 2-dim space
plotNugg(nugg,weight)
#generate a random projection vector to 1-dim space
proj_1d = rustiefel(2, 1)
#project data nugget centers into 1-dim space by the random projection vector
nuggproj_1d = as.matrix(nugg)%*%proj_1d
#plot the stripchart for 1-dim projected data nuggets
plotNugg(nuggproj_1d,weight)
#plot the weighted histogram for 1-dim projected data nuggets
plotNugg(nuggproj_1d,weight,hist = TRUE)
Run the code above in your browser using DataLab