% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/machine_learning.R
\name{predict_diagram_kkmeans}
\alias{predict_diagram_kkmeans}
\title{Predict the cluster labels for new persistence diagrams using a pre-computed clustering.}
\usage{
predict_diagram_kkmeans(
  new_diagrams,
  clustering,
  num_workers = parallelly::availableCores(omit = 1)
)
}
\arguments{
\item{new_diagrams}{a list of persistence diagrams which are either the output of a persistent homology calculation like \code{\link[TDA]{ripsDiag}}/\code{\link[TDAstats]{calculate_homology}}/\code{\link{PyH}}, or \code{\link{diagram_to_df}}.}

\item{clustering}{the output of a \code{\link{diagram_kkmeans}} function call.}

\item{num_workers}{the number of cores used for parallel computation, default is one less than the number of cores on the machine.}
}
\value{
a vector of the predicted cluster labels for the new diagrams.
}
\description{
Returns the nearest (highest kernel value) \code{\link[kernlab]{kkmeans}} cluster center label for new persistence diagrams.
This allows for reusing old cluster models for new tasks, or to perform cross validation.
}
\examples{

# create two diagrams
D1 <- TDAstats::calculate_homology(TDA::circleUnif(n = 10,r = 1),
                                   dim = 0,threshold = 2)
D2 <- TDAstats::calculate_homology(TDA::circleUnif(n = 10,r = 1),
                                   dim = 0,threshold = 2)
g <- list(D1,D1,D2,D2)

# calculate kmeans clusters with centers = 2, and sigma = t = 2 in dimension 0
clust <- diagram_kkmeans(diagrams = g,centers = 2,dim = 0,t = 2,sigma = 2,num_workers = 2)

# create two new diagrams
D4 <- TDAstats::calculate_homology(TDA::circleUnif(n = 10,r = 1),
                                   dim = 0,threshold = 2)
D5 <- TDAstats::calculate_homology(TDA::circleUnif(n = 10,r = 1),
                                   dim = 0,threshold = 2)
g_new <- list(D4,D5)

# predict cluster labels
predict_diagram_kkmeans(new_diagrams = g_new,clustering = clust,num_workers = 2)
}
\seealso{
\code{\link{diagram_kkmeans}} for clustering persistence diagrams.
}
\author{
Shael Brown - \email{shaelebrown@gmail.com}
}
