Amid escalating urbanization, devising rational commercial space layouts is a critical challenge. Leveraging machine learning, this study uses a Back-propagation (BP) neural network to optimize commercial spaces in Weinan City's central urban area. The results indicate an increased number of commercial facilities with a trend of multi-centered agglomeration and outward expansion. Based on these findings, we propose a strategic framework for rational commercial space development emphasizing aggregation centers, development axes, and spatial guidelines. This strategy provides valuable insights for urban planners in small and medium-sized cities in the Yellow River Basin and metropolitan areas, ultimately showcasing the power of machine learning in enhancing urban planning.