{"id":201216,"date":"2024-01-18T11:57:38","date_gmt":"2024-01-18T16:57:38","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=201216"},"modified":"2024-01-18T11:57:08","modified_gmt":"2024-01-18T16:57:08","slug":"hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/","title":{"rendered":"Hierarchical Clustering in Python: A Comprehensive Implementation Guide &#8211; Part I"},"content":{"rendered":"\n<p><em>Author: Updated by Chainika Thakar (Originally written by Vibhu Singh)<\/em><\/p>\n\n\n\n<p>Hierarchical clustering is a powerful technique in the realm of data analysis and pattern recognition, offering a nuanced understanding of the relationships within datasets. This comprehensive guide delves into the intricacies of hierarchical clustering, specifically tailored for implementation in Python.<\/p>\n\n\n\n<p>As the volume of raw data continues to increase rapidly, the prominence of unsupervised learning has grown. The primary objective of unsupervised learning is to unveil latent and intriguing patterns within unannotated datasets. Clustering stands out as the predominant algorithm in unsupervised learning, with applications spanning diverse domains\u2014from medical diagnostics and facial recognition to stock market analysis. This blog specifically explores the intricacies of Hierarchical Clustering.<\/p>\n\n\n\n<p>By the end of this guide, readers will not only have a robust grasp of the theory behind hierarchical clustering but will also be equipped to apply this knowledge effectively using Python, ensuring a seamless integration of this powerful analytical tool into their data science toolkit.<\/p>\n\n\n\n<p>This blog covers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What is hierarchical clustering?<\/li>\n\n\n\n<li>Example of hierarchical clustering<\/li>\n\n\n\n<li>Difference between clustering and classification<\/li>\n\n\n\n<li>Importance of K-Means in hierarchical clustering<\/li>\n\n\n\n<li>Difference between K-means clustering and hierarchical clustering<\/li>\n\n\n\n<li>Key concepts of hierarchical clustering<\/li>\n\n\n\n<li>How to identify if two clusters are similar?<\/li>\n\n\n\n<li>What is a dendrogram?<\/li>\n\n\n\n<li>Types of hierarchical clustering<\/li>\n\n\n\n<li>Agglomerative hierarchical clustering<\/li>\n\n\n\n<li>Divisive hierarchical clustering<\/li>\n\n\n\n<li>How to do hierarchical clustering in Python?<\/li>\n\n\n\n<li>Pros of hierarchical clustering in trading<\/li>\n\n\n\n<li>Cons of hierarchical clustering in trading<\/li>\n\n\n\n<li>Applications of hierarchical clustering<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-hierarchical-clustering\">What is hierarchical clustering?<\/h2>\n\n\n\n<p>Hierarchical clustering is a technique in&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/unsupervised-learning\/\">unsupervised machine learning<\/a>&nbsp;that involves the organisation of data into a hierarchy of nested clusters. Unlike other clustering methods, hierarchical clustering creates a tree-like structure of clusters (dendrogram), which visually represents the relationships between data points.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can check out this introductory video on&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/startCourseDetails\/?cid=219&amp;section_no=8&amp;unit_no=1&amp;preview=true&amp;course_type=paid&amp;unit_type=Video\">hierarchical clustering<\/a>&nbsp;which is a free preview. This link will be accessible only after logging into the&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/\">Quantra website<\/a>.<\/li>\n\n\n\n<li>Further, you can enroll into our course on&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/course\/portfolio-management-machine-learning\">portfolio management using machine learning<\/a>. In this course, starting from the video on \u201c<a href=\"https:\/\/quantra.quantinsti.com\/startCourseDetails?cid=219&amp;section_no=8&amp;unit_no=4&amp;course_type=paid&amp;unit_type=Video\">hierarchical clustering on stocks<\/a>\u201d in Section 8, unit 4 you shall get help with further learning about the implementation of hierarchical clustering in the trading domain.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example-of-hierarchical-clustering\">Example of hierarchical clustering<\/h2>\n\n\n\n<p>In the realm of portfolio creation, envision a scenario where we seek to evaluate stock performance. Employing hierarchical clustering allows us to group akin stocks based on performance similarities, creating clusters grounded in shared financial traits like volatility, earnings growth, and price-to-earnings ratio.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"difference-between-clustering-and-classification\">Difference between clustering and classification<\/h2>\n\n\n\n<p>Both classification and clustering try to group the data points into one or more classes based on the similarity of various features. The difference lies in the way both works.<\/p>\n\n\n\n<p>Classification is a supervised algorithm, where there are predefined labels (yi) assigned to each input data point (Xi).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Classification-quantinsti.png\" alt=\"\" class=\"wp-image-201218 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Whereas, clustering is an unsupervised algorithm where labels are missing meaning the dataset contains only input data points (Xi).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Clustering-quantinsti.png\" alt=\"\" class=\"wp-image-201219 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>The other major difference is since classification techniques have labels, there is a need for training and test datasets to verify the model. In clustering, there are no labels so there is no need for training and test datasets.<\/p>\n\n\n\n<p>Popular examples of classification algorithms are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/quantra.quantinsti.com\/course\/trading-with-machine-learning-regression\">Logistic Regression<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/quantra.quantinsti.com\/course\/trading-machine-learning-classification-svm\">Support Vector Classifier<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/blog.quantinsti.com\/naive-bayes\/\">Naive Bayes<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/quantra.quantinsti.com\/course\/decision-trees-analysis-trading-ernest-chan\">Decision Trees<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/blog.quantinsti.com\/random-forest-algorithm-in-python\/\">Random Forest<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/quantra.quantinsti.com\/course\/neural-networks-deep-learning-trading-ernest-chan\">Neural Networks<\/a><\/li>\n<\/ol>\n\n\n\n<p>Examples of clustering algorithms are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Hierarchical clustering<\/li>\n\n\n\n<li><a href=\"https:\/\/blog.quantinsti.com\/k-means-clustering-pair-selection-python\/\">K-Means Clustering<\/a><\/li>\n\n\n\n<li>Mean Shift Clustering<\/li>\n\n\n\n<li>Spectral Clustering<\/li>\n<\/ol>\n\n\n\n<p>Let us see the difference between hierarchical clustering and classification which is explained briefly in the table below.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Aspect<\/strong><\/td><td><strong>Hierarchical Clustering<\/strong><\/td><td><strong>Classification<\/strong><\/td><\/tr><tr><td>Objective<\/td><td>Groups data points into hierarchical clusters<\/td><td>Assign labels to data points<\/td><\/tr><tr><td>Type of Learning<\/td><td>Unsupervised learning<\/td><td>Supervised learning<\/td><\/tr><tr><td>Training Data<\/td><td>No predefined classes; clusters based on similarity<\/td><td>Requires labelled training data<\/td><\/tr><tr><td>Output<\/td><td>Dendrogram showing hierarchical cluster structure<\/td><td>Predicted class labels for new data<\/td><\/tr><tr><td>Algorithm Goal<\/td><td>Discover inherent structures and relationships<\/td><td>Learn patterns for accurate predictions<\/td><\/tr><tr><td>Usage<\/td><td>Exploratory data analysis; pattern discovery<\/td><td>Predictive modelling; assigning labels<\/td><\/tr><tr><td>Example<\/td><td>Grouping stocks based on price movements<\/td><td>Predicting stock trends as bullish\/bearish<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>In this article, we will deep dive into the details of only hierarchical clustering.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"importance-of-k-means-in-hierarchical-clustering\">Importance of K-Means in Hierarchical Clustering<\/h2>\n\n\n\n<p>The answer to why we need Hierarchical clustering lies in the process of K-means clustering.<\/p>\n\n\n\n<p>We will understand the K-means clustering in a layman&#8217;s language.<\/p>\n\n\n\n<p>Consider this unlabeled data for our problem. Our task is to group the unlabeled data into clusters using K-means clustering.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"484\" height=\"363\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Unlabeled-data-converted-into-clusters-quantinsti.png\" alt=\"\" class=\"wp-image-201220 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Unlabeled-data-converted-into-clusters-quantinsti.png 484w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Unlabeled-data-converted-into-clusters-quantinsti-300x225.png 300w\" data-sizes=\"(max-width: 484px) 100vw, 484px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 484px; aspect-ratio: 484\/363;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1\">Step 1<\/h3>\n\n\n\n<p>The first step is to decide the number of clusters (k). Let\u2019s say we have decided to divide the data into two clusters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2\">Step 2<\/h3>\n\n\n\n<p>Once the clusters are decided, we randomly initialise two points, called the cluster centroids.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"525\" height=\"433\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Clusters-centroid-quantinsti.png\" alt=\"\" class=\"wp-image-201222 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Clusters-centroid-quantinsti.png 525w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Clusters-centroid-quantinsti-300x247.png 300w\" data-sizes=\"(max-width: 525px) 100vw, 525px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 525px; aspect-ratio: 525\/433;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3\">Step 3<\/h3>\n\n\n\n<p>In the third step, the algorithm goes to each of the data points and divides the points into respective classes, depending on whether it is closer to the red cluster centroid or green cluster centroid.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"568\" height=\"451\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Divide-points-2-quantinsti.png\" alt=\"\" class=\"wp-image-201224 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Divide-points-2-quantinsti.png 568w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Divide-points-2-quantinsti-300x238.png 300w\" data-sizes=\"(max-width: 568px) 100vw, 568px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 568px; aspect-ratio: 568\/451;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4\">Step 4<\/h3>\n\n\n\n<p>In the fourth step, we move to the centroid step. We compute the mean of all the red points and move the red cluster centroid there and do the same for the green cluster centroid.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"588\" height=\"453\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Mean-of-red-and-green-cluster-points-quantinsti.png\" alt=\"\" class=\"wp-image-201226 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Mean-of-red-and-green-cluster-points-quantinsti.png 588w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/01\/Mean-of-red-and-green-cluster-points-quantinsti-300x231.png 300w\" data-sizes=\"(max-width: 588px) 100vw, 588px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 588px; aspect-ratio: 588\/453;\" \/><\/figure>\n\n\n\n<p>We will do steps 3 and 4 &nbsp;till the cluster centroid will not move any further. That is in this example, the colours of the point will not change any further.<\/p>\n\n\n\n<p><strong>The K-means process looks good, right?<\/strong><\/p>\n\n\n\n<p>Yes, but there is one problem or we can say the limitation of this process. At the beginning of the algorithm, we need to decide the number of clusters. But we don\u2019t know how many clusters we need at the start.<\/p>\n\n\n\n<p>Hierarchical clustering bridges this gap. In hierarchical clustering, we don\u2019t need to define the number of clusters at the beginning.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p><strong>Difference between K-means clustering and hierarchical clustering<\/strong><\/p>\n\n\n\n<p>Now, let us find out the difference between K-means clustering and hierarchical clustering. There is a thin line difference between the two and hence, it is important to find out the significant concepts that make each different from the other.<\/p>\n\n\n\n<p>Below you can see the tabular representation of the same.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Aspect<\/strong><\/td><td><strong>K-Means Clustering<\/strong><\/td><td><strong>Hierarchical Clustering<\/strong><\/td><\/tr><tr><td>Objective<\/td><td>Partition data into distinct clusters, where each cluster has similar data points. For instance, in trading, you might use K-means to group stocks based on similar volatility patterns.<\/td><td>Group data into hierarchical clusters, forming a tree-like structure (dendrogram). For instance, hierarchical clustering could help create a hierarchy of stocks based on their correlation, indicating how closely related they are.<\/td><\/tr><tr><td>The number of Clusters<\/td><td>Predefined before clustering, and the algorithm aims to assign data points to the specified number of clusters. In trading, you might decide to group stocks into, say, three clusters based on specific criteria like price movements.<\/td><td>Not predefined; the algorithm forms a dendrogram, allowing you to decide the number of clusters based on where you cut the tree. This flexibility can be useful when the optimal number of clusters is not known in advance. For instance, you might identify clusters of stocks with varying degrees of correlation.<\/td><\/tr><tr><td>Computational Complexity<\/td><td>Generally more computationally efficient as it assigns each data point to a single cluster. In trading, this could involve grouping stocks into clusters efficiently, making it easier to analyse and make investment decisions.<\/td><td>Can be computationally intensive for large datasets, especially when forming the dendrogram. However, it offers a visual representation that can be valuable for understanding relationships among data points. For instance, you might use hierarchical clustering to create a visual representation of how different stocks are related in terms of price movements.<\/td><\/tr><tr><td>Cluster Shape<\/td><td>Assumes clusters are spherical, which may not be suitable for data with complex shapes. For example, if stocks have non-linear relationships, K-means might struggle to accurately capture them.<\/td><td>Can handle clusters of various shapes, making it more adaptable to complex structures. In trading, where relationships between stocks can be intricate, hierarchical clustering might provide a more nuanced view of how stocks are grouped.<\/td><\/tr><tr><td>Interpretability<\/td><td>May lack interpretability for complex data, as it focuses on assigning points to clusters without explicitly showing relationships. For instance, K-means might group stocks based on volatility, but the underlying reasons for the grouping may not be immediately clear.<\/td><td>Offers interpretability through the dendrogram, providing a visual representation of relationships among data points. This can be particularly beneficial in trading, where understanding how stocks are hierarchically grouped can inform investment strategies based on correlations.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><em>Stay tuned for Part II to learn about the hierarchical clustering key concepts.<\/em><\/p>\n\n\n\n<p><em>Originally posted on <a href=\"https:\/\/blog.quantinsti.com\/hierarchical-clustering-python\/\">QuantInsti<\/a> blog.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Clustering stands out as the predominant algorithm in unsupervised learning, with applications spanning diverse domains\u2014from medical diagnostics and facial recognition to stock market analysis. <\/p>\n","protected":false},"author":186,"featured_media":21725,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,349,338,341],"tags":[806,16557,16558,595],"contributors-categories":[13654],"class_list":{"0":"post-201216","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-development","12":"tag-data-science","13":"tag-hierarchical-clustering","14":"tag-k-means-in-hierarchical-clustering","15":"tag-python","16":"contributors-categories-quantinsti"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Hierarchical Clustering in Python: A Comprehensive Implementation Guide &#8211; Part I<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/201216\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hierarchical Clustering in Python: A Comprehensive Implementation Guide \u2013 Part I\" \/>\n<meta property=\"og:description\" content=\"Clustering stands out as the predominant algorithm in unsupervised learning, with applications spanning diverse domains\u2014from medical diagnostics and facial recognition to stock market analysis.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-18T16:57:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"700\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Contributor Author\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Contributor Author\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Contributor Author\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\"\n\t            },\n\t            \"headline\": \"Hierarchical Clustering in Python: A Comprehensive Implementation Guide &#8211; Part I\",\n\t            \"datePublished\": \"2024-01-18T16:57:38+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/\"\n\t            },\n\t            \"wordCount\": 1403,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/cluster-grid.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"Hierarchical Clustering\",\n\t                \"K-Means in Hierarchical Clustering\",\n\t                \"Python\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/\",\n\t            \"name\": \"Hierarchical Clustering in Python: A Comprehensive Implementation Guide - Part I | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/cluster-grid.jpg\",\n\t            \"datePublished\": \"2024-01-18T16:57:38+00:00\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/cluster-grid.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/cluster-grid.jpg\",\n\t            \"width\": 1100,\n\t            \"height\": 700,\n\t            \"caption\": \"Algo Trading Clustering\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\",\n\t            \"name\": \"Contributor Author\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/contributor-author\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Hierarchical Clustering in Python: A Comprehensive Implementation Guide &#8211; Part I","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/201216\/","og_locale":"en_US","og_type":"article","og_title":"Hierarchical Clustering in Python: A Comprehensive Implementation Guide \u2013 Part I","og_description":"Clustering stands out as the predominant algorithm in unsupervised learning, with applications spanning diverse domains\u2014from medical diagnostics and facial recognition to stock market analysis.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/","og_site_name":"IBKR Campus US","article_published_time":"2024-01-18T16:57:38+00:00","og_image":[{"width":1100,"height":700,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","type":"image\/jpeg"}],"author":"Contributor Author","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Contributor Author","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/"},"author":{"name":"Contributor Author","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485"},"headline":"Hierarchical Clustering in Python: A Comprehensive Implementation Guide &#8211; Part I","datePublished":"2024-01-18T16:57:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/"},"wordCount":1403,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","keywords":["Data Science","Hierarchical Clustering","K-Means in Hierarchical Clustering","Python"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/","name":"Hierarchical Clustering in Python: A Comprehensive Implementation Guide - Part I | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","datePublished":"2024-01-18T16:57:38+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/hierarchical-clustering-in-python-a-comprehensive-implementation-guide-part-i\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","width":1100,"height":700,"caption":"Algo Trading Clustering"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485","name":"Contributor Author","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/contributor-author\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/cluster-grid.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/201216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/186"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=201216"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/201216\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/21725"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=201216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=201216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=201216"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=201216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}