predictionMetrics {predkmeans}R Documentation

Measures of Prediction Performance

Description

Computes several measures of performance for cluster label prediction.

Usage

predictionMetrics(centers, cluster.pred, X, labels = TRUE)

Arguments

centers

Matrix of Cluster centers

cluster.pred

Vector of predicted cluster membership. Should be integers or names corresponding to rows of centers.

X

Matrix of observations at prediction locations.

labels

Logical indicating whether cluster prediction and

Value

A list with the following elements:

MSPE

Mean squared prediction error. Sum of squared distances between observations and predicted cluster centers.

wSS

Within-cluster sum-of-squares. Sum of squared distances between observations at prediction locations and best (i.e. closest) cluster center.

MSME

Mean squared misclassification error. Sum of squared distances between predicted cluster center and best (i.e. closest) cluster center.

pred.acc

Proportion of cluster labels correctly predicted.

cluster.pred

Predicted cluster assignments (same as argument provided).

cluster.assign

Integer vector of 'best' cluster assignments (i.e. assignment to closest cluster center)

Author(s)

Joshua Keller

References

Keller, J.P., Drton, M., Larson, T., Kaufman, J.D., Sandler, D.P., and Szpiro, A.A. (2017). Covariate-adaptive clustering of exposures for air pollution epidemiology cohorts. Annals of Applied Statistics, 11(1):93–113.

See Also

predictML

Examples

n <- 100
d <- 5 # Dimension of exposure
K <- 3 # Number of clusters
X <- matrix(rnorm(n*d), ncol=d, nrow=n)
centers <- matrix(runif(d*K), nrow=K, ncol=d)
cluster_pred <- sample(1:K, size=n, replace=TRUE)
metrics <- predictionMetrics(centers, cluster.pred=cluster_pred, X=X)
metrics[c("MSPE", "wSS", "MSME", "pred.acc")]

[Package predkmeans version 0.1.1 Index]