show_IMIFA_digit: Plot the posterior mean image

show_IMIFA_digitR Documentation

Plot the posterior mean image

Description

Plots the posterior mean of a given cluster from an "IMIFA"-related model fit to a digit data set in the form of a square grayscale grid.

Usage

show_IMIFA_digit(res,
                 G = 1,
                 what = c("mean", "last"),
                 dat = NULL,
                 ind = NULL,
                 ...)

Arguments

res

An object of class "Results_IMIFA" generated by get_IMIFA_results.

G

The index of the cluster for which the posterior mean digit is to be represented.

what

A switch controlling whether the "mean" or "last" valid sample is to be plotted.

dat

The full grayscale grid data set (prior to centering and scaling). Necessary when ind is supplied or if pixels with standard deviation of 0 exist in the data set (which will have been automatically removed by mcmc_IMIFA).

ind

The index of columns of dat which were discarded prior to fitting the "IMIFA"-related model via mcmc_IMIFA. Can be a vector of column indices of dat or an equivalent vector of logicals. The discarded pixels are replaced by the column-means corresponding to ind among images assigned to the given cluster G.

...

Additional arguments to be passed, via show_digit, to mat2cols and/or plot_cols.

Details

This function is a wrapper to show_digit which supplies the posterior mean digit of a given cluster from a "IMIFA" model.

Value

The desired image representation of the posterior mean digit (or the last valid sample) from the desired cluster.

Note

Note that both centering and scaling of the original data prior to modelling is accounted for in reconstructing the means, but dat, if necessary, must be the raw data prior to pre-processing.

Author(s)

Keefe Murphy - <keefe.murphy@mu.ie>

See Also

USPSdigits, show_digit, get_IMIFA_results, mcmc_IMIFA, mat2cols, plot_cols

Examples

# Load the USPS data and discard peripheral digits
data(USPSdigits)
ylab  <- USPSdigits$train[,1]
train <- USPSdigits$train[,-1]
ind   <- apply(train, 2, sd) > 0.7
dat   <- train[,ind]

# Fit an IMIFA model (warning: quite slow!)
# sim <- mcmc_IMIFA(dat, n.iters=1000, prec.mu=1e-03, z.init="kmeans",
#                   centering=FALSE, scaling="none")
# res <- get_IMIFA_results(sim, zlabels=ylab)

# Examine the posterior mean image of the first two clusters
# show_IMIFA_digit(res, dat=train, ind=ind)
# show_IMIFA_digit(res, dat=train, ind=ind, G=2)

Keefe-Murphy/IMIFA documentation built on Jan. 31, 2024, 2:15 p.m.