Machine Learning of Combinatorial Rules in Mechanical Metamaterials