Improving educational quality is a universal concern. Despite efforts made in this regard, learning outcomes have not improved sufficiently. Therefore, further investigation is needed on this issue, adopting new perspectives (conceptual and analytical) to facilitate the understanding and design of effective actions. The objective of this study was to determine the influence of executive functions (considering both cognitive and affective processes) and their interactions on learning outcomes in Language and Literature and Mathematics in Spanish students, through the use of artificial intelligence, based on the machine learning approach, and more specifically, the decision tree technique. A total of 173 students in compulsory secondary education (12-17 years old) from the same educational institution participated. The school's educational counsellor provided information on student executive function levels by completing the BRIEF2 questionnaire for each participant. She also reported on the learning outcomes achieved by students in the subjects of interest for this research (Language and Literature and Mathematics). R software was used to model the regression trees. The results revealed groups of students characterised by different profiles, i.e., by different combinations of difficulties in various executive functions and varying levels of learning outcomes in each academic area. However, regardless of the academic area considered (Language and Literature or Mathematics), working memory was identified as the most relevant executive function in all of the students' learning outcomes. Understanding the combination of executive functions that predict learning outcomes in each group of students is important since it enables teachers and other educational professionals, policymakers and researchers to provide individualised educational resources according to the diverse student profiles and needs. It constitutes an effective mechanism to improve students' learning results and, ultimately, to enhance an equitable and more effective educational system.