Learn R Programming

ClusterR (version 1.3.3)

predict_GMM: Prediction function for a Gaussian Mixture Model object

Description

Prediction function for a Gaussian Mixture Model object

Usage

predict_GMM(data, CENTROIDS, COVARIANCE, WEIGHTS)

# S3 method for GMMCluster predict(object, newdata, ...)

Value

a list consisting of the log-likelihoods, cluster probabilities and cluster labels.

Arguments

data

matrix or data frame

CENTROIDS

matrix or data frame containing the centroids (means), stored as row vectors

COVARIANCE

matrix or data frame containing the diagonal covariance matrices, stored as row vectors

WEIGHTS

vector containing the weights

object, newdata, ...

arguments for the `predict` generic

Author

Lampros Mouselimis

Details

This function takes the centroids, covariance matrix and weights from a trained model and returns the log-likelihoods, cluster probabilities and cluster labels for new data.

Examples

Run this code

data(dietary_survey_IBS)

dat = as.matrix(dietary_survey_IBS[, -ncol(dietary_survey_IBS)])

dat = center_scale(dat)

gmm = GMM(dat, 2, "maha_dist", "random_subset", 10, 10)

# pr = predict_GMM(dat, gmm$centroids, gmm$covariance_matrices, gmm$weights)

Run the code above in your browser using DataLab