k-means clustering is a very popular Machine Learning algorithm used for categorizing data into distinct groups of observations. The method…