Unsupervised learning of phase transitions: from principal component analysis to variational autoencoders