% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gmeans.R
\name{predict.gmeans}
\alias{predict.gmeans}
\title{Predict Method for G-means Clustering}
\source{
Adapted from \CRANpkg{clue}
}
\usage{
\method{predict}{gmeans}(
  object,
  newdata,
  method = c("euclidean", "manhattan", "minkowski"),
  p = 2,
  ...
)
}
\arguments{
\item{object}{(\code{gmeans()})\cr
An object of class \code{"gmeans"}.}

\item{newdata}{(\code{matrix()})\cr
New data to predict on.}

\item{method}{(\code{character(1)})\cr
Distance metric to use.
Either \code{"euclidean"}, \code{"manhattan"}, or \code{"minkowski"}. Default is \code{"euclidean"}.}

\item{p}{(\code{numeric(1)})\cr
Power of the Minkowski distance. Default is \code{2}.}

\item{...}{(\code{any})\cr
Additional arguments.}
}
\value{
An \code{integer()} vector with one cluster index per row of \code{newdata}.
}
\description{
Predicted values based on the G-means clustering model.
}
\details{
The \code{predict} method for G-means clustering assigns new data points to the nearest
cluster center identified by the G-means algorithm. The method uses the specified
distance metric to calculate the distance between each new data point and all
cluster centers, and then assigns each point to the cluster with the closest center.

The \code{method} argument specifies the distance metric to use. The following options:
\itemize{
\item \code{"euclidean"}: The Euclidean distance is the default metric used in the k-means
and is defined as \deqn{
    d(x, y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2}
  }
\item \code{"manhattan"}: The Manhattan distance is defined as \deqn{
    d(x, y) = \sum_{i=1}^{n} |x_i - y_i|
  }
\item \code{"minkowski"}: The Minkowski distance is defined as \deqn{
    d(x, y) = \left( \sum_{i=1}^{n} |x_i - y_i|^p \right)^{1/p},
  }
where \eqn{p} is a parameter that defines the distance type (e.g., \eqn{p=2}
for Euclidean, \eqn{p=1} for Manhattan).
}
}
\examples{
set.seed(123)
x <- as.matrix(iris[, -5])
cl <- gmeans(x)

newdata <- x[1:10, ]
predict(cl, newdata)
}
\seealso{
\code{\link[clue:cl_predict]{clue::cl_predict()}} to predict on a plain \code{\link[stats:kmeans]{stats::kmeans()}} object.
}
