From the course: Spatial Machine Learning and Statistics in Python
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Applying the k-means clustering algorithm - Python Tutorial
From the course: Spatial Machine Learning and Statistics in Python
Applying the k-means clustering algorithm
- [Instructor] After DBSCAN, now we are going to learn about a clustering technique called K-Means. K-Means is a so-called centroid-based clustering algorithm that partitions the data into a given number of K clusters where each cluster is represented by the mean or the centroid of its points. K-Means start by distributing K clusters at random and then assigning each point to one of the centroids. Then it is going to compute the new centroids based on the center of mass of the current clusters, and then based on that, will update the location of the centroids. The algorithm keeps iteratively repeating these steps until the final location of the centroids converge. Now let's move on to the Python terminal and see how we can do this in practice. Here again, we are going to use the usual European dataset and the coordinates' new binary features prepared for DBSCAN in the previous video. Then we also import the KMeans function from the sklearn library, and then quickly do the function…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.