Abstract The electrification of rural communities is crucial from both social and economic perspectives, aligned with Sustainable Development Goal 7: “Affordable and Clean Energy”. This study presents a comprehensive comparison of clustering techniques, including k-means, Gaussian Mixture Models (GMM), Hierarchical Clustering, Density-based Spatial Clustering of Applications with Noise (DBSCAN), and Agglomerative Clustering, aimed at enhancing solar irradiance prediction. Leveraging historical climate data from a rural community in the coastal region of Ecuador, each technique is evaluated using error metrics such as Mean Absolute Error (MAE) and Coefficient of Determination R2. This assessment identifies the most effective clustering technique in this specific context. In order to delve deeper into these comparisons, simulations are conducted in AMPL to validate and refine the selection of techniques. In this process, it is considered the sizing and design of a microgrid within the Barcelona community, Ecuador, which integrates various energy sources, including solar. Additionally, a penalty system is introduced for unmet energy demands during less critical periods, thereby optimizing efficiency and enhancing energy availability within the community. In conclusion, this paper introduces a scalable methodology to improve solar irradiance prediction, emphasizing the significance of comparing clustering techniques as its main contribution. This advancement in prediction accuracy has the potential to enhance the feasibility and efficiency of renewable energy systems for rural communities, thereby fostering sustainable economic growth and bolstering efforts in climate change mitigation and adaptation.