Machine learning approaches are explored to predict the bandgaps of inorganic compounds using known compositional features, based on a dataset of 3,896 compounds with experimentally measured bandgaps. Particularly among various existing methods, we propose a new method, random forest with Gaussian process model as leaf nodes (RF-GP), and show its advantages. We have also investigated ensemble learning methods, which produce superior results to other traditional machine learning methods, but at the cost of extra computational load and further reduced interpretability.