Improving the accuracy of weather prediction, especially rainfall, is very important in various sectors such as agriculture, water resource management, and disaster mitigation. This research aims to optimize the Long Short-Term Memory (LSTM) model in rainfall prediction through the application of hyperparameter optimization using two main techniques: Grid Search and Bayesian Optimization (Optuna). This hyperparameter optimization includes finding the best configuration of important parameters, such as the number of LSTM units, batch size, learning rate, and number of epochs. A historical rainfall dataset from BMKG is used, which is then divided into training and test data to build and test the prediction model. Grid Search performs a thorough exploration of all possible parameter combinations, while Optuna uses a probabilistic Bayesian approach to speed up the optimization process. The results show that hyperparameter optimization significantly improves the performance of LSTM models. The model optimized with Optuna produces a Mean Squared Error (MSE) value of 0.179578 with an execution time of 105.26 seconds, while Grid Search has an MSE of 0.286778 with an execution time of 457.69 seconds. The lower MSE value indicates that the Optuna model has a smaller prediction error, making it more accurate in predicting rainfall. The faster execution time of Optuna also confirms its efficiency in finding the optimal hyperparameter configuration compared to Grid Search. The conclusion of this study confirms that hyperparameter optimization plays an important role in improving the prediction accuracy of LSTM for rainfall. The developed method is expected to be the basis for the development of other weather prediction models as well as support decision-making in various sectors that rely on weather prediction. In addition, this research opens up opportunities for further studies in the optimization of deep learning models in handling complex climate data.