With flexible learning, students are actively engaged in their own education and are held to high standards of performance. Online academic courses make it easier for students to receive personalized education because they provide students with more flexibility to concentrate on what is most important to them and give them greater control over their own education. This study’s objective was to investigate whether there is a correlation between how well students succeed in online classes and the extent to which they make use of the schedule and the geographical and resource flexibility offered by such programmes. This article uses a developing approach for predicting and classifying the flexibility in online learning of students who are at risk of failing due to academic and demographic variables. The K-nearest neighbours (KNN) method, the random forest (RF) method, and the logistic regression method were used to categorise the students participating in flexible online learning. The information for the dataset came from Kaggle, and it was gathered for use in testing machine learning. The dataset had a total of 1,875 instances representing 11 different features. Also, accuracy, precision, sensitivity and f-score metrics were applied to evaluate the system. The results show that the RF algorithm has a high accuracy percentage of 85%. The empirical findings demonstrate that students formed distinct patterns of learning time, location and access to knowledge. This suggests that flexibility was used to a significant degree. Patterns in learning time and the availability of learning materials were shown to have a substantial relationship with the accomplishments of the students. Understanding flexibility use habits may help adapt lessons and boost collaboration among similar students.