This paper compares how foreign direct investment (FDI) and digital finance (DFI) are related to regional total factor productivity in China. Using panel data for 31 provinces from 2017 to 2024, we combine a random forest model with GeoTimeShapley decomposition to separate the standalone contributions of the two variables from their interactions with location and time. The interaction terms account for most of their model-based relevance. FDI has a larger contribution, but it is spatially concentrated and varies markedly across years. DFI follows a more gradual pattern and becomes more relevant as digital infrastructure and financial inclusion expand. External capital and domestic digital finance are therefore associated with productivity under different regional and temporal conditions.