Code and demonstration data for the paper, "On-the-fly closed-loop materials discovery via Bayesian active learning," Kusne, A.G., Yu, H., Wu, C. et al. Nat Commun 11, 5966 (2020). https://doi.org/10.1038/s41467-020 19597-w Code: Closed-loop autonomous materials exploration and optimization. This code is used to control an autonomous materials exploration and optimization platform. It guides subsequent experiments to learn about a material's phase map and target functional properties in a unified framework. Data: CAMEO code is demonstrated on Fe-Ga-Pd composition spread X-ray diffraction data.