Harnessing the recent advance in data science and materials science, it is feasible today to build predictive models for materials properties. In this study, we employ the data of high-throughput quantum mechanics calculations based on 170,714 inorganic crystalline compounds to train a machine learning model for formation energy prediction. Different from the previous work, our model reaches a fairly good predictive ability (R2=0.982 and MAE=0.07 eVatom-1, DenseNet model) and meanwhile can be universally applied to the large phase space of inorganic materials. The improvement comes from several effective structure-dependent descriptors that are proposed to take the information of electronegativity and structure into account. This model can provide a useful tool to search for new materials in a vast phase space in a fast and cost-effective manner.