Rice is a strategic commodity in ensuring national food security in Indonesia. Predicting rice productivity is a critical issue due to the decreasing harvest area and fluctuating production. This study aims to develop and compare the performance of two machine learning algorithms, namely Extreme Gradient Boosting (XGBoost) and Random Forest, in predicting rice productivity based on harvest area and total production data. The dataset consists of rice productivity data from 38 provinces in Indonesia over the period 2018 to 2024. The models were evaluated using three data splitting ratios (70:30, 80:20, and 90:10) and four evaluation metrics: Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Squared Error (RMSE), and Coefficient of Determination (R²). The results show that both models perform well, with Random Forest achieving the highest R² value of 0.887 and the lowest RMSE of 2.939 on the 90:10 split, indicating higher accuracy. XGBoost, while slightly lower in accuracy (R² = 0.781), produced more stable predictions across varying input scales. When tested on new data, both models showed consistent performance, demonstrating generalization capabilities. These findings indicate that machine learning models are effective in modeling and forecasting agricultural productivity and can serve as decision-support tools for policymakers and agricultural stakeholders. The models can be utilized for strategic planning, resource allocation, and improving agricultural productivity in the future.