## General

CEC aims to efficiently implement Cross Entropy Clustering Algorithm as R extension.

More about CEC in the paper: Tabor, J., & Spurek, P. (2014). Cross-entropy clustering. Pattern Recognition, 47(9), 3046-3059.

## Simple demo

``````library(devtools)
library('gmum.r')

data(cec_mouse_1_spherical)
dataset = input``````

That is the dataset we want to cluster:

``plot(dataset)`` Run cec with default parameters. Set number of clusters and dataset:

``````c <- CEC(k=3, x=dataset)
plot(c)`````` Since initial clusterization is random. It may be a good idea to run cec multiple times and choose the best result:

``````c <- CEC(k=3, x=dataset, control.nstart=10)
plot(c)`````` Better than before, however, we know that clusters are spherical; let’s inform cec about that:

``````c <- CEC(k=3, x=dataset, control.nstart=10, method.type='sphere')
plot(c)`````` You can learn details of clustering like this:

``centers(c)``
``````# Output of centers(c)
[]
 1.957193 1.974472

[]
 0.03909274 0.02175208

[]
 -2.012686  2.016024``````
``covMatrix(c)``
``````# Output of covMatrix(c)
[]
  0.254579374 -0.007326478 -0.007326478  0.258511736

[]
  1.00163190 -0.02665602 -0.02665602  0.99577141

[]
 0.2548147 0.0119440 0.0119440 0.2425556``````

You can predict cluster which a point would belong to:

``predict(c, c(1,1))``

You can visualise size and shape of clusters:

``plot(c, ellipses=TRUE)`` Try the same with random assignment:

``````c <- CEC(k=3, x=dataset, control.nstart=10, method.type='sphere', method.init='random')
plot(c)`````` 