The main purpose of this study was to explore major factors at student and teacher/school levels affecting middle-school students’ science self-efficacy among countries with high science academic performance levels in PISA 2015 data by using various regression algorithms of machine learning and multilevel latent profile analysis (MLPA). Out of total of 195 (110 at the student-level and 75 at the teacher/school-level), 88 at the student-level and 38 at the teacher/school-level explanatory variables were finally selected after data pre-processing. Through over 20 regression analysis algorithms of machine learning, 10 variables at the student-level and five variables at the teacher/school-level were found to be significant predictors, consistent with previous studies. Next, MLPA was applied to classify underlying science self-efficacy sub-groups at each level and verify the statistical significance of variables affecting science self-efficacy, chosen from the machine learning. Three classes at the student-level (low, moderate, high) and two at the teacher/school-level (mid-low, mid-high) were selected as the optimal number of latent profiles. At the student-level, students with higher environmental awareness, science activities, interest in broad science topics, instrumental motivation, test anxiety, and achieving motivation were more likely to belong to the moderate or high groups than the low group. At the teacher/school-level, the mid-high group had more considerable science-specific resources, higher instructional leadership, a larger student-teacher ratio, and more science teachers than mid-low group. Finally, the significance of the study was presented, and implications for increasing science self-efficacy in middle school students were suggested.