To improve the utilization of new energy sources and reduce economic costs, a micro-grid dispatching model based on new energy prediction with P2G is proposed. This paper consists of two stages. The first stage is to optimize the model of support vector machine using particle swarm algorithm to predict the data of wind power and photovoltaic power generation based on several influence factors. The second stage is to use the data of wind power and PV output in the first stage and put them into the micro-grid model of this paper for optimal dispatching. This stage is solved by using CPLEX+YALMIP and divided into three scenarios for comparative analysis. The conclusion is that the micro-grid containing P2G has effectively improves the economy and the capacity of consuming renewable energy. The bi-layer optimization of this paper, with the first stage improving accuracy and the second stage optimizing dispatch, not only greatly promotes the smooth and reliable operation of micro-grids, but also reflects the systematic nature of micro-grid modelling.