Temperature, Humidity, and Weather Prediction Using Random Forest and LSTM for Food Crop Cultivation Optimization in Tegal
Abstract
The agricultural sector in the Tegal region faces uncertain climate fluctuations that directly impact food crop productivity. A crucial indicator for determining plant environmental comfort is the Temperature Humidity Index (THI). This research aims to develop a hybrid model capable of predicting and classifying future THI values to support precision decision-making for farmers. The methodology utilized historical climate data including Temperature humidity, rainfall, sunshine, and wind speed from the Tegal Maritime Meteorology Station spanning a 10-year period (2016-2025). A Long Short-Term Memory (LSTM) model was applied to forecast future THI values, while a Random Forest (RF) model was utilized to classify plant stress categories. Model performance was evaluated using Root Mean Square Error (RMSE), Accuracy, and F1-score. The results indicate that Tegal experiences comfortable (24 ≤ THI < 27), moderately comfortable (27 ≤ THI < 30), and uncomfortable (THI ≥ 30) conditions, particularly during dry and transitional seasons. The LSTM model achieved a 98.42% prediction accuracy, and the RF model reached a 99.59% classification accuracy. In conclusion, this highly accurate model can serve as an early warning system, providing farmers with actionable recommendations for optimal planting schedules and stress mitigation.