This study aims to provide an efficient and accurate machine-learning approach for modelling and forecasting the real gross domestic production (GDP) in the context of Pakistan. The study forecasts Pakistan's GDP growth rate using different forecasting models, such as naïve, seasonal naïve (SNaive), smoothing, and k-nearest neighbors (k-NN). Machine learning algorithms provide additional advice for data-driven decision-making. According to the findings, the k-NN-based forecasting gives minimum mean absolute percentage error (MAPE), root mean square error (RMSE), and mean absolute error (MAE) compared to the other three models. Economic policymakers can use accurate models to measure significant economic activity and formulate plans. The results indicate that the model produced accurate projections of future GDP levels for Pakistan.