This paper considers the problem of sensor node localization, where a total of n anchor nodes are used to determine the locations of other nodes based on the received signal strengths. Challenges arise when anchor nodes are sparse and locations of them are not at grid positions. A range-based machine learning algorithm is developed to tackle the challenges. Instead of using samples to calibrate the parameters of a chosen signal model, we use machine learning to estimate the signal propagation function and its parameters at the same time. It overcomes the model dependency issue of existing range-based algorithms, and avoids the insufficient support issue of support vector machine methods. Simulation results show that the proposed algorithm has good adaptability to different signal characteristics, network deployment, and device variability. It significantly outperforms existing methods, especially when the anchor nodes are sparsely and irregularly deployed.