  We use persistent homology and persistence images as an observable of three
different variants of the two-dimensional XY model in order to identify and
study their phase transitions. We examine models with the classical XY action,
a topological lattice action, and an action with an additional nematic term. In
particular, we introduce a new way of computing the persistent homology of
lattice spin model configurations and, by considering the fluctuations in the
output of logistic regression and k-nearest neighbours models trained on
persistence images, we develop a methodology to extract estimates of the
critical temperature and the critical exponent of the correlation length. We
put particular emphasis on finite-size scaling behaviour and producing
estimates with quantifiable error. For each model we successfully identify its
phase transition(s) and are able to get an accurate determination of the
critical temperatures and critical exponents of the correlation length.
