Predict Mixture Membership
Arguments
- object
A fitted
shoal_gmm()model.- newdata
A numeric matrix or data frame with the same columns as the data the model was fitted to. Omit it to return the training assignment.
- type
"class"(default) for the most likely component, or"posterior"for the fulln x kmatrix of responsibilities.- ...
Ignored.
Examples
fit <- shoal_gmm(as.matrix(iris[1:100, 1:4]), k = 2L)
predict(fit, as.matrix(iris[101:150, 1:4]))
#> [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [39] 2 2 2 2 2 2 2 2 2 2 2 2
head(predict(fit, type = "posterior"))
#> [,1] [,2]
#> [1,] 1 1.533810e-26
#> [2,] 1 3.345318e-19
#> [3,] 1 5.977894e-22
#> [4,] 1 3.633872e-19
#> [5,] 1 9.938109e-28
#> [6,] 1 4.480187e-27
