This paper presents PCA inversion, a novel application of Principal Compone
nt Analysis to the problem of spectral line inversion, ie. solar/stellar at
mospheric model parameter estimation from spectral lines. For a given type
of spectral line we compute a database of synthetic spectral profiles using
a large number of models. Inversion of an observed profile to obtain an at
mospheric model is equivalent to a problem in pattern recognition, finding
the nearest profile in the synthetic profile database. To reduce dimensiona
lity we use the synthetic data as a PCA training set to decompose each synt
hetic (and observed) profile into a sum of a small number of principal comp
onents, or eigenprofiles. The coefficients of this decomposition can be reg
arded as elements of a low-dimensional eigenfeature vector. The eigenfeatur
es are smooth functions of model parameters, indicating that eigenfeatures
for parameters not in the training set could be easily estimated by interpo
lation. Search for the nearest profile is fast because it is done in the ei
genfeature vector space. We illustrate the method using several types of sy
nthetic spectra: unpolarised intensity profiles of a line formed in a Milne
-Eddington model atmosphere; unpolarised H alpha flux profiles of a line fo
rmed in non-local Thermodynamic Equilibrium in the chromosphere of a cool s
tar; and polarised Stokes parameter profiles of a line split by the Zeeman
effect in the presence of a magnetic field. We also apply PCA to a set of S
tokes data observed in a sunspot region by the High Altitude Observatory Ad
vanced Stokes Polarimeter. PCA inversion is proposed as a fast alternative
to non-linear least squares inversion commonly used for solar magnetic fiel
d measurements based on such Stokes data.