Predictive and generative machine learning models for photonic crystals