Ef fi ciently measuring a quantum device using machine learning