Machine learning (ML) is more and more used to address the challenges of managing the physical layer of increasingly heterogeneous and complex optical networks. In this tutorial, we illustrate how simple and more sophisticated machine learning methods can be used in lightpath quality of transmission (QoT) estimation and forecast tasks. We also discuss data processing strategies with the aim to determine relevant features to feed the ML classifiers and predictors. We then introduce a preliminary study on the application of transfer learning to try to overcome the scarcity of field data.