The sloshing-induced impact loads on the tank wall are significant when the liquid in a tank is excited at and around its natural frequencies, which are highly reliant on the tank's geometry and liquid fill level. Herein, To design the optimal porous baffle for mitigation of liquid sloshing, a machine learning algorithm based on the MLPR model is adopted. First, a sloshing database comprising of different features such as porosity, baffle arrangement, submergence depth of the baffle, motion period, and free-surface elevation at the tank wall is prepared from the sloshing experiments in a swaying rectangular tank with the vertical porous baffle. Then, the detailed feature study is conducted on the database. The MLPR model is trained and validated after preprocessing the data, and the predictions on the free-surface elevation are made for 3520 combinations of feature values using the trained model. A comparison with the available experimental data shows that a well-trained machine learning model can predict well the physical characteristics that occurred in a sloshing tank. A fully submerged single baffle with a porosity of 0.1375 is obtained as the optimal baffle. It reduces significantly the liquid sloshing at resonance, especially the first-mode resonance peak, compared to the no-baffle tank.