The asymmetry in the flow of events that is expressed by the phrase time s arrow traces back to the second law of thermodynamics. In the microscopic regime, fluctuations prevent us from discerning the direction of time s arrow with certainty. Here, we find that a machine learning algorithm that is trained to infer the direction of time s arrow identifies entropy production as the relevant physical quantity in its decision-making process. Effectively, the algorithm rediscovers the fluctuation theorem as the underlying thermodynamic principle. Our results indicate that machine learning techniques can be used to study systems that are out of equilibrium, and ultimately to answer open questions and uncover physical principles in thermodynamics. The phrase arrow of time refers to the asymmetry in the flow of events. A machine learning algorithm trained to infer its direction identifies entropy production as the relevant underlying physical principle in the decision-making process.