Peer influence, which means that an individual can directly influence his friends to be similar with him, is very important in social network analysis. However, peer influence effects are often confounded with latent homophily caused by unobserved similar characteristics. Scholars have designed randomized experiments or established mathematical models to control the latent homophily to get a more accurate effect of peer influence. However, the randomized experiments cannot utilize the valuable second-hand data and the mathematical models are always complex and time-consuming. In this paper, we propose a novel approach based on machine learning to estimate the peer influence effect. First, we use machine learning or deep learning algorithms to get node embeddings which imply the structural information of the nodes in a social network. Then we use the embeddings to act as a proxy variable of unobserved homophily factors in OLS regression models. To verify the feasibility of our approach, we design a simulation experiment. Finally, we implement our method to an empirical study and find that peer influence exists in online game social networks and using node embeddings as a proxy variable in regression can help estimate a more accurate peer influence effect.