Piezo actuators are widely used in ultra-precision fields because of their high response and nano-scale step length. However, their hysteresis characteristics seriously affect the accuracy and stability of piezo actuators. Existing methods for fitting hysteresis loops include operator class, differential equation class, and machine learning class. The modeling cost of operator class and differential equation class methods is high, the model complexity is high, and the process of machine learning, such as neural network calculation, is opaque. The physical model framework cannot be directly extracted. Therefore, the sparse identification of nonlinear dynamics (SINDy) algorithm is proposed to fit hysteresis loops. Furthermore, the SINDy algorithm is improved. While the SINDy algorithm builds an orthogonal candidate database for modeling, the sparse regression model is simplified, and the Relay operator is introduced for piecewise fitting to solve the distortion problem of the SINDy algorithm fitting singularities. The Relay-SINDy algorithm proposed in this paper is applied to fitting hysteresis loops. Good performance is obtained with the experimental results of open and closed loops. Compared with the existing methods, the modeling cost and model complexity are reduced, and the modeling accuracy of the hysteresis loop is improved.