The unique electronic configuration endows carbon with super-flexible bonding ability, displaying metallic, semi-conducting and insulating features with unprecedented applications. Inspired by the pressure–temperature phase diagram that clearly shows the phases (solid/liquid/gas) of a substance in different conditions, for the first time, we have derived the electronic ‘phase diagram’ using machine learning that can discover complex rules and invisible relationships among multi-variables. Based on SACADA database with 522 three-dimensional carbon allotropes, electronic band gap is studied by using support vector machine, decision tree and multiple-layer perception algorithms. It is identified that density and bond angle are two key factors in determining the electronic phase diagram for distinguishing metallic, semiconducting, and insulating carbon phases, where density relates to bond length and coordination number, while bond angle relates to orbital orientations, both together determine the overlap of wave functions between different orbitals.