Precision in the measurement of glucose levels in the artificial pancreas is a challenging task and a mandatory requirement for the proper functioning of an artificial pancreas. A suitable machine learning (ML) technique for the measurement of glucose levels in an artificial pancreas may play a crucial role in the management of diabetes. Therefore in the present work, a comparison has been made among a few ML techniques for the measurement of glucose levels in the artificial pancreas because ML is an astounding technology of artificial intelligence and widely applicable in various fields such as medical science, robotics, and environmental science. The models, namely, decision tree (DT), random forest (RF), support vector machine (SVM), and K‐nearest neighbor (KNN), based on supervised learning, are proposed for the dataset of Pima Indian to predict and classify diabetes mellitus. Ensuring the predictions and accuracy up to the level of diabetes mellitus type 2 (DMT2), the comparative behavior of all four models has been discussed. The ML models developed here stratify and predict whether an individual is diabetic or not based on the features available in the dataset. The dataset passes through pre‐processing, and ML algorithms are fitted to train the dataset, and then the performance of the test results is discussed. An error matrix (EM) has been generated to measure the accuracy score of the models. The accuracies in the prediction and classification of DMT2 models are 71%, 77%, 78%, and 80% for DT, SVM, RF, and KNN algorithms, respectively. The KNN model has shown a more precise result in comparison to other models. The proposed methods have shown astounding behavior in terms of accuracy in the prediction of diabetes mellitus as compared to previously developed methods.