The classical XY model has been consistently studied since it was introduced more than six decades ago. Of particular interest has been the two-dimensional spin model's exhibition of the Berezinskii-Kosterlitz-Thouless (BKT) transition. This topological phenomenon describes the transition from bound vortex-antivortex pairs at low temperatures to unpaired or isolated vortices and antivortices above some critical temperature. In this work we propose a machine learning based method to determine the emergence of this phase transition. Generating unique states can be difficult due to the U(1) symmetry present. We introduce an auxiliary field (analogous to a vortex density field) corresponding to a given state in order to eliminate the unwanted symmetry. An autoencoder was used to map these auxiliary fields into a lower-dimensional latent space. Samples were taken from this latent space to determine the thermal average of the vortex density, which was then used to determine the critical temperature of the phase transition.