  The ability to measure differences in collected data is of fundamental
importance for quantitative science and machine learning, motivating the
establishment of metrics grounded in physical principles. In this study, we
focus on the development of such metrics for viscoelastic fluid flows governed
by a large class of linear and nonlinear stress models. To do this, we
introduce a kernel function corresponding to a given viscoelastic stress model
that implicitly embeds flowfield snapshots into a Reproducing Kernel Hilbert
Space (RKHS) whose squared norm equals the total mechanical energy. Working
implicitly with lifted representations in the RKHS via the kernel function
provides natural and unambiguous metrics for distances and angles between
flowfields without the need for hyperparameter tuning. Additionally, we present
a solution to the preimage problem for our kernels, enabling accurate
reconstruction of flowfields from their RKHS representations. Through numerical
experiments on an unsteady viscoelastic lid-driven cavity flow, we demonstrate
the utility of our kernels for extracting energetically-dominant coherent
structures in viscoelastic flows across a range of Reynolds and Weissenberg
numbers. Specifically, the features extracted by Kernel Principal Component
Analysis (KPCA) of flowfield snapshots using our kernel functions yield
reconstructions with superior accuracy in terms of mechanical energy compared
to conventional methods such as ordinary Principal Component Analysis (PCA)
with na\"ively-defined state vectors or KPCA with ad-hoc choices of kernel
functions. Our findings underscore the importance of principled choices of
metrics in both scientific and machine learning investigations of complex fluid
systems.
