Performs parameter estimation by means of the Expectation-Maximization (EM) algorithm and cluster allocation for the Mixture of Unigrams.
mou_EM(x, k, n_it = 100, eps = 1e-07, seed_choice = 1, init = NULL)
Document-term matrix describing the frequency of terms that occur in a collection of documents. Rows correspond to documents in the collection and columns correspond to terms.
Number of clusters/groups.
Number of iterations for the Expectation-Maximization algorithm.
Tolerance level for the convergence of the algorithm. Default is 1e-07
.
Set seed for reproducible results
Vector containing the initial document allocations for the initialization of the algorithm. If NULL (default) initialization is carried out via spherical k-means (skmeans).
A list containing the following elements:
The data matrix.
the clustering labels.
the number of clusters.
the sample size.
the vocabulary size.
vector containing the likelihood values at each iteration.
estimated probabilities of belonging to the k
clusters.
matrix containing the estimates of the omega parameters for each cluster.
matrix containing the posterior probabilities of belonging to each cluster.
Akaike Information Criterion (AIC) value of the fitted model.
Bayesian Information Criterion (BIC) value of the fitted model.
Starting from the data given by x
the Mixture of Unigrams is fitted
and k
clusters are obtained.
The algorithm for the parameter estimation is the Expectation-Maximization (EM).
In particular, the function assigns initial values to weights of the Multinomial distribution for each cluster
and inital weights for the components of the mixture. The estimates are obtained with maximum n_it
steps of the
EM algorithm or until the tolerance level eps
is reached; by using the posterior distribution
of the latent variable z, the documents are allocated to the cluster which maximizes the
posterior distribution.
For further details see the references.
Nigam, K., McCallum, A., Thrun, S., Mitchell, T.: Text classification from labeled and unlabeled documents using EM. Machine learning 39, 103-134 (2000).
# NOT RUN {
# Load the CNAE2 dataset
data("CNAE2")
# Perform parameter estimation and clustering
mou_CNAE2 = mou_EM(x = CNAE2, k = 2)
# Shows cluster labels to documents
mou_CNAE2$clusters
# }
Run the code above in your browser using DataLab