| Line 27... |
Line 27... |
| 27 |
initial (distinct) cluster centres. If a number, a random set of
|
27 |
initial (distinct) cluster centres. If a number, a random set of
|
| 28 |
(distinct) rows in \code{x} is chosen as the initial centres.}
|
28 |
(distinct) rows in \code{x} is chosen as the initial centres.}
|
| 29 |
\item{iter.max}{the maximum number of iterations allowed.}
|
29 |
\item{iter.max}{the maximum number of iterations allowed.}
|
| 30 |
\item{nstart}{if \code{centers} is a number, how many random sets
|
30 |
\item{nstart}{if \code{centers} is a number, how many random sets
|
| 31 |
should be chosen?}
|
31 |
should be chosen?}
|
| 32 |
\item{algorithm}{character: may be abbreviated.}
|
32 |
\item{algorithm}{character: may be abbreviated. Note that
|
| - |
|
33 |
\code{"Lloyd"} and \code{"Forgy"} and alternative names for one
|
| - |
|
34 |
algorithm.}
|
| 33 |
\item{object}{an \R object of class \code{"kmeans"}, typically the
|
35 |
\item{object}{an \R object of class \code{"kmeans"}, typically the
|
| 34 |
result \code{ob} of \code{ob <- kmeans(..)}.}
|
36 |
result \code{ob} of \code{ob <- kmeans(..)}.}
|
| 35 |
\item{method}{character: may be abbreviated. \code{"centers"} causes
|
37 |
\item{method}{character: may be abbreviated. \code{"centers"} causes
|
| 36 |
\code{fitted} to return cluster centers (one for each input point) and
|
38 |
\code{fitted} to return cluster centers (one for each input point) and
|
| 37 |
\code{"classes"} causes \code{fitted} to return a vector of class
|
39 |
\code{"classes"} causes \code{fitted} to return a vector of class
|
| Line 76... |
Line 78... |
| 76 |
A vector of integers (from \code{1:k}) indicating the cluster to
|
78 |
A vector of integers (from \code{1:k}) indicating the cluster to
|
| 77 |
which each point is allocated.
|
79 |
which each point is allocated.
|
| 78 |
}
|
80 |
}
|
| 79 |
\item{centers}{A matrix of cluster centres.}
|
81 |
\item{centers}{A matrix of cluster centres.}
|
| 80 |
\item{totss}{The total sum of squares.}
|
82 |
\item{totss}{The total sum of squares.}
|
| 81 |
\item{withinss}{Vector of within-cluster sum of squares, one component per cluster.}
|
83 |
\item{withinss}{Vector of within-cluster sum of squares,
|
| - |
|
84 |
one component per cluster.}
|
| 82 |
\item{tot.withinss}{Total within-cluster sum of squares, i.e., \code{sum(withinss)}.}
|
85 |
\item{tot.withinss}{Total within-cluster sum of squares,
|
| - |
|
86 |
i.e., \code{sum(withinss)}.}
|
| 83 |
\item{betweenss}{The between-cluster sum of squares, i.e. \code{totss-tot.withinss}.}
|
87 |
\item{betweenss}{The between-cluster sum of squares,
|
| - |
|
88 |
i.e. \code{totss-tot.withinss}.}
|
| 84 |
\item{size}{The number of points in each cluster.}
|
89 |
\item{size}{The number of points in each cluster.}
|
| 85 |
\item{iter}{The number of (outer) iterations.}
|
90 |
\item{iter}{The number of (outer) iterations.}
|
| 86 |
\item{ifault}{possibly an algorithm problem indicator for experts.}
|
91 |
\item{ifault}{integer: indicator of a possible algorithm problem
|
| - |
|
92 |
-- for experts.}
|
| 87 |
}
|
93 |
}
|
| 88 |
\references{
|
94 |
\references{
|
| 89 |
Forgy, E. W. (1965) Cluster analysis of multivariate data:
|
95 |
Forgy, E. W. (1965) Cluster analysis of multivariate data:
|
| 90 |
efficiency vs interpretability of classifications.
|
96 |
efficiency vs interpretability of classifications.
|
| 91 |
\emph{Biometrics} \bold{21}, 768--769.
|
97 |
\emph{Biometrics} \bold{21}, 768--769.
|
| Line 139... |
Line 145... |
| 139 |
## random starts do help here with too many clusters
|
145 |
## random starts do help here with too many clusters
|
| 140 |
## (and are often recommended anyway!):
|
146 |
## (and are often recommended anyway!):
|
| 141 |
(cl <- kmeans(x, 5, nstart = 25))
|
147 |
(cl <- kmeans(x, 5, nstart = 25))
|
| 142 |
plot(x, col = cl$cluster)
|
148 |
plot(x, col = cl$cluster)
|
| 143 |
points(cl$centers, col = 1:5, pch = 8)
|
149 |
points(cl$centers, col = 1:5, pch = 8)
|
| 144 |
|
- |
|
| 145 |
## Artificial example [was "infinite loop" on x86_64; PR#15364]
|
- |
|
| 146 |
rr <- c(rep(-0.4, 5), rep(-0.4- 1.11e-16, 14), -.5)
|
- |
|
| 147 |
r. <- signif(rr, 12)
|
- |
|
| 148 |
try ( k3 <- kmeans(rr, 3, trace=2) ) ## Warning: Quick-Transfer.. steps exceed
|
- |
|
| 149 |
try ( k. <- kmeans(r., 3) ) # after rounding, have only two distinct points
|
- |
|
| 150 |
k. <- kmeans(r., 2) # fine
|
- |
|
| 151 |
}
|
150 |
}
|
| 152 |
\keyword{multivariate}
|
151 |
\keyword{multivariate}
|
| 153 |
\keyword{cluster}
|
152 |
\keyword{cluster}
|