A good environment can provide material security for urban development, facilitate the efficient use of energy resources, and attract large amounts of investment, bring technological innovation, and thus promote the pace of urbanization. On the contrary, a bad ecological environment restricts the development of urbanization, and the image, development speed, construction scale, investment environment and resource supply of cities are affected. The purpose of this paper is to study the coordinated development of urban development and nature conservation environment based on machine learning. The ecological city theory and the kinds of machine learning algorithms are analyzed. Among the mutual constraints of urbanization and ecological environment studied by using gray correlation matrix as well as coordination degree, the experimental results show that the unreasonable industrial structure is an important factor causing serious industrial pollution in M city.