Shrinkage greatly influences the mechanical and fatigue properties of compacted graphite iron and it is necessary in order to study the causes of shrinkage in compacted graphite iron and to predict it effectively. In this paper, a kind of cylindrical necking test sample was designed to evaluate the shrinkage in compacted graphite iron, and a method to calculate the size of shrinkage was proposed. By observing the microstructure around the shrinkage zone, it is concluded that concentrated shrinkage mainly appears in the solidification region where the dendritic gap is closed, and the isolated shrinkage mainly occurs in the final solidification region, and the supersaturated carbon elements are gathered on the surface of the shrinkage. The cause of shrinkage in compacted graphite iron is caused by its solidification method, where the austenite dendrites and the eutectic clusters are generated close to the melt zone during the solidification process, leading to the inability to feed the shrinkage. Based on the thermodynamic analysis, the equations between the volume change of each phase, solid phase rate, and time during solidification of compacted graphite iron were established to theoretically explain the formation mechanism of the shrinkage. Taking nine parameters such as the chemical elements and characteristic values of thermal analysis as the input nods, a four-layer BP neural network model for predicting the size of shrinkage in compacted graphite iron was constructed, and the R-squared of the model reached 97%, which indicates it could be used to predict the shrinkage tendency.