* サンプルデータ2次元
require(data.table) require(ggplot2) x1 <- rnorm(100) y1 <- rnorm(100) * 0.2 a2 <- rnorm(200) b2 <- rnorm(200) * 0.4 x2 <- a2 * 2 + b2 + 3 y2 <- - a2 + 2 * b2 + 4 D <- data.table( x=c(x1,x2), y=c(y1,y2) ) p <- ggplot(D, aes(x = x, y = y)) p + geom_point(size = 2)
* サンプルデータ6次元
require(data.table) require(ggplot2) require(mvtnorm) T <- data.table( rbind(rmvnorm(200, rep(0, 6), diag(c(5, rep(1,5)))), rmvnorm( 15, c(0, rep(20, 5)), diag(rep(1, 6)))) ) plot(T)
install.packages("mclust")
* テストデータ
require(mclust) C = Mclust(D) summary(C) plot(C)
require(mclust) C2 = Mclust(T) summary(C2) plot(C2)
* iris
require(mclust) C3 = Mclust(iris[,c(1:4)]) summary(C3) plot(C3)
* テストデータ
C$classification C$uncertainty
C2$classification C2$uncertainty
* iris
C3$classification C3$uncertainty
* テストデータ
C$d C$n C$G
C2$d C2$n C2$G
* iris
C3$d C3$n C3$G
* テストデータ
C$parameters$pro C$parameters$mean C$parameters$variance$d C$parameters$variance$G C$parameters$variance$sigma C$parameters$variance$cholsigma
C2$parameters$pro C2$parameters$mean C2$parameters$variance$d C2$parameters$variance$G C2$parameters$variance$sigma C2$parameters$variance$cholsigma
* iris
C3$parameters$pro C3$parameters$mean C3$parameters$variance$d C3$parameters$variance$G C3$parameters$variance$sigma C3$parameters$variance$cholsigma
確認
sd(x1) sd(y1) sd(x2) sd(y2) sqrt( C$parameters$variance$sigma )
* テストデータ
hcTree <- hc(modelName = "VVV", data = D) cl <- hclass(hcTree, c(2,3,4,5)) ## par(pty = "s", mfrow = c(1,1)) clPairs(D, cl=cl[,"2"]) clPairs(D, cl=cl[,"5"])
hcTree <- hc(modelName = "VVV", data = T) cl <- hclass(hcTree, c(2,3,4,5)) ## par(pty = "s", mfrow = c(1,1)) clPairs(T, cl=cl[,"2"]) clPairs(T, cl=cl[,"5"])
* iris
hcTree <- hc(modelName = "VVV", data = iris[,c(1:4)]) cl <- hclass(hcTree,c(2,3,4,5)) ## Not run: par(pty = "s", mfrow = c(1,1)) clPairs(iris[,c(1:4)],cl=cl[,"2"]) clPairs(iris[,c(1:4)],cl=cl[,"5"])
* テストデータ
hcTree <- hc(modelName = "VVV", data = D) cl <- hclass(hcTree, c(2,3,4,5)) par(mfrow = c(1,2)) dimens <- c(1,2) coordProj(D, dimens = dimens, classification=cl[,"2"]) coordProj(D, dimens = dimens, classification=cl[,"5"])
hcTree <- hc(modelName = "VVV", data = T) cl <- hclass(hcTree, c(2,3,4,5)) par(mfrow = c(1,2)) dimens <- c(1,2) coordProj(T, dimens = dimens, classification=cl[,"2"]) coordProj(T, dimens = dimens, classification=cl[,"5"])
* iris
hcTree <- hc(modelName = "VVV", data = iris[,c(1:4)]) cl <- hclass(hcTree, c(2,3,4,5)) par(mfrow = c(1,2)) dimens <- c(1,2) coordProj(iris[,c(1:4)], dimens = dimens, classification=cl[,"2"]) coordProj(iris[,c(1:4)], dimens = dimens, classification=cl[,"5"])
* テストデータ
require(mclust) dens = densityMclust(D) plot(dens) plot(dens, D)
require(mclust) dens = densityMclust(T) plot(dens) plot(dens, T)
* iris
require(mclust) dens = densityMclust(iris[,1:4]) plot(dens) plot(dens, iris[,1:4])
* テストデータ
require(mclust) C = Mclust(D) dens = densityMclust(D) plot(dens) plot(dens, D, col = "grey", points.col = mclust.options()$classPlotColors[C$classification], pch = C$classification)
require(mclust) C2 = Mclust(T) dens = densityMclust(T) plot(dens, T, col = "grey", points.col = mclust.options()$classPlotColors[C2$classification], pch = C2$classification)
* iris
require(mclust) C3 = Mclust(iris[,c(1:4)]) dens = densityMclust(iris[,c(1:4)]) plot(dens, iris[,c(1:4)], col = "grey", points.col = mclust.options()$classPlotColors[C3$classification], pch = C3$classification)
require(mclust) C3 = Mclust(iris[,c(1:4)]) ct <- table(iris$Species, C3$classification) ct