
Cluster spherical observations using a mixture of Poisson kernel-based densities
Source:R/clustering_functions.R
predict.pkbc.RdObtain predictions of membership for spherical observations based on a
mixture of Poisson kernel-based densities estimated by pkbc
Usage
# S4 method for class 'pkbc'
predict(object, k, newdata = NULL)Value
Returns a list with the following components
Memb: vector of predicted memberships of
newdataProbs: matrix where entry (i,j) denotes the probability that observation i belongs to the k-th cluster.
Examples
# generate data
dat <- rbind(matrix(rnorm(100), ncol = 2), matrix(rnorm(100, 5), ncol = 2))
res <- pkbc(dat, 2)
# extract membership of dat
predict(res, k = 2)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1
#> [38] 1 1 2 2 1 1 1 1 1 2 1 1 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
#> [75] 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
# predict membership of new data
newdat <- rbind(matrix(rnorm(10), ncol = 2), matrix(rnorm(10, 5), ncol = 2))
predict(res, k = 2, newdat)
#> $Memb
#> [1] 2 1 1 1 1 2 2 2 2 2
#>
#> $Probs
#> [,1] [,2]
#> [1,] 0.19565742 0.80434258
#> [2,] 0.96607103 0.03392897
#> [3,] 0.94966743 0.05033257
#> [4,] 0.63318436 0.36681564
#> [5,] 0.95972637 0.04027363
#> [6,] 0.09664861 0.90335139
#> [7,] 0.03520711 0.96479289
#> [8,] 0.16335367 0.83664633
#> [9,] 0.03340081 0.96659919
#> [10,] 0.06562115 0.93437885
#>