The mud weight window (MW) determination is one of the most important parameters in drilling oil and gas wells, where accurate design can secure the drilled well and deliver a stable borehole. In this paper, novel algorithms based on the most influential set of input features are developed to predict pore pressure, including rate of penetration (ROP), deep resistivity (ILD), density (RHOB), photoelectric index (PEF), corrected gamma ray (CGR), compression-wave velocity (Vp), weight on bit (WOB), shear-wave velocity (Vs) and pore compressibility (Cp). The algorithms used in this study are as follows: 1) machine learning algorithms (ML), these are the K-nearest neighbor (KNN) algorithm, weighted K-Nearest Neighbor (WKKNN), and distance weighted KNN (DWKNN); 2) hybrid machine learning algorithms (HML), which include the combination of three ML with particle swarm optimization (PSO) (KNN-PSO, WKNN-PSO and DWKNN-PSO). The 2875-record dataset used in this study was collected from three wells (S1, S2 and S3) in one of the gas reservoirs (Tabnak field) in Iran. After comparing the performance accuracy of all algorithms, DWKNN-PSO has the best performance accuracy compared to other algorithms presented in this paper (for the total dataset of wells S1 and S2: R2=0.9656 and RMSE = 12.6773 psi). Finally, the generalizability of the best predictive algorithm for PP, DWKNN-PSO, is evaluated by testing the proposed algorithm on an unseen dataset from another well (S3) in the field under study, where the DWKNN-PSO algorithm provides PP predictions in well S3 with high accuracy, R2 = 0.9765 and RMSE = 9.7545 psi, confirming its ability to be used in PP prediction in the studied field.