<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Heena Gupta on Medium]]></title>
        <description><![CDATA[Stories by Heena Gupta on Medium]]></description>
        <link>https://medium.com/@heenag2248?source=rss-3c02afd906d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zxbx69ICSAmD7AG77sWbQQ.png</url>
            <title>Stories by Heena Gupta on Medium</title>
            <link>https://medium.com/@heenag2248?source=rss-3c02afd906d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:09:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@heenag2248/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Clustering Evaluation Methods- Intrinsic and Extrinsic]]></title>
            <link>https://medium.com/@heenag2248/clustering-evaluation-methods-intrinsic-and-extrinsic-936f0c96876f?source=rss-3c02afd906d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/936f0c96876f</guid>
            <dc:creator><![CDATA[Heena Gupta]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 08:54:55 GMT</pubDate>
            <atom:updated>2025-03-01T11:41:02.168Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine a data scientist exploring the world of clustering. Your task is to group data points meaningfully, but how do you ensure that your clusters are good? This article discusses various cluster evaluation metrics, progressing from intrinsic to extrinsic.</p><p><strong>Intrinsic Clustering Metrics — Looking Within the Data</strong></p><p>I<strong>ntrinsic metrics </strong>rely solely on the dataset itself. These metrics don’t need external labels, making them valuable when ground truth is unknown.</p><p><strong>1.</strong> <strong>Inertia: Compactness of Clusters</strong></p><p>At first, you focus on compact clusters. <strong>Inertia</strong> measures how tightly data points are packed within each cluster by calculating the sum of intra-cluster distances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*ZpOaPBdZpHPeiHZMMEBGSQ.png" /></figure><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*2-o3CD78m592E-kd_R1D9A.png" /></figure><p>Where:</p><ul><li>N : Number of clusters.</li><li>xi: point in the Cluster.</li><li>Ck: Centroid of cluster.</li></ul><p><strong>Insight:</strong></p><p>A smaller inertia value indicates more compact clusters. But something feels missing — compactness alone doesn’t guarantee meaningful separation between clusters.</p><p><strong>2.</strong> <strong>Dunn Index: Compactness Meets Separation</strong></p><p><strong>Dunn Index</strong> introduces the idea of separation between clusters. It evaluates the ratio of the minimum inter-cluster distance to the maximum intra-cluster distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*EAerTuf_WWn2W8UcfWLlGA.png" /></figure><p><strong>Formula:</strong></p><p>Dunn Index = min(Inter-Cluster distance)/max(Intra-Cluster distance)</p><p><strong>Insight:</strong></p><p>The Dunn Index emphasizes well-separated and compact clusters. The higher the index, the better the clustering. But what about evaluating each data point’s placement?</p><p><strong>3.</strong> <strong>Silhouette Coefficient: Balancing Cohesion and Separation</strong></p><p>The <strong>Silhouette Coefficient</strong> evaluates how well each point is assigned to its cluster, balancing intra-cluster cohesion and inter-cluster separation.</p><p><strong>Steps to calculate Silhouette score:<br> </strong>1. Select a random point in a cluster and find the distance between that point and all the other points in that cluster and sum it. Let this distance be called a(i).<br> 2. Now compute the distance between that point from the 1st cluster to all the other points in the closest cluster and sum it, we’ll call this b(i)</p><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*xc--XFQU3DED9Pbn5AoHSw.png" /></figure><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*4v7ogKGDl4oyWOP01UL0Gg.png" /></figure><p><strong>Insight:</strong></p><p>With values ranging from -1 to 1, a high Silhouette Coefficient indicates efficient clustering. A high value means that the intra cluster distance is low and inter cluster distance is high.</p><p><strong>4.</strong> <strong>Calinski-Harabasz Index: Variance Ratios</strong></p><p>The <strong>Calinski-Harabasz Index</strong> measures the ratio of between-cluster variance to within-cluster variance, helping assess distinct cluster separation.</p><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*NfIY_WnCIfyoRG9vqkLW8A.png" /></figure><p><strong>Insight:</strong></p><p>A higher CH Index indicates better-defined clusters. But compactness and separation don’t always guarantee meaningful clusters in real-world scenarios.</p><p><strong>5.</strong> <strong>Davies-Bouldin Index: Compactness vs. Separation Tradeoff</strong></p><p>The <strong>Davies-Bouldin Index</strong> takes a different approach by comparing each cluster to its most similar cluster.</p><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*YK3UrcsAqO1_Uf3b6sM-dQ.png" /></figure><p><strong>Insight:</strong></p><p>A lower DB Index suggests better clustering. However, you realize intrinsic metrics can’t confirm alignment with external expectations.</p><p><strong>Extrinsic Clustering Metrics — Incorporating Ground Truth</strong></p><p>Now, we introduce <strong>extrinsic metrics</strong>, which compare clustering results to known labels. These metrics validate clustering when ground truth is available.</p><p><strong>1.</strong> <strong>Rand Index and Adjusted Rand Index</strong></p><p>The <strong>Rand Index</strong> evaluates how well clustering agrees with ground truth by measuring correct pairings. The Adjusted Rand Index refines the Rand Index by accounting for chance agreements.</p><p><strong>Formula:</strong></p><p>Here, G refers to the ground truth and P refers to predicted clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*8JmKLh0llv0jEPRrJFXJRg.png" /></figure><p><strong>Insight:</strong></p><p>A higher Adjusted Rand Index indicates better clustering, adjusted for randomness. Next, you explore precision and recall.</p><p><strong>2.</strong> <strong>Fowlkes-Mallows Index: Precision Meets Recall</strong></p><p>The <strong>Fowlkes-Mallows Index</strong> calculates the geometric mean of precision and recall.</p><p><strong>Formula:</strong></p><p>The definition for TP, FP, and FN is done by counting the number of pairwise points if they are allocated in the same or different cluster for the predicted and actual label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*r9rDp_WKMfEKWmq218PRZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*ZmwmA5GKmy6lOOx-2m_fQw.png" /></figure><p><strong>Insight:</strong></p><p>A higher FMI indicates better clustering. However, you seek to measure shared information.</p><p><strong>3.</strong> <strong>Normalized Mutual Information (NMI): Shared Information</strong></p><p>The <strong>NMI</strong> evaluates the mutual information between clustering and labels, normalized by entropy.</p><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*6QufBUUmi9eHhEtq0ofW5A.png" /></figure><p><strong>Insight:</strong></p><p>A higher NMI indicates stronger agreement. Finally, you evaluate individual label precision and recall.</p><p><strong>4.</strong> <strong>BCubed Metrics: Label-Based Precision and Recall</strong></p><p>The <strong>BCubed Precision and Recall</strong> metrics evaluate clustering performance based on true and predicted labels for individual data points. Precision represents how many items in the same cluster belong to its category. Symmetrically, the recall associated to one item represents how many items from its category appear in its cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*N1RSbIfSLIMhN-CJpkZkCQ.png" /></figure><p><strong>Formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*4ZYSVGaAG00g-_HgRdi3xA.png" /></figure><p>Where the predicted 𝑓𝑝 , and the gold standard truth 𝑓𝑡 for each e</p><p><strong>Insight:</strong></p><p>Higher precision and recall indicate better alignment with ground truth.</p><p><strong>Conclusion</strong></p><p>Clustering metrics highlights the importance of both intrinsic and extrinsic measures. While intrinsic metrics assess clustering quality based on data structure, extrinsic metrics validate alignment with ground truth. Together, they provide a comprehensive evaluation framework, ensuring meaningful clustering results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=936f0c96876f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Google Cloud Load Balancing with Managed Instance Groups]]></title>
            <link>https://medium.com/@heenag2248/understanding-google-cloud-load-balancing-with-managed-instance-groups-62024c5f2c28?source=rss-3c02afd906d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/62024c5f2c28</guid>
            <dc:creator><![CDATA[Heena Gupta]]></dc:creator>
            <pubDate>Fri, 03 Jan 2025 08:17:47 GMT</pubDate>
            <atom:updated>2025-01-03T08:17:47.279Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Cloud provides powerful services to help manage and distribute traffic across multiple instances of your application. One such service is <strong>Google Cloud Load Balancing</strong>, which helps to ensure that your application remains highly available, scalable, and resilient. This article will guide you through the process of setting up a <strong>Managed Instance Group (MIG)</strong> with <strong>Google Cloud Load Balancer</strong>, along with a basic <strong>Nginx web server</strong> running on each instance in the group.</p><p>Let’s break it down into digestible steps:</p><h3>1. What is Google Cloud Load Balancing?</h3><p><strong>Google Cloud Load Balancing</strong> is a fully distributed, global, and software-defined load balancer that helps distribute traffic across multiple servers or instances. By setting up a load balancer, you can ensure your application remains highly available, scalable, and fault-tolerant.</p><p>Some key benefits include:</p><ul><li><strong>High availability</strong>: Traffic is directed only to healthy instances.</li><li><strong>Global distribution</strong>: The load balancer routes traffic to the nearest healthy instance, reducing latency.</li><li><strong>Automatic failover</strong>: If one instance fails, the traffic is automatically redirected to the next healthy instance.</li><li><strong>Scalability</strong>: Automatically adjust the number of VMs to handle fluctuating traffic.</li></ul><h3>2. What is a Managed Instance Group (MIG)?</h3><p>A <strong>Managed Instance Group (MIG)</strong> is a group of identical virtual machine (VM) instances managed as a unit. MIGs allow for automated scaling, updates, and health checks. They also handle the creation and deletion of instances based on the demand and health of the services running on them.</p><p><strong>Key features of MIGs</strong>:</p><ul><li><strong>Autoscaling</strong>: Automatically adjusts the number of instances based on load.</li><li><strong>Health checks</strong>: Regularly checks if the instances are running correctly and replaces unhealthy ones.</li><li><strong>Automated updates</strong>: Deploy new application versions seamlessly.</li></ul><h3>3. Prerequisites</h3><p>Before we start, ensure you have the following:</p><ul><li>A <strong>Google Cloud account</strong>.</li><li>Google Cloud SDK (gcloud) installed on your machine or Cloud Shell access.</li></ul><h3>4. Create an Instance Template with Nginx</h3><p>An <strong>instance template</strong> defines the configuration of your virtual machines. It specifies the machine type, the operating system, and any startup scripts.</p><p>In this case, we’ll use <strong>Debian Linux</strong> and install <strong>Nginx</strong>, a lightweight web server, on each VM instance.</p><h4>Create the Startup Script</h4><p>The startup script installs Nginx and customizes the default Nginx page to show the instance’s hostname.</p><blockquote>#!/bin/bash</blockquote><blockquote>apt-get update</blockquote><blockquote>apt-get install -y nginx</blockquote><blockquote>service nginx start</blockquote><blockquote>sed -i — ‘s/nginx/Google Cloud Platform — ‘“$HOSTNAME”’/’ /var/www/html/index.nginx-debian.html</blockquote><p>This script performs the following:</p><ol><li>Updates the package list on the VM.</li><li>Installs <strong>Nginx</strong>.</li><li>Starts the <strong>Nginx</strong> service.</li><li>Customizes the <strong>index.html</strong> page to display the instance’s hostname for easy identification.</li></ol><h4>Create the Instance Template</h4><p>To create an instance template, use the following gcloud command:</p><blockquote>gcloud compute instance-templates create nucleus-template-753 \ — machine-type=e2-medium \ — image-family=debian-11 \ — image-project=debian-cloud \ — metadata=startup-script=’#! /bin/bash apt-get update apt-get install -y nginx service nginx start sed -i — ‘s/nginx/Google Cloud Platform — ‘“$HOSTNAME”’/’ /var/www/html/index.nginx-debian.html’ \ — tags=http-server</blockquote><ul><li><strong>--machine-type=e2-medium</strong>: Specifies the type of machine to use (e2-medium is a balanced machine type).</li><li><strong>--image-family=debian-11</strong>: Selects the base OS (Debian 11).</li><li><strong>--metadata=startup-script=...</strong>: Specifies the startup script to run when the instance is created.</li><li><strong>--tags=http-server</strong>: Assigns the tag http-server, which allows HTTP traffic to the instances.</li></ul><h3>5. Create a Managed Instance Group (MIG)</h3><p>Now that we have the instance template, we will create a <strong>Managed Instance Group</strong> to deploy multiple identical instances.</p><h4>Create the MIG with 2 Nginx Instances</h4><p>Run the following gcloud command to create the MIG:</p><blockquote>gcloud compute instance-groups managed create nucleus-instance-group-753 \ — base-instance-name=nucleus-webserver \ — template=nucleus-template-753 \ — size=2 \ — zone=europe-west4-a</blockquote><p>Here’s what the command does:</p><ul><li><strong>--base-instance-name=nucleus-webserver</strong>: Names the instances in the group nucleus-webserver-&lt;suffix&gt;, where &lt;suffix&gt; is automatically added.</li><li><strong>--template=nucleus-template-753</strong>: Uses the previously created template to configure the instances.</li><li><strong>--size=2</strong>: Specifies that we want to create 2 instances.</li><li><strong>--zone=europe-west4-a</strong>: Specifies the zone where the instances will be created.</li></ul><h3>6. Set Up the Health Check for the Instances</h3><p>To ensure that traffic is only sent to healthy instances, we need to configure a <strong>Health Check</strong>.</p><p>Here’s how to create an HTTP health check:</p><blockquote>gcloud compute health-checks create http http-health-check-753 \ — port 80 \ — request-path / \ — check-interval 30s \ — timeout 10s \ — unhealthy-threshold 3 \ — healthy-threshold 2</blockquote><p>Explanation:</p><ul><li><strong>--port 80</strong>: Specifies the port on which to check the instance (HTTP).</li><li><strong>--request-path /</strong>: Specifies the path to check (/ means the root of the web server).</li><li><strong>--check-interval 30s</strong>: Sets the interval between each health check to 30 seconds.</li><li><strong>--timeout 10s</strong>: Sets the timeout for each check to 10 seconds.</li><li><strong>--unhealthy-threshold 3</strong>: Specifies that an instance is unhealthy if it fails 3 consecutive checks.</li><li><strong>--healthy-threshold 2</strong>: Specifies that an instance is healthy if it passes 2 consecutive checks.</li></ul><h3>7. Create the Load Balancer</h3><p>Now that the instance group and health check are in place, we can create the load balancer.</p><ol><li><strong>Create a Backend Service</strong> to direct traffic to the Managed Instance Group:</li></ol><blockquote>gcloud compute backend-services create nucleus-backend-service-753 \ — protocol=HTTP \ — health-checks=http-health-check-753 \ — global</blockquote><ul><li><strong>--protocol=HTTP</strong>: Specifies that the backend service uses HTTP.</li><li><strong>--health-checks=http-health-check-753</strong>: Associates the health check with the backend service.</li></ul><p><strong>2. Create a URL Map</strong> to route traffic to the backend service:</p><blockquote>gcloud compute url-maps create nucleus-url-map-753 \<br> — default-service=nucleus-backend-service-753</blockquote><p><strong>3. Create a Target HTTP Proxy</strong> to manage the load balancing:</p><blockquote>gcloud compute target-http-proxies create nucleus-http-proxy-753 \<br> — url-map=nucleus-url-map-753</blockquote><p><strong>4. Create a Forwarding Rule</strong> to route traffic from an external IP address to the target HTTP proxy:</p><blockquote>gcloud compute forwarding-rules create nucleus-forwarding-rule-753 \<br> — global \<br> — target-http-proxy=nucleus-http-proxy-753 \<br> — ports=80</blockquote><ul><li><strong>--global</strong>: Specifies that the forwarding rule is global.</li><li><strong>--ports=80</strong>: Specifies that traffic on port 80 will be forwarded to the proxy.</li></ul><h3>8. Test the Load Balancer</h3><p>To test your setup, visit the external IP address assigned to the forwarding rule:</p><blockquote>gcloud compute forwarding-rules describe nucleus-forwarding-rule-753 — global</blockquote><p>Look for the <strong>IP Address</strong> field in the output. Once you have the external IP, open it in your browser or use curl to access it. You should see the custom Nginx page with the instance’s hostname.</p><p>For example:</p><blockquote>curl http://&lt;EXTERNAL_IP&gt;</blockquote><p>This should display the Nginx landing page with the Google Cloud Platform hostname.</p><h3>Conclusion</h3><p>Congratulations! You’ve successfully set up a <strong>Google Cloud Load Balancer</strong> with a <strong>Managed Instance Group</strong> running <strong>Nginx web servers</strong>. By following these steps, you’ve created a highly available, scalable web server setup that can handle increased traffic by automatically adding or removing instances as needed. This setup provides fault tolerance and load balancing, ensuring that your application can handle user requests efficiently.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62024c5f2c28" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>