Piezoresistive pressure sensors have broad applications but often face accuracy challenges due to temperature-induced drift. Traditional compensation methods based on discrete data, such as polynomial interpolation, support vector machine (SVM), and artificial neural network (ANN), overlook the thermal hysteresis, resulting in lower accuracy. Considering the sequence-dependent nature of temperature drift, we propose the RF-IWOA-GRU temperature compensation model. Random forest (RF) is used to interpolate missing values in continuous data. A combination of gated recurrent unit (GRU) networks and an improved whale optimization algorithm (IWOA) is employed for temperature compensation. This model leverages the memory capability of GRU and the optimization efficiency of the IWOA to enhance the accuracy and stability of the pressure sensors. To validate the compensation method, experiments were designed under continuous variations in temperature and actual pressure. The experimental results show that the compensation capability of the proposed RF-IWOA-GRU model significantly outperforms that of traditional methods. After compensation, the standard deviation of pressure decreased from 10.18 kPa to 1.14 kPa, and the mean absolute error and root mean squared error were reduced by 75.10% and 76.15%, respectively.