  (Abridged) This paper explores the use of k-means clustering as a tool for
automated unsupervised classification of massive stellar spectral catalogs. The
classification criteria are defined by the data and the algorithm, with no
prior physical framework. We work with a representative set of stellar spectra
associated with the SDSS SEGUE and SEGUE-2 programs. We classify the original
spectra as well as the spectra with the continuum removed. The second set only
contains spectral lines, and it is less dependent on uncertainties of the flux
calibration. The classification of the spectra with continuum renders 16 major
classes. Roughly speaking, stars are split according to their colors, with
enough finesse to distinguish dwarfs from giants of the same effective
temperature, but with difficulties to separate stars with different
metallicities. Overall, there is no one-to-one correspondence between the
classes we derive and the MK types. The classification of spectra without
continuum renders 13 classes, the color separation is not so sharp, but it
distinguishes stars of the same effective temperature and different
metallicities. Some classes thus obtained present a fairly small range of
physical parameters (200 K in effective temperature, 0.25 dex in surface
gravity, and 0.35 dex in metallicity), so that the classification can be used
to estimate the main physical parameters of some stars at a minimum
computational cost. We also analyze the outliers of the classification. Most of
them turn out to be failures of the reduction pipeline, but there are also high
redshift QSOs, multiple stellar systems, dust-reddened stars, galaxies, and,
finally, odd spectra whose nature we have not decipher. The template spectra
representative of the classes are publicly available
(ftp://stars:kmeans@ftp.iac.es).
