It was to explore the effect of the CT and X-ray examinations before the hip replacement to predict the collapse of the necrotic femoral head under the classification of medical big data based on the decision tree algorithm of the difference grey wolf optimization (GWO) and provide a more effective examination basis for the treatment of patients with the osteonecrosis of the femoral head (ONFH). From January 2019 to January 2021, a total of 152,000 patients with ONFH and hip replacement in the tertiary hospitals were enrolled in this study. They were randomly divided into two groups, the study sample-X group (X-ray examination results) and based-CT group (CT examination results)—76,000 cases in each group. The actual measurement results of the femoral head form the gold standard to evaluate the effect of the two groups of detection methods. The measurement results of X-ray and CT before hip replacement are highly consistent with the detection results of the physical femoral head specimens, which can effectively predict the collapse of ONFH and carry out accurate staging. It is worthy of clinical promotion.