Establishing a mathematical model to predict and compensate for the thermal error of CNC machine tools is a commonly used approach. Most existing methods, especially those based on deep learning algorithms, have complicated models that need huge amounts of training data and lack interpretability. Therefore, this paper proposes a regularized regression algorithm for thermal error modeling, which has a simple structure that can be easily implemented in practice and has good interpretability. In addition, automatic temperature-sensitive variable selection is realized. Specifically, the least absolute regression method combined with two regularization techniques is used to establish the thermal error prediction model. The prediction effects are compared with state-of-the-art algorithms, including deep-learning-based algorithms. Comparison of the results shows that the proposed method has the best prediction accuracy and robustness. Finally, compensation experiments with the established model are conducted and prove the effectiveness of the proposed modeling method.