Description Usage Arguments Value See Also Examples
View source: R/FLXMCLmajority.R
This is a model driver for flexmix
from package flexmix implementing mixtures of majority classifiers.
1 2 3 4 5 |
formula |
A formula which is interpreted relative to the formula specified in the call to |
... |
Further arguments to and from other methods. |
Returns an object of class FLXMCLmajority
inheriting from FLXMCL
.
Other mixtures majority: FLXMCL-class
,
FLXMCLmajorityGenerative
Other mixtures majority: FLXMCL-class
,
FLXMCLmajorityGenerative
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(benchData)
data <- flashData(1000)
data$x <- scale(data$x)
grid <- expand.grid(x.1=seq(-6,6,0.2), x.2=seq(-4,4,0.2))
cluster <- kmeans(data$x, center = 4)$cluster
model <- FLXMCLmajority()
fit <- flexmix(y ~ ., data = as.data.frame(data), concomitant = FLXPmultinom(~ x.1 + x.2), model = model, cluster = cluster)
## prediction with aggregation depending on membership in mixture components
pred.grid <- mypredict(fit, newdata = grid, aggregate = TRUE)
image(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))))
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(pred.grid[[1]][,1], length(seq(-6,6,0.2))), add = TRUE)
points(data$x, pch = as.character(data$y))
## local membership
loc.grid <- prior(fit, newdata = grid)
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(loc.grid[,1], length(seq(-6,6,0.2))), add = TRUE)
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(loc.grid[,2], length(seq(-6,6,0.2))), add = TRUE)
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(loc.grid[,3], length(seq(-6,6,0.2))), add = TRUE)
contour(seq(-6,6,0.2), seq(-4,4,0.2), matrix(loc.grid[,4], length(seq(-6,6,0.2))), add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.