Improved irradiance forecasting ensures precise solar power generation forecasts, resulting in smoother operation of the distribution grid. Empirical models are used to estimate irradiation using a wide range of data and specific national or regional parameters. In contrast, algorithms based on Artificial Intelligence (AI) are becoming increasingly popular and effective for estimating solar irradiance. Although there has been significant development in this area elsewhere, employing an AI model to investigate irradiance in Bangladesh is limited. This research forecasts solar radiation in Bangladesh using ensemble machine-learning models. The meteorological data collected from 32 stations contain maximum temperature, minimum temperature, total rain, humidity, sunshine, wind speed, cloud coverage, and irradiance. Ensemble machine-learning algorithms including Adaboost regression (ABR), gradient-boosting regression (GBR), random forest regression (RFR), and bagging regression (BR) are developed to predict solar irradiance. With the default parameters, the GBR provides the best performance as it has the lowest standard deviation of errors. Then, the important hyperparameters of the GRB are tuned with the grid-search algorithms to further improve the prediction accuracy. On the testing dataset, the optimized GBR has the highest coefficient of determination (R2) performance, with a value of 0.9995. The same approach also has the lowest root mean squared error (0.0007), mean absolute percentage error (0.0052), and mean squared logarithmic error (0.0001), implying superior performance. The absolute error of the prediction lies within a narrow range, indicating good performance. Overall, ensemble machine-learning models are an effective method for forecasting irradiance in Bangladesh. They can attain high accuracy and robustness and give significant information for the assessment of solar energy resources.