Professional Documents
Culture Documents
FMLASS3Q7 - Jupyter Notebook
FMLASS3Q7 - Jupyter Notebook
In [51]: df
localhost:8888/notebooks/FMLASS3Q7.ipynb 1/6
10/18/23, 10:41 PM FMLASS3Q7 - Jupyter Notebook
In [54]: agglo_cluster_single=AgglomerativeClustering(n_clusters=3,metric='euclidean
agglo_cluster_single.fit(X)
In [55]: plot_clusters(X,agglo_cluster_single.labels_,title_cluster="Agglomerative C
In [56]: agglo_cluster_comp=AgglomerativeClustering(n_clusters=3,metric='euclidean',
agglo_cluster_comp.fit(X)
localhost:8888/notebooks/FMLASS3Q7.ipynb 2/6
10/18/23, 10:41 PM FMLASS3Q7 - Jupyter Notebook
In [58]: agglo_cluster_avg=AgglomerativeClustering(n_clusters=3,metric='euclidean',l
agglo_cluster_avg.fit(X)
localhost:8888/notebooks/FMLASS3Q7.ipynb 3/6
10/18/23, 10:41 PM FMLASS3Q7 - Jupyter Notebook
localhost:8888/notebooks/FMLASS3Q7.ipynb 4/6
10/18/23, 10:41 PM FMLASS3Q7 - Jupyter Notebook
localhost:8888/notebooks/FMLASS3Q7.ipynb 5/6
10/18/23, 10:41 PM FMLASS3Q7 - Jupyter Notebook
Use cases
The choice of linkage method depends on the specific application. Single linkage is often
used in anomaly detection, as it can identify outliers that are connected to other data points
by a chain of similar data points. Complete linkage is often used in image segmentation, as
it can produce compact clusters. Average linkage is a general-purpose linkage method that
is often used in a variety of applications.
In the context of the Online Retail data, the average linkage dendrogram appears to be the
most informative. It shows that the customers are grouped into three distinct clusters, with
each cluster having a different purchasing behavior. For example, one cluster may consist
of customers who frequently purchase large quantities of low-priced items, while another
cluster may consist of customers who infrequently purchase high-priced items.
localhost:8888/notebooks/FMLASS3Q7.ipynb 6/6