Due to the toxicity, bioaccumulation, non-biodegradability and perseverance of heavy metals, their risk assessment is essential for soil quality management. The Hakanson potential ecological risk index (RI), which considers the effects of heavy metal concentration and toxicity, has been widely used in soil ecological risk assessment. However, RI overlooks the influence of soil properties on the mobility and availability of heavy metals in risk assessment. To fill this gap, this study sought to develop an improved ecological risk index (IRI), which incorporates soil adsorption into RI, and applied it to evaluate the ecological risk of heavy metals in the soil of the Taihu basin, China. The soil adsorption models based on the Gradient Boosting Decision Tree (GBDT) was used to predict the soil adsorption capacity of five heavy metals (i.e. cadmium, chromium, copper, lead, zinc). The soil adsorption capacity in 1446 sites in the Taihu basin was predicted by the GBDT models and was assigned as the weight of IRI. The risk assessment results of the five metals in the Taihu basin showed that 40% of the sites were at a moderate risk level and 60% of the sites were at a slight risk level based on the RI. The value of IRI in the basin ranged from 11.1 to 75.5, with a mean value of 28.1. IRI differed from RI in spatial distribution due to the influence of soil adsorption. The comparative analysis between the metal contents in sediments and surrounding soils confirmed the tremendous influence of soil adsorption on ecological risks, indicating that soil adsorption should be taken into consideration in soil risk assessment.