Hybrid System Identification: Theory and Algorithms for Learning Switching Models