The knowledge of phase diagrams is crucial to understand materials and to design new ones with better properties. However, elucidating phase diagrams is a difficult task, both experimentally and theoretically. In this work, we address the problem of predicting phase diagrams and crystal structures using a data-driven approach. We used machine learning methods to predict the stable phases using composition, temperature, and pressure extracted from a set of diagrams contained in the NIST database. We used the extracted data to train machine learning algorithms to predict the stable phases and the chemical formula of the stable compounds, including structural features such as Bravais lattices, crystal types, and the local atomic environments of the inorganic compounds contained in the ICSD database. The computationally efficient data-driven methods presented in this paper will aid material scientists in estimating the structure of virtually any mixture of elements in any proportion over a wide temperature range.