This study delves into the emerging opportunities and challenges arising from the integration of education and artificial intelligence in the unique backdrop of the COVID-19 pandemic. Its primary objective is to develop an optimized ensemble model that sheds light on the surge in learning engagement among secondary school students during Emergency Distance Learning (EDL) amid the pandemic. To achieve this, we explored three distinct methodologies: the k-Nearest Neighbor method (KNN), Random Forest (RF), and Gradient Boosting (XGB). Our approach involved constructing an ensemble model that synthesized the strengths and weaknesses of these individual models based on their training outcomes. In contrast to prevailing beliefs that Emergency Distance Learning (EDL) negatively impacts education, our study's findings underscore a positive upswing in students' learning activity during EDL. Furthermore, our ensemble model effectively identifies the underlying reasons behind this increased engagement, achieving an impressive overall accuracy rate of 87% in processing the survey responses. Our research encompassed a comprehensive sample, targeting 35,950 secondary school students from 16 regions and cities of significant importance within Kazakhstan. This diverse sample included students from urban, rural, and small schools, providing a well-rounded perspective on territorial affiliation. Data collection was conducted through an online survey using a methodologically verified structured questionnaire.