Mastering Unsupervised Learning offers several benefits and expands your skills in the field of machine learning:
By mastering Unsupervised Learning and specifically k-Means Clustering, you will unlock new possibilities for data exploration, pattern discovery, and knowledge extraction from unlabeled data.
Machine Learning is often divided into 3 main categories.
Where we see that Unsupervised is one of the main groups.
Unsupervised learning is a type of algorithm that learns patterns from untagged data. The hope is that through mimicry, which is an important mode of learning in people, the machine is forced to build a compact internal representation of its world and then generate imaginative content from it. In contrast to supervised learning where data is tagged by an expert, e.g. as a “ball” or “fish”, unsupervised methods exhibit self-organization that captures patterns as probability densities…
https://en.wikipedia.org/wiki/Unsupervised_learning
What is clustering?
Organize a set of objects into groups in such a way that similar objects tend to be in the same group.
What is k-Means Clustering?
Algorithm for clustering data based on repeatedly assigning points to clusters and updating those clusters’ centers.
This can be repeated a specific number of times or until only small change in centroids positions.
Let’s create some random data to demonstrate it.
import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
# Generate some numbers
data = np.random.randn(400,2)
data[:100] += 5, 5
data[100:200] += 10, 10
data[200:300] += 10, 5
data[300:] += 5, 10
fig, ax = plt.subplots()
ax.scatter(x=data[:,0], y=data[:,1])
plt.show()
This shows some random data in 4 clusters.
Then the following code demonstrates how it works. You can change max_iter to be the number iteration – try to do it for 1, 2, 3, etc.
model = KMeans(n_clusters=4, init='random', random_state=42, max_iter=10, n_init=1)
model.fit(data)
y_pred = model.predict(data)
fig, ax = plt.subplots()
ax.scatter(x=data[:,0], y=data[:,1], c=y_pred)
ax.scatter(x=model.cluster_centers_[:,0], y=model.cluster_centers_[:,1], c='r')
plt.show()
In the next lesson you will learn about Artificial Neural Network.
This is part of a FREE 10h Machine Learning course with Python.
Build and Deploy an AI App with Python Flask, OpenAI API, and Google Cloud: In…
Python REST APIs with gcloud Serverless In the fast-paced world of application development, building robust…
App Development with Python using Docker Are you an aspiring app developer looking to level…
Why Value-driven Data Science is the Key to Your Success In the world of data…
Harnessing the Power of Project-Based Learning and Python for Machine Learning Mastery In today's data-driven…
Is Python the right choice for Machine Learning? Should you learn Python for Machine Learning?…