<?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 Bhargav Sharma on Medium]]></title>
        <description><![CDATA[Stories by Bhargav Sharma on Medium]]></description>
        <link>https://medium.com/@gautambhargav644?source=rss-d0b90c6ce80e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qJRRASaZMZ-V4zMIv7qfiQ.jpeg</url>
            <title>Stories by Bhargav Sharma on Medium</title>
            <link>https://medium.com/@gautambhargav644?source=rss-d0b90c6ce80e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:20:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gautambhargav644/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[Building for Billions: Mastering System Design for Massive Scale]]></title>
            <link>https://medium.com/engineering-at-bajaj-health/building-for-billions-mastering-system-design-for-massive-scale-cf2cd8fd7857?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf2cd8fd7857</guid>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Thu, 15 Feb 2024 03:50:04 GMT</pubDate>
            <atom:updated>2024-06-24T02:40:05.680Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Level 1. Foundational Structure:</strong></h3><p>Let’s begin with a basic setup: when a web browser or mobile app requests a website, it queries the Domain Name System (DNS) to obtain an IP address mapped to the site. For instance, entering 173.194.203.106 in the browser takes you to Google.com. Once the IP is retrieved, HTTP requests are sent directly to the web server, which returns HTML pages or JSON containing the stored data. It’s a straightforward process for a small user base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IGj0dDAga0BTTGXBuXqf5A.gif" /><figcaption>Fig 1: Level 1</figcaption></figure><h3><strong>Limitations :</strong></h3><p><strong>1. Scalability:</strong> The basic setup described in Level 1 may not efficiently handle large traffic volumes or a rapidly growing user base.<br><strong>2.</strong> <strong>Limited Functionality:</strong> The basic structure may support only static content delivery or simple data retrieval.</p><p>Hence with the growth of the user base, one server is not enough, and we need multiple servers: one for web/mobile traffic, the other for the database.</p><h3>Level 2. Introducing Database:</h3><p>Separating the web traffic server from the data server enables independent scaling. But which database should you choose? It hinges on your specific needs:</p><p><strong>Relational Databases</strong> :</p><ul><li><strong>Structured Data:</strong> When your data is well-organized and follows a clear structure.</li><li><strong>Complex Queries:</strong> For applications requiring complex queries or transactions.</li></ul><p><strong>Non-Relational Databases</strong> :</p><ul><li><strong>Massive Data Storage:</strong> Opt for non-relational databases when dealing with huge volumes of data.</li><li><strong>Speed Matters:</strong> When your application demands lightning-fast response times, non-relational databases shine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MDcHaFbA4qq5fnzCBiPrg.gif" /><figcaption>Fig 2: Level 2</figcaption></figure><h3>Limitations :</h3><ol><li><strong>Single Point of Failure:</strong> It introduces a potential single point of failure. If the database server experiences downtime or becomes overloaded, it can disrupt the entire system’s functionality, impacting user experience and service availability.</li><li><strong>Scalability Challenges</strong></li></ol><p>Having covered Level 2, scalability issues persist as user bases expand and the risk of database downtime looms. This is where horizontal and vertical scaling steps in.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Relational databases:</strong> MySQL, PostgreSQL</li><li><strong>Non-relational databases: </strong>MongoDB, Cassandra</li></ul><h3>Level 3. Vertical and Horizontal Scaling :</h3><p>Vertical scaling, referred to as “scale up”, means the process of adding more power (CPU, RAM, etc.) to your servers.</p><ul><li><strong>Advantage:</strong> Simplicity and suitability for low traffic periods.</li><li><strong>Disadvantages:</strong> <br>a. Hard limit on server resources.<br>b. Lack of failover and redundancy, risking complete downtime if one server fails.</li></ul><p>Horizontal scaling, referred to as “scale-out”, allows you to scale<br>by adding more servers to your pool of resources.</p><ul><li><strong>Advantage:</strong> Overcomes limitations of vertical scaling.</li><li><strong>Disadvantage:</strong> Requires more complexity but offers resilience and availability by distributing workload across multiple servers.</li></ul><p>Scaling can address situations where a user cannot access a website because one of the web servers is offline. In such cases, additional servers can be dynamically provisioned or resources can be allocated to other servers to ensure continuous availability and smooth operation of the website. Additionally, a load balancer can redirect traffic away from the offline server to the functioning ones, further enhancing reliability and user experience.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Vertical scaling:</strong> Amazon RDS, Google Cloud SQL</li><li><strong>Horizontal scaling:</strong> MongoDB Sharding, Cassandra Cluster</li></ul><h3>Level 4. Addition of Load Balancer :</h3><p>A load balancer evenly distributes incoming traffic among a set of web servers designated for load balancing. <br>Users connect directly to the public IP of the load balancer, eliminating direct access to the web servers by clients. This setup enhances security, as communication between servers occurs via private IPs. Private IPs are accessible only within the same network, ensuring they are not reachable over the Internet. The load balancer communicates with the web servers exclusively through these private IPs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*UEZoh0zr4wdtIgCVapet2A.png" /><figcaption>Level 4: Setup with Load Balancer</figcaption></figure><h3>Limitations :</h3><p>The limitation of the above setup is that while we have addressed the needs of the web tier, we have neglected the data tier. Up until now, we have been using only one database Although the database is not depicted in the diagram, we have been utilizing a single database thus far, which lacks support for failover and redundancy. Data replication is a common technique used to address this issue.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Load balancers:</strong> AWS Elastic Load Balancing, NGINX Load Balancer</li></ul><h3>Level 5. Data Replications :</h3><p>Data replication is the process of copying data from one location to another. There are various methodologies for achieving this, with one popular approach being the master/slave methodology.<br>In this, A master database generally only supports write operations. A slave database gets copies of the data from the master database and only supports read operations. All the data-modifying commands like insert, delete, or update must be sent to the master database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*0XAdd1Z2nVTbl04kLIZU8A.png" /><figcaption>Level 5</figcaption></figure><h3><strong>Advantages:</strong></h3><p>• <strong>Better performance:</strong> In the master-slave model, write and update operations occur in master nodes, while read operations are distributed among slave nodes, enabling parallel query processing and enhancing performance.<br>• <strong>Reliability and high availability:</strong> Data replication across multiple locations ensures data preservation in the event of a disaster, ensuring continued operation of the website even if one database server is offline.</p><h3>What if one database goes offline?</h3><ul><li><strong>If a slave database goes offline</strong>, traffic is redirected to another available slave. If only one slave is operational, traffic redirection occurs to the master database.</li><li><strong>In the event of the master database going offline</strong>, a slave is promoted to master. However, there could be discrepancies in data between the promoted slave and the previous master. Therefore, data recovery scripts should be executed to synchronize the data before the promotion.</li></ul><blockquote><strong>Note: </strong>Database administrators or automated configuration tools manage the assignment of master and slave roles in database replication setups. Traffic redirection during database failures is typically overseen by the load balancer.</blockquote><p>The addition of a CDN can further scale the above setup by addressing the limitation of static file delivery.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Replication tools:</strong> MySQL Replication, MongoDB Replica Sets</li><li><strong>Disaster recovery solutions:</strong> AWS RDS Multi-AZ, Google Cloud Spanner</li></ul><h3>Level 6. Addition of CDN and Caching layer:</h3><p>A CDN is a network of geographically dispersed servers used to deliver static content. CDN servers cache static content like images, videos, CSS, JavaScript files, etc.</p><h3>Working:</h3><p>When a user accesses a website, the CDN server nearest to them will serve static content. If the content is not already cached on the CDN server, it retrieves it from the database and stores it locally for a specified Time-to-Live (TTL) period. This process optimizes content delivery, reducing latency and improving user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*jgP-WPTv_jyzdSGOExj9lg.png" /><figcaption>Level 6</figcaption></figure><h3><strong>Considerations of using a CDN:</strong></h3><ul><li><strong>Cost management:</strong> Ensuring the CDN expenses are optimized within budget constraints.</li><li><strong>CDN Fallback: </strong>Implementing backup plans in case the CDN service encounters issues.</li><li><strong>Setting appropriate cache expiry:</strong> Configuring cache lifetimes to balance the freshness of content with bandwidth optimization.</li></ul><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>CDN providers:</strong> Akamai, Fastly, Cloudflare</li><li><strong>CDN services:</strong> Amazon CloudFront, Cloudflare CDN</li><li><strong>Caching solutions: </strong>Redis, Memcached, Varnish Cache</li></ul><h3>Level 7. Stateful to Stateless architecture:</h3><p>When scaling the web tier horizontally, it’s smart to move session data out of it. Storing session info in long-lasting storage like relational or NoSQL databases is a good idea.</p><h3><strong>Stateful architecture:</strong></h3><p>A stateful server remembers client data (state) from one request to the next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*0MW_9zWiwkXKjzseOGxuBg.png" /><figcaption>Level 7: Stateful Architecture</figcaption></figure><p><strong>Limitation:</strong><br>Now, if a user A’s HTTP request needs authentication, it must be directed to Server 1. However, for other services like Server 2, user A’s authentication will fail.</p><h3>Stateless architecture:</h3><p>In stateless architecture, Each server operates independently without relying on a shared state. We’ll utilize relational or NoSQL databases to store and manage user state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*gHyZCvBIEavET15XtmSsLQ.png" /><figcaption>Level 7: Stateless Architecture</figcaption></figure><p>In this stateless architecture, HTTP requests from users can be sent to any web server, which fetches state data from a shared data store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*-qoeae45Vc7lMLaUC_eMDw.png" /><figcaption>Level 7</figcaption></figure><p>Once state data is extracted from the web servers, auto-scaling the web tier becomes straightforward by dynamically adding or removing servers according to traffic demand. As our website grows and attracts users from around the world, it’s important to have multiple data centers to ensure availability and provide a better experience for users in different places.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Session management tools: </strong>Redis for session storage</li><li><strong>NoSQL databases:</strong> MongoDB for storing state data</li></ul><h3>Level 8. Including Data Centers:</h3><p>A data center is a physical location that stores and processes an organization’s data and applications.<br>GeoDNS, also known as geo-routed DNS, is a handy service that directs users to the nearest data center based on their location. It works by resolving domain names to IP addresses, ensuring users are routed to the closest server for faster access and better performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*B2c0kq5p7oj473VbITO5hA.png" /><figcaption>Level 8: Inclusion of Data Centers</figcaption></figure><p>Additionally, these data centers serve as backup options in case another data center experiences downtime or encounters issues.</p><h3>Challenges for Multi-Data Center Setup:</h3><ul><li><strong>Traffic redirection:</strong> Utilizing GeoDNS to direct users to the nearest data center efficiently.</li><li><strong>Data synchronization:</strong> Ensuring data consistency across multiple centers, even during failover, through replication.</li><li><strong>Test and deployment:</strong> Crucial to test website/application performance across diverse locations and employ automated deployment tools for consistent service delivery.</li></ul><p>To further scale our system, we need to decouple different components of the system so they can be scaled independently.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Datacenter providers:</strong> AWS, Google Cloud, Microsoft Azure</li><li><strong>GeoDNS services: </strong>Amazon Route 53 Traffic Flow, Cloudflare GeoDNS</li></ul><h3>Level 9. Message Queue:</h3><p>A <strong>message queue</strong>, a durable component stored in memory, facilitates asynchronous communication. It acts as a buffer, distributing asynchronous requests.<br>The fundamental architecture is straightforward: Input services, termed <strong>producers</strong> or publishers, generate messages and publish them to the message queue. Subsequently, other services or servers, referred to as <strong>consumers</strong> or subscribers, connect to the queue and execute actions specified by the messages. <br>Decoupling the producer and consumer, enables independence and can be implemented in front of databases or servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*k3pQX4keuE-IdtBxDgOgJA.png" /></figure><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Message queue systems:</strong> RabbitMQ, Apache Kafka, Amazon SQS</li></ul><h3>Level 10. Logging, Metrics and Automation:</h3><p>As now our website has grown to support a sizable business, it’s important to invest in tools for logging, metrics, and automation.</p><h3>Logging:</h3><p>Keeping an eye on error logs is crucial for spotting system issues. You can check these logs on each server or use tools to bring them all together for easier management.</p><h3>Metrics:</h3><p>Gathering different kinds of metrics helps us understand how well the system is doing.</p><p>• <strong>Host level metrics:</strong> CPU, Memory, disk I/O, etc.<br>• <strong>Aggregated level metrics: </strong>the performance of the entire database tier, cache tier, etc.<br>• <strong>Key business metrics: </strong>daily active users, retention, revenue, etc.</p><h3>Automation:</h3><p>As systems grow, automation becomes super helpful for boosting productivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*5ibfvGhZY4LEbKQedVWp2A.png" /><figcaption>Level 9</figcaption></figure><p>As the data grows every day, your database gets more overloaded. It is time to scale the data<br>tier.</p><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Logging tools:</strong> ELK Stack (Elasticsearch, Logstash, Kibana), Splunk</li></ul><h3>Level 11. Database scaling:</h3><p>Similar to servers, databases can also scale both vertically and horizontally.</p><h3>Vertical scaling:</h3><p>Vertical scaling, or scaling up, involves increasing the power of a database server by adding resources like CPU, RAM, and disk space. For instance, Amazon Relational Database Service (RDS) offers database servers with up to 24 TB of RAM, enabling them to store and manage large volumes of data efficiently.</p><h3>Horizontal scaling:</h3><p>Horizontal scaling, also known as sharding, involves adding more servers to a database system. <br>Sharding breaks large databases into smaller parts called shards, each with its unique data. To locate specific data, the database server uses a hash function. While sharding helps scale databases, it comes with challenges:</p><ul><li><strong>Resharding data: </strong>Sometimes, a shard can’t hold more data due to rapid growth, requiring redistribution of data.</li><li><strong>Celebrity problem:</strong> Heavy access to certain shards can overload servers, especially if popular data ends up on the same shard.</li><li><strong>Join and de-normalization:</strong> Join operations become difficult across multiple shards, so databases are often simplified to speed up queries.</li></ul><h3>Organization’s Toolkit for the same:</h3><ul><li><strong>Vertical scaling solutions:</strong> Amazon RDS with provisioned IOPS</li><li><strong>Horizontal scaling solutions:</strong> Amazon DynamoDB, Google Cloud Bigtable</li></ul><p>Ready to scale your systems like a pro? Thank you for reading to the end. Follow for more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf2cd8fd7857" width="1" height="1" alt=""><hr><p><a href="https://medium.com/engineering-at-bajaj-health/building-for-billions-mastering-system-design-for-massive-scale-cf2cd8fd7857">Building for Billions: Mastering System Design for Massive Scale</a> was originally published in <a href="https://medium.com/engineering-at-bajaj-health">Engineering at Bajaj Health</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying the Web: Understanding Chromium’s Architecture]]></title>
            <link>https://medium.com/engineering-at-bajaj-health/demystifying-the-web-understanding-chromiums-architecture-a62c3b22eece?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a62c3b22eece</guid>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 14:34:44 GMT</pubDate>
            <atom:updated>2024-04-10T12:04:24.109Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered when you write the command document.getElementByClassName(&quot;test&quot;) in the console why don’t you get the output as an element &lt;a class=&#39;test&#39;&gt;Gmail&lt;/a&gt; instead, you will get this!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/0*ELt2CfKsO2mv_9D3.png" /><figcaption>Output 1</figcaption></figure><p>okay, let’s not waste time and deep dive into it.</p><h3>Understanding How Browsers Interpret HTML, CSS, and JavaScript.</h3><p>Creating a website begins with HTML for structure, CSS for style, and JavaScript for interaction. First, let’s explore some of the major components of a browser and also the workings of a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PXEhv78pnMw2ubKZ.png" /><figcaption>Figure:1. CHROMIUM’S ARCHITECTURE</figcaption></figure><h3>Components of Browser:</h3><ol><li><strong>Rendering Engine: </strong>The rendering engine interprets and executes web content by providing default behaviors (for example, drawing &lt;input&gt; elements) and by servicing calls to the <strong>DOM API</strong>. Rendering web content proceeds in several stages, beginning with parsing, building an in-memory representation of the <strong>DOM</strong>, laying out the document graphically, and manipulating the document in response to script instructions. The rendering engine is also responsible for enforcing the same-origin policy, which helps prevent malicious websites from disrupting the user’s session with honest websites. Some of the engine examples are.<br><strong>ex:</strong> Apple created <a href="https://en.wikipedia.org/wiki/WebKit">WebKit</a>, Google originally used WebKit for its Chrome browser but eventually forked it to create the <a href="https://en.wikipedia.org/wiki/Blink_(browser_engine)">Blink</a> engine, and Mozilla developed the <a href="https://en.wikipedia.org/wiki/Gecko_(software)">Gecko</a> engine for its Firefox.</li><li><strong>Browser Kernel: </strong>As the intermediary between UI and the r<strong>endering engine,</strong> the browser kernel is pivotal. Responsible for managing multiple rendering engine instances, it also implements the <strong>browser kernel API</strong>. Notably, it crafts a tab-based windowing system, complete with a location bar showcasing active tab URLs and security indicators. Additionally, the kernel oversees persistent user states, including <strong>bookmarks</strong>, <strong>cookies</strong>, and <strong>saved passwords</strong>.</li></ol><p>Note: The architecture allocates high-risk components, such as the <strong>HTML parser</strong>, the <strong>JavaScript virtual machine</strong>, and the <strong>Document Object Model</strong> (DOM), to its sandboxed rendering engine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*0948DcUnwhHhVONq.png" /></figure><p>The assignment of tasks between the rendering engine and the browser kernel.</p><p>Interestingly some of the assignments of browser components to modules are driven by <em>historical artifacts</em> for example:<br>1. The <strong>browser kernel</strong> is responsible for displaying JavaScript alert dialog boxes, whereas &lt;select&gt; drop-down menus are displayed by the <strong>rendering engine</strong>.<br>2. cookie database, are implemented by the <strong>browser kernel </strong>because of its direct access to the file system. Other features, such as regular expressionsare implemented by the <strong>rendering engine </strong>because they are performance-sensitive and have often been the source of security vulnerabilities.</p><p>Now that we’ve grasped the terminology, let’s delve into the mechanics:</p><p><strong>STEP 1: </strong>The <strong>browser kernel</strong> receives your HTML file, intertwined with CSS and JavaScript, as raw bytes — its native language being only 1’s and 0&#39;s.</p><p><strong>STEP 2:</strong> This data stream is then transmitted to the <strong>rendering engine </strong>for interpretation. Initially, the browser engages in <em>character encoding</em>, directing the rendering engine on how to translate this digital code into recognizable characters, numbers, and symbols.</p><p><strong>STEP 3: </strong>Subsequently, HTML tokenization takes place, where the browser discerns common tokens, such as tags like &lt;h1&gt;, &lt;p&gt;, and &lt;script&gt;, crucially defined by developers.</p><p><strong>STEP 4:</strong> Following this tokenization, each tag is converted into objects for example:</p><pre>const object={<br>   nodeName:h2<br>   nodeValue:&quot;Hello World&quot;,<br>   hidden:false,<br>   ...rest<br>}</pre><p><strong>STEP 5: </strong>However, mere object creation is insufficient, Here, the <strong>rendering engine</strong> arranges them hierarchically, delineating parent-child relationships and crafting a <strong>Document Object Model (DOM).</strong></p><p><strong>STEP 6: </strong>Hang On! CSS, the silent conductor of style, isn’t left behind similarly to CSS, the <strong>rendering engine</strong> crafts the <strong>Cascading Style Sheets Object Model (CSSOM).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*l2nEEU5KdZWT8gLh.png" /></figure><p><strong>STEP 7: </strong>Indeed, the challenge lies in managing the created objects (<strong>DOM</strong>) effectively, providing developers with the means to access and manipulate them at will. This is where <strong>NodeLists</strong> and <strong>HTMLCollections</strong> come into play.</p><blockquote><strong><em>NodeList:</em></strong></blockquote><ul><li><strong>Returned by </strong><strong>querySelectorAll</strong>: When you use the querySelectorAll method in JavaScript to select multiple elements in the DOM, the browser returns a NodeList containing all matching elements.</li><li><strong>Live Collection</strong>: NodeLists are live collections, meaning they are automatically updated as the DOM changes. If elements matching the selector are added or removed from the DOM, the NodeList updates accordingly.</li><li><strong>Iterability</strong>: NodeLists can be iterated over using methods like forEach or indexed using bracket notation.</li></ul><blockquote><strong><em>HTMLCollection:</em></strong></blockquote><ul><li><strong>Returned by DOM collections</strong>: Some DOM properties, such as children or getElementsByTagName, return HTMLCollections. These collections contain live lists of elements with specific characteristics.</li><li><strong>Non-live</strong>: Unlike NodeLists, HTMLCollections are not live. If elements matching the criteria are added or removed from the DOM after the collection is created, the HTMLCollection does not automatically update.</li><li><strong>Named access</strong>: HTMLCollections can also be accessed using named keys, like collectionName[&#39;elementName&#39;].</li></ul><p><strong>STEP 8: </strong>The<strong> rendering engine </strong>emits bitmaps of the rendered document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/0*7-JsN2pVPYl38kPJ.png" /><figcaption>Code -&gt; Bitmap</figcaption></figure><p>Thank you for reading to the end for those who are eager to delve deeper into the Chromium architecture, I encourage you to explore further from <a href="https://seclab.stanford.edu/websec/chromium/chromium-security-architecture.pdf"><strong>here</strong></a>.</p><p><strong>Follow</strong> for the latest on web architecture and more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a62c3b22eece" width="1" height="1" alt=""><hr><p><a href="https://medium.com/engineering-at-bajaj-health/demystifying-the-web-understanding-chromiums-architecture-a62c3b22eece">Demystifying the Web: Understanding Chromium’s Architecture</a> was originally published in <a href="https://medium.com/engineering-at-bajaj-health">Engineering at Bajaj Health</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript's ‘By Value’ vs ‘By Reference’]]></title>
            <link>https://medium.com/@gautambhargav644/javascripts-by-value-vs-by-reference-3ef16d05b806?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ef16d05b806</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Wed, 24 May 2023 19:10:57 GMT</pubDate>
            <atom:updated>2023-05-24T19:10:57.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*nccHP8Z4XXiZF3YH.png" /></figure><p>Certainly! JavaScript’s behavior with data types can sometimes lead to bugs if not understood correctly. There is a distinct behavior in JavaScript where certain data types are passed by value, while others are passed by reference. Let’s take a deep dive in this behavior.</p><blockquote>I would like to start by asking two questions that will further enhance your understanding of the need to explore this concept:</blockquote><pre>const a=5<br>const b=5<br>console.log(a===b)  //Q1<br><br>const arr1=[5]<br>const arr2-[5]<br>console.log(a===b)  //Q2</pre><blockquote>the answer for Q1 is <strong><em>true</em></strong> where as answer for Q2 is <strong><em>false </em></strong>let’s see why and how?</blockquote><p>JavaScript generally has two types of data types: <strong>primitive</strong> and <strong>non-primitive</strong>. This further leads to the concept that primitive data types are passed by value, while non-primitive data types are passed by reference.</p><h3>Primitive Data Types :</h3><p>Primitive data types in JavaScript are basic data types that hold a single value and are <strong>immutable</strong>.Below are some primitive data types</p><ol><li>Null</li><li>Undefined</li><li>Number</li><li>String</li><li>Boolean</li></ol><p>These <strong>primitive</strong> data types in JavaScript are considered <strong>immutable</strong>, which means that once they are initialised with a value, that value <strong><em>cannot be modified</em></strong> directly. In other words, you cannot change the original value once it is assigned to a variable. However, you have the option to <strong>replace the existing value</strong> with a new one or <strong>remove</strong> it from memory altogether.</p><h3>Non Primitive Data Types :</h3><p>Non-primitive data types in JavaScript are complex data structures that can hold multiple values and are mutable, allowing for direct modification of their contents.</p><ol><li>Array</li><li>Object</li></ol><p>These data types, including objects and arrays, are referred to as reference types because variables of these types store a reference to the memory location where the data is stored, rather than the data itself.</p><p><strong>Note</strong>: It is important to note that when performing a comparison operation (using === or ==) on <strong><em>immutable or primitive data</em></strong> <strong><em>types</em></strong> in JavaScript, the comparison is based solely on the <strong>values</strong> and <strong>data types</strong>, according to the rules defined by == or ===. On the other hand, when comparing <strong><em>non-primitive data types</em></strong>, such as objects or arrays, the comparison is based on the <strong>references of the variables</strong> rather than the values themselves.</p><blockquote>Similarly, in the above example, even if the contents of arr1 were equal to the contents of arr2, the comparison arr1 === arr2 would still evaluate to false because the two variables point to different memory addresses or references.</blockquote><h3>But why primitive data types are not referenced ?</h3><p>In JavaScript, primitive types are not referenced because they are designed to be simple and efficient data types that hold basic values.Below are some another valid reasons:</p><ol><li><strong>Efficiency</strong>: Primitive types, such as int, float, boolean, etc., are typically small in size and are directly stored in memory, either on the stack or within objects. So the additional storage of it’s references will require additional memory.</li><li><strong>Performance</strong>: Since primitive types are not objects, they don’t require dynamic memory allocation or garbage collection, which can lead to improved performance.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ef16d05b806" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript’s Call Stack and Event Loop: Making Sense of the Madness!]]></title>
            <link>https://medium.com/@gautambhargav644/javascripts-call-stack-and-event-loop-making-sense-of-the-madness-1f7cddbf6712?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f7cddbf6712</guid>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 21:38:21 GMT</pubDate>
            <atom:updated>2023-02-27T21:38:21.041Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript has become an essential tool for web developers in recent years. It’s used everywhere, from full-stack and app development to machine learning. As a result, developers are increasingly curious about JavaScript’s quirky topics, like the event loop and call stack. This blog will explore these topics and shed light on their intricacies. So, let’s dive into the world of JavaScript and better understand these fundamentals.</p><h3>Why do we need a call stack?</h3><blockquote>Since JavaScript is a single-threaded synchronous language, it can only handle one task at a time. In order to handle these tasks one by one smoothly, we need a data structure to track everything and tell the interpreter which threads to work on and which to block.</blockquote><h3>A.) Call Stacks:</h3><p>In simple terms, the call stack is a data structure that holds the function calls made in a script in the sequence in which they were called.</p><p>Below is an image that self-explains how the call stack works and stores the function calls of a program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*G_cmdU3EkU3ti0YVPuI1rg.gif" /></figure><h3>Key Points About the Call Stack:</h3><ol><li>When a function returns or its scope ends, it is automatically removed (<strong>popped out</strong>) from the call stack.</li><li>Each element (<em>function call</em>) in the call stack is commonly referred to as a “<strong>stack frame</strong>”. The call stack has a maximum size, which is determined by the browser or runtime environment. In modern browsers, the maximum call stack size is typically around 10,000 frames, although this can vary depending on the platform and hardware. When the call stack exceeds its maximum size, a “<strong>stack overflow</strong>” error is thrown, indicating that there is not enough memory available to store additional stack frames.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*BhswiFackhr5eJZSqamrGQ.png" /><figcaption>-example for stack overflow</figcaption></figure><blockquote>Understanding the call stack is an essential prerequisite for grasping the concept of the <strong>event loop</strong>. But let’s take a step back and build a foundation before diving into the <strong>event loop</strong>.</blockquote><h3><strong>Understanding Synchronous vs Asynchronous Programming in JavaScript:</strong></h3><h3><strong>1. Synchronous:</strong></h3><p>It means that it is a technique that executes instructions line by line in the order that it appears in the program. Each instruction or task must wait for the previous one to complete before it can begin.</p><p>Ex:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*FEo74EMvsyNEXs_1qQRQew.png" /><figcaption>synchronous behavior</figcaption></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*rhFFzlqqVNkr906kPAemQg.png" /><figcaption>Output</figcaption></figure><p>The JavaScript interpreter indeed moves line by line, so the output of our example will be as expected: first, the data of the file will be printed, and then the output of our log statement. However, what if the synchronous function, readFileSynctakes longer to execute than we anticipated? In this case, our “Important Data!” will have to wait, which can become problematic.</p><h3>Why is synchronous behavior a problem?</h3><blockquote>Think about it this way: imagine you’re waiting in a line at a coffee shop, and the person in front of you is taking an unusually long time to order their drink. As a result, you’re stuck waiting and can’t move forward in the line until they’re done. This can be frustrating, especially if you’re in a hurry or have other things to do.</blockquote><p>In the same way, when a <strong>synchronous function</strong> takes a long time to execute, it can create a bottleneck that slows down the entire program.</p><p>Similarly, as we know Javascript runs in browsers that are dependent on user interactions. When a JavaScript function is called and it is by default synchronous, meaning that it takes time to execute and blocks further statements until it’s finished. This can create a problem for the user because, for example, if they click on a button and an event is called, it will be added to the call stack but won’t be processed until the blocking of the synchronous function is completed.</p><p>This delay can make the user feel like the website or application is unresponsive or slow to load, which can lead to frustration and a negative experience.</p><h3>2. Asynchronous:</h3><p>It is a technique that enables your program to start a potentially long-running task and still be able to be responsive to other events while that task runs, rather than having to wait until that task has finished.</p><p>As the name implies, “<strong>asynchronous</strong>” is indeed the opposite of “synchronous”. In general, we can use the “<strong>setTimeout</strong>” function to achieve asynchronous behavior in our code. This allows us to execute certain tasks without waiting for other tasks to complete, resulting in faster and more efficient code. as shown below:</p><p>Ex:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*2_Kbkfq20ryHsrEUG8EpqA.png" /><figcaption>asynchronous behavior</figcaption></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*uHhFXLN9ItzUi8dFAEOJOg.png" /><figcaption>output</figcaption></figure><p>Even though JavaScript is a line-by-line and block-oriented language, it still allows for the use of asynchronous functions like “<strong>setTimeout</strong>”. When “<strong>setTimeout</strong>” is called, the interpreter immediately passes over it and continues executing the rest of the code.</p><p>The example above can be <strong>confusing in terms of understanding</strong>, how it works <strong>behind the scenes in JavaScript</strong>, especially since JavaScript is a <strong>single-threaded</strong> language. It may seem counterintuitive how code can continue executing and display the console log statement “Important Data!” before the 2-second delay specified in the “<strong>setTimeout</strong>” function has elapsed.</p><p>So the answer to the above question will be Although JavaScript provides the “<strong>setTimeout</strong>” function, it is the browser or the interpreter that handles the asynchronous behavior.</p><p>As you can see in the setTimeout function, there is typically an <strong>arrow function</strong> included as a callback. These callbacks are commonly known as <em>asynchronous callbacks</em>. Whenever these callbacks are invoked, the interpreter can detect this and removes them from the call stack. The callbacks are sent to complete their task to <strong>web APIs</strong>, and after completion, they are pushed into a <strong>task queue </strong>which is managed by the browser. This allows for the smooth execution of subsequent functions in the call stack.</p><blockquote><strong>Note</strong>: setTimeout is just a function of javascript that calls out the code which is part of <strong>Web API </strong>which the browser provides for us.</blockquote><p>Alright, so it seems like you’ve grasped the concept that asynchronous behavior in JavaScript is due to <strong>callbacks</strong> being removed from the call stack and sent off to complete their tasks in the <strong>web APIs</strong>. Once they finish, they’re added to a <strong>task queue(aka callback queue)</strong>, now who is responsible for sending them back to the call stack? And how does this happen? Well, my friend, that’s where the <strong>event loop</strong> comes in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mCTrLQ9H82ika8RE0PthBg.gif" /><figcaption>The backend of asynchronous behavior</figcaption></figure><h3>B.) Event Loops:</h3><p>Its job is to constantly monitor the call stack and the task queue and to push items from the <strong>task queue</strong> onto the <strong>call stack</strong> when the <strong>call stack</strong> is empty.</p><p>The following image explains everything:</p><p><strong>Step 1:</strong> As soon as the first log statement is pushed into the stack, it prints “Hello guy” and exits.</p><p><strong>Step 2:</strong> Then interpreter inserts “<strong>setTimeout”</strong> into the stack, but once it detects that there is a callback involved, it pops it and sends it to the web APIs (written in C++), which will execute the timer and then send it to the <strong>task queue</strong>. In the meantime, the last log statement has been displayed “Bye !”.</p><p><strong>Step 3:</strong> Once the “<strong>event loop”</strong> realizes that there is something in the queue that is waiting and the stack is empty, it pops the task from the queue and pushes it to the stack. Stack further pops it to the browser.</p><p>This is how the asynchronous behavior works out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7pYjFCHN_x_Vx65xpF1C0w.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f7cddbf6712" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Compelling Reasons to Learn JavaScript in 2023: Unleash Your Web Development Potential!]]></title>
            <link>https://medium.com/@gautambhargav644/3-compelling-reasons-to-learn-javascript-in-2023-unleash-your-web-development-potential-4dc23a7f2e3c?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dc23a7f2e3c</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[trending]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Tue, 21 Feb 2023 02:30:06 GMT</pubDate>
            <atom:updated>2023-02-21T02:30:06.162Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*oA_bQSOIDdmUTQ3btHHM3g.jpeg" /></figure><p>Are you ready to unlock your web development potential? Look no further than JavaScript, the dynamic and versatile programming language that has been a mainstay in web development for years. In 2023, learning JavaScript will be more crucial than ever before. With its ability to create interactive and cutting-edge web applications, this language has become an indispensable tool for developers at all levels. In this article, we’ll reveal five reasons why learning JavaScript is the ultimate way to stay at the forefront of web development in the years to come. Get ready to take your skills to the next leve<strong>l!</strong></p><h3><strong>1. Popularity:</strong></h3><p>Do you want to stay ahead of the curve and maximize your earning potential as a programmer? Look no further than the most popular language of 2022 — JavaScript! Whether you’re driven by your passion for technology or your desire to stay up to date, JavaScript is the language you can’t afford to ignore. According to the StackOverflow survey of 2022, JavaScript is the language that tops the charts <em>(Image 1.0)</em>, with its popularity continuing to soar. By adding JavaScript to your toolbag for 2023, you’ll be able to seize new opportunities and enhance your skills. So, if you’re ready to level up your programming game, it’s time to embrace the power of JavaScript!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sABrBDsNIeLTq3EcATqBrA.png" /><figcaption>Image 1.0</figcaption></figure><h3>2. It works in the browser:</h3><p>And the best part about JavaScript’s popularity is that it’s more than just a trend. As the world becomes increasingly dependent on browsers, the need for web developers who are proficient in JavaScript is only going to increase. This versatile language allows developers to create stunning web applications, from interactive maps and charts to real-time chat applications and beyond.</p><p>While there are a few other languages that can run in the browser, none of them come close to the simplicity and ease of use that JavaScript provides. And with no need to set up a development environment on your PC like other languages, all you need is a modern browser like Chrome or Firefox to start coding and experimenting.</p><h3>3. Versatile programming language:</h3><p>JavaScript is more than just a language for web development. In fact, it’s an incredibly versatile programming language that can be used across a wide range of fields. Here are just a few examples:</p><ol><li><strong>Web Development </strong>(Frontend &amp; Backend): JavaScript is the go-to language for frontend development with popular frameworks like React and Vue. It’s also used on the backend with popular tools like Node.js.</li><li><strong>App Development:</strong> JavaScript can be used to build native apps with frameworks like React Native, making it a great choice for mobile app development.</li><li><strong>Desktop Applications</strong>: With the help of Electron.js, developers can use JavaScript to build desktop applications, just like the Atom editor.</li><li><strong>Blockchain:</strong> JavaScript can also be used to create backend support for Ethereum smart contracts, making it a popular choice for blockchain development.</li><li><strong>Machine Learning:</strong> TensorFlow.js is a popular library for machine learning in JavaScript, allowing developers to use JavaScript for data science and artificial intelligence.</li><li><strong>IoT:</strong> JavaScript can also be used in IoT devices like Raspberry Pi, making it a powerful tool for the internet of things.</li></ol><p>With its versatility and vast community support, JavaScript has transformed the world of coding, and the possibilities are endless. Whether you’re a seasoned developer or a beginner, learning JavaScript can help you stay ahead of the curve and explore new avenues of innovation.</p><p>So why limit yourself to a single programming language when you can master a superpower like JavaScript? Unleash your potential and take your coding skills to new heights with JavaScript.</p><p><em>“If you found this blog helpful and informative, don’t forget to hit that follow button to stay up-to-date with the latest programming trends and tips.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dc23a7f2e3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pure and Impure Functions in Programming.]]></title>
            <link>https://medium.com/@gautambhargav644/pure-and-impure-functions-in-programming-9727fde1b879?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9727fde1b879</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 04:10:44 GMT</pubDate>
            <atom:updated>2023-01-18T04:10:44.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q96XfZdOnO5LQoFNtXu1MA.png" /></figure><p>Often, these terms come up in interviews and in programming, so let’s look at pure and impure functions and learn about them.</p><h3>Impure Functions:</h3><blockquote>Functions having one or more side effects are called impure functions.</blockquote><h4>What are the side effects?</h4><p>Essentially, these are effects caused by external code in a function that doesn’t belong to it. Let’s understand using examples.</p><pre>const [count, setCount] = useState(0);<br><br>const increment=()=&gt;{<br>   setCount(count+1);<br>   if(count&gt;3) return false;<br>   else return true;<br>}</pre><p>now this usage of count in the function increment gives it side effects such as:</p><ol><li>The output of the function depends entirely on the state of the count.</li><li>In the case where the count was not even initialized, then the function would have an error, which makes it dependent on the count.</li><li>Modifying external variables affects the function because it modifies their state.</li><li>As the function is not deterministic, reading it alone won’t yield a predictable result. You should also know the current state of the count as well.</li></ol><p><em>Now that you know what an impure function is, check the following function and see if it is impure or not:</em></p><pre>const print=()=&gt;{<br>   console.log(&quot;Hello&quot;);<br>}</pre><p>This is an impure function…I’m sure you’re confused but think about it, what is a console? A console is an object that provides access to the browser debugging console, so this will also be considered external code.</p><p>Basically The console.log() command tells the program to make changes to the console’s current state.</p><h3>Pure Functions:</h3><p>Having a good understanding of impure functions will make it much easier for you to understand pure functions.</p><blockquote>Pure functions are those that don’t have any side effects and always produce the same output for the same inputs.</blockquote><pre>const increment=(num)=&gt;{<br>  return num+1;<br>}</pre><p>The above function has no external dependencies and completely relies on its own logic. No matter how many times the input 9 is passed to the function, the output will always be 10.</p><h3>Benefits of Pure Functions:</h3><ol><li>As pure functions are predictable and reliable, debugging them is easy, since any errors will be caused by the function itself.</li><li>Due to their lack of dependency on libraries or frameworks, pure functions are lightweight and work fine on any platform.</li><li>The global states do not need to be updated or modified, so these functions are faster than regular functions.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9727fde1b879" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding your data:]]></title>
            <link>https://medium.com/@gautambhargav644/we-are-surrounded-by-data-but-starved-for-insights-f872bbd91813?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f872bbd91813</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Tue, 18 Oct 2022 16:49:41 GMT</pubDate>
            <atom:updated>2023-01-18T09:53:33.201Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays, data plays an increasingly important role in our personal and professional lives. Investing in the right places at the right time, buying the right things, going to new places when we should go, etc., are all made easier by it. Marketers use data to determine which audience to target, what message to send, and what offer to make. That’s the power of data; there’s ample data out there to help us make these important decisions. That’s why we must first understand data carefully so that it won’t lead to erroneous conclusions.</p><p>As part of this article, we will describe the steps we can take to get a better understanding of the data to ease further data analysis.</p><blockquote><strong>It is important to ask the following good questions in order to gain a better understanding of data:</strong></blockquote><pre>import pandas as pd<br>df=pd.read_csv(&#39;train.csv&#39;)</pre><h3><strong>Q1.How big is the data?</strong></h3><pre>df.shape<br>#output will be a tuple as (row,column)</pre><h3><strong>Q2.What does the data look like?</strong></h3><pre>df.head()</pre><p>The above command will return the first five rows of the data, but this could be misleading considering that we are judging the data of 12000 or more rows based on the first five rows. Hence, we should use the sample command which picks randomly five rows from the data for better understanding.</p><pre>df.sample(5)</pre><h3><strong>Q3.What are the data types of columns?</strong></h3><pre>df.info()<br><strong><em>--(Fig-Image1)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*uS3DsogL4JczTde_LOlFCA.png" /><figcaption><strong><em>Fig-Image1</em></strong></figcaption></figure><h3><strong>Q4.Are there any missing values in your data?</strong></h3><p>If values are missing completely at random, the data sample is likely still representative of the population. But if the values are missing systematically, the analysis may be biased.</p><pre>df.isnull().sum()<br><strong><em>--(Fig-Image2)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*CtUuGj0KqgiHvwzPZRa-lw.png" /><figcaption><strong><em>Fig-Image2</em></strong></figcaption></figure><h3>Q5. <strong>What does the data look like statistically</strong>?</h3><p>We can generate descriptive statistics that summarize the central tendency, dispersion, and shape of datasets’ distribution excluding NaN values.</p><pre>df.describe()<br><strong><em>--(Fig-Image3)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*5plLmwkOpy0q3LcEC2uj7Q.png" /><figcaption><strong><em>Fig-Image3</em></strong></figcaption></figure><h3>Q6.Are there any duplicate values in the data?</h3><p>Datasets that contain duplicates may contaminate the training data with the test data or vice versa.</p><pre>df.duplicated().sum()<br>#output:number of duplicate values</pre><h3>Q7.What is the correlation between columns?</h3><p>Correlation analysis has the main benefit of helping us determine which variables to examine further, as well as allowing us to test hypotheses rapidly.</p><pre>df.corr()<br><strong><em>--(Fig-Image4)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Vo-X6EwwHhkaDWi7fyZMoA.png" /><figcaption><strong><em>Fig-Image4</em></strong></figcaption></figure><p>A positive correlation result means that both variables increase in relation to each other, while a negative correlation means that as one variable decreases, the other increases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f872bbd91813" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Data Analysis:]]></title>
            <link>https://medium.com/@gautambhargav644/the-art-of-data-analysis-164b56eeae28?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/164b56eeae28</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analytics-tools]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 21:16:06 GMT</pubDate>
            <atom:updated>2022-10-16T21:19:23.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*yR9ithXv1gG5-RaroieqCg.png" /></figure><blockquote><strong>Data Analysis: </strong>It is a process of inspecting,cleansing,transforming and modeling data with the goal of discovering useful information,informing conclusions and supporting decision-making.</blockquote><p><strong>What makes data analysis so important today?</strong></p><p>The importance of data analytics lies in the fact that it helps businesses optimize their performance. In addition, It provides in-depth insights into data and examines large amounts of data to uncover hidden patterns, correlations, and other insights.</p><blockquote><strong>Data Analysis process:</strong></blockquote><ol><li><em>Asking questions about the data.</em></li><li><em>Data Wrangling or Data preprocessing.</em></li><li><em>Exploratory data analysis.</em></li><li><em>Drawing conclusions from the preprocessed data.</em></li><li><em>Communicating Results.</em></li></ol><blockquote><strong>1. Asking questions:</strong></blockquote><p>Our next step is to ask ourselves “<strong>what conclusions are we trying to draw from the data?</strong>”, and “<strong>what is our subject of expertise?</strong>” i.e. banking, stocks, sports, etc.</p><blockquote><strong>2. Data Wrangling/Data Prrprocessing:</strong></blockquote><p>It is the process of transforming and mapping data from one “raw” data form into another format with the intent of making it more appropriate and valuable for a variety of downstream purposes such as analytics.</p><p><strong>Process in Data Wrangling:</strong></p><ul><li><strong>Gathering data</strong>: through <em>CSV</em> files, <em>API</em>s, <em>Web scraping</em>, and <em>Databases</em>.</li><li><strong>Assessing data</strong>: getting information about <em>rows and columns of data, data types of various columns</em>, and a <em>high-level mathematical overview of the data</em>. (data.describe())</li><li><strong>Cleaning data</strong>: Replace or reassign missing data, remove duplicates, and correct incorrect data types.</li></ul><blockquote><strong>3. Exploratory data analysis:</strong></blockquote><ul><li><strong>Exploring data</strong>: Finding correlation and covariance, Doing univariate and multivariate analysis, and by plotting graphs.</li><li><strong>Augmenting data</strong>: For instance, removing outliers, adding new columns, and so on, can be done as part of feature engineering.</li></ul><blockquote><strong>4. Drawing Conclusion</strong>:</blockquote><p>Using any of these, the conclusion can be drawn:</p><ul><li><strong>Machine learning</strong>: Implementing different algorithm to find conclusions.</li><li><strong>Inferential Statistics</strong>: Drawing inferences about the population data from sample data.</li><li><strong>Descriptive Statistics</strong>: It is a means of describing features of a data set by generating summaries about data samples.</li></ul><blockquote><strong>5</strong>. <strong>Communicating Results/Data Storytelling:</strong></blockquote><ul><li>In-person.</li><li>Through Reports.</li><li>Blog Posts.</li><li>Through PPTs or Slide decks.</li></ul><p><strong>Note</strong>: <em>Although the above steps are interconnected, they don’t need to be followed in the given order. As an example, maybe we need to do data manipulation between drawing conclusions.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*8QeTwztRLv2Bo8PuWxYu0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=164b56eeae28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Seaborn: Statistical data visualization]]></title>
            <link>https://medium.com/@gautambhargav644/seaborn-statistical-data-visualization-d2652e59ddc5?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2652e59ddc5</guid>
            <category><![CDATA[seaborn]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Thu, 13 Oct 2022 05:46:26 GMT</pubDate>
            <atom:updated>2022-10-13T05:46:26.829Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Seaborn</strong>: Data visualization library based on <a href="https://medium.com/@gautambhargav644/matplotlib-visualization-with-python-3e686aca2631">matplotlib</a> .In addition, it provides high-level interfaces for drawing attractive and informative statistical graphics.</blockquote><p><strong>What makes Seaborn better than Matplotlib?</strong></p><ol><li>Unlike seaborn functions, Matplotlib doesn’t work well with data frames.</li><li>Seaborn comes with numerous customized themes and high-level interfaces.</li></ol><pre>#can be installed using below command<br>pip install seaborn</pre><ul><li><strong>As we go along, we will use some random datasets that seaborn itself provides. You can find all the data </strong><a href="https://github.com/mwaskom/seaborn-data"><strong>here</strong></a>.</li></ul><blockquote><strong>Seaborn totally depends on three functions : </strong>We can call particular functions for particular graphs, such as sns.boxplot for boxplots. Despite this, the functions below can create any graph.</blockquote><ol><li><strong>relplot</strong>: Used for relational plots.</li><li><strong>displot</strong>: Used for distributional plot</li><li><strong>catplot</strong>: Used for categorical plots.</li></ol><h3><strong>1. Relplot</strong>:</h3><p>The default plot kind is a <strong>scatter plot</strong>.</p><blockquote><strong>Scatter Plots using Searborn:</strong></blockquote><pre><strong>import seaborn as sns</strong></pre><pre><strong>d=sns.load_dataset(&#39;penguins&#39;)<br>sns.relplot(x=&quot;bill_depth_mm&quot;,y=&quot;bill_length_mm&quot;,data=d)<br><em>--(Fig.Image1)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*xDmJ5BAiP3cPK6oog53hZA.png" /><figcaption><strong><em>Fig.Image1</em></strong></figcaption></figure><p>However, the graph does not give us any information on which species corresponds to which bill_length and bill_width. This can be accomplished by passing property ‘hue’ as ‘species’.</p><pre>d=sns.load_dataset(‘penguins’)<br>sns.relplot(x=&#39;bill_depth_mm&#39;,y=&#39;body_mass_g&#39;,data=d,<strong><em>hue=&#39;species&#39;</em></strong>)<br><strong><em>--(Fig.Image2)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*KpbmWA7Q_RCrmQUsReUd8A.png" /><figcaption><strong><em>Fig.Image2</em></strong></figcaption></figure><blockquote><strong>Line Graph:</strong> In the above code, we can pass a single argument kind=’line’ to make it a line graph. That’s how simple Seaborn is.</blockquote><pre>d=sns.load_dataset(‘penguins’)<br>sns.relplot(x=&#39;bill_depth_mm&#39;,y=&#39;body_mass_g&#39;,data=d,hue=&#39;species&#39;, <strong>kind=&#39;line&#39;</strong>)<br><strong><em>--(Fig.Image3)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*5jJtLUXczNJSS-yGMoX8VA.png" /><figcaption><strong><em>Fig.Image3</em></strong></figcaption></figure><h3>2. Displot:</h3><p>The default plot kind is a <strong>histogram</strong>.</p><pre>penguins <strong>=</strong> sns<strong>.</strong>load_dataset<strong>(</strong>&quot;penguins&quot;<strong>)</strong><br>sns<strong>.</strong>displot<strong>(</strong>data<strong>=</strong>penguins<strong>,</strong> x<strong>=</strong>&quot;flipper_length_mm&quot;<strong>)<br><em>--(Fig.Image4)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*f1un2yTkwwdWA6NuWZT4gw.png" /><figcaption><strong><em>Fig.Image4</em></strong></figcaption></figure><p>While in histogram mode, it is also possible to add a KDE(kernel density estimates) curve:</p><pre>penguins <strong>=</strong> sns<strong>.</strong>load_dataset<strong>(</strong>&quot;penguins&quot;<strong>)</strong><br>sns<strong>.</strong>displot<strong>(</strong>data<strong>=</strong>penguins<strong>,</strong> x<strong>=</strong>&quot;flipper_length_mm&quot;,<strong>kde=True)<br><em>--(Fig.Image5)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*Q5I1yWpwyy-EVM45CzJudQ.png" /><figcaption><strong><em>Fig.Image5</em></strong></figcaption></figure><h3>3. Catplot:</h3><p>By default, the visual representation will be a <strong>jittered strip plot</strong>:</p><pre>df = sns.load_dataset(“iris”)<br>sns.catplot(data=df, x=”sepal_width”, y=”species”)<br><strong><em>--(Fig.Image6)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*c1j8Oy5vRsEhQUAerSQyYw.png" /><figcaption><strong><em>Fig.Image6</em></strong></figcaption></figure><blockquote><strong><em>Box Plots: </em></strong><em>These graphs are used to show distribution of numeric data values,especially when we want to compare them between multiple groups.</em></blockquote><pre>df = sns.load_dataset(“iris”)<br>sns.catplot(data=df, x=”sepal_width”, y=”species”,<strong>kind=”box”</strong>)<strong><br><em>--(Fig.Image7)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*8dnQS2fZ0upDFFMTR7rcuA.png" /><figcaption><strong><em>Fig.Image7</em></strong></figcaption></figure><blockquote><strong>Violin plot: </strong>A violin plot is hybrid of box plaot and a kernel density plot,which shows peaks in the data.It is used to visualize the distribution of numerical data.Unlike a box plot that can only show summary statistics ,violin plot depicts summary statistics and the density of each variable.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_nnrPDnnFU-ySoES5G2sQ.png" /><figcaption>Violin Plot Simplification</figcaption></figure><pre>df = sns.load_dataset(“iris”)<br>sns.catplot(data=df, x=”sepal_width”, y=”species”,<strong>kind=”violin”</strong>)<br><strong><em>--(Fig.Image8)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*8ybITqhbxg9UnihOP_xSEg.png" /><figcaption><strong><em>Fig.Image8</em></strong></figcaption></figure><h3><strong>Different color palettes in seaborn</strong>:</h3><p>Seaborn makes it easy to use colors that are well-suited to the characteristics of your data and your visualization goals.</p><blockquote><strong>Color palettes</strong>:</blockquote><pre>sns.color_palette(&quot;Set2&quot;)<br><strong><em>--(Fig.Image9)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*3LDM5gOm4YUa2OaDR27BKg.png" /><figcaption><strong><em>Fig.Image9</em></strong></figcaption></figure><blockquote><strong>Perceptually uniform palettes:</strong></blockquote><pre>sns.color_palette(&quot;rocket&quot;, as_cmap=True)<br><strong><em>--(Fig.Image10)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*JY8ngyxaKBNhw0KR0cKGQA.png" /><figcaption><strong><em>Fig.Image10</em></strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2652e59ddc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Matplotlib: Visualization with Python]]></title>
            <link>https://medium.com/@gautambhargav644/matplotlib-visualization-with-python-3e686aca2631?source=rss-d0b90c6ce80e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e686aca2631</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Bhargav Sharma]]></dc:creator>
            <pubDate>Tue, 11 Oct 2022 21:43:23 GMT</pubDate>
            <atom:updated>2022-10-12T21:41:59.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*yx09L8VGCw74gdAyplkzaQ.png" /></figure><blockquote><strong>Matplotlib: </strong>A library for creating static,animated and interactive visualizations in python.It provides an object-oriented programming methods for embedding plots into applications using GUI toolkits such as <a href="https://en.wikipedia.org/wiki/Tkinter">Tkinter</a> and <a href="https://en.wikipedia.org/wiki/WxPython">wxPython</a>.</blockquote><pre>#can be installed using below command<br>pip install matplotlib</pre><blockquote><strong>Prerequisites: </strong>Basic knowledge of<strong> </strong><a href="https://medium.com/@gautambhargav644/numpy-pythons-library-45fa16c4ffc">Numpy</a>,<a href="https://medium.com/@gautambhargav644/pandas-pythons-library-9682d840020f">Pandas</a>.</blockquote><blockquote><strong>Line graphs: </strong>These type of graphs are used to track the changes over the short and long period of time.</blockquote><pre>import matplotlib.pyplot as plt</pre><pre><strong>x=[1,2,3]<br>y=[2,4,6]<br>plt.plot(x,y)</strong></pre><pre><strong>plt.figure(figsize=(5,3),dpi=100)</strong> #determining the size of the graph<br>(length,breadth) in inches in figsize and dpi pixel per inch </pre><pre>#setting up the title and axis of the graph<strong><br>plt.title(&#39;First Graph&#39;,fontdict={&#39;fontsize&#39;:15}) </strong>#fontdict is optional<strong><br>plt.xlabel(&#39;x-axis&#39;,fontdict={&#39;fontsize&#39;:12})<br>plt.ylabel(&#39;y-axis&#39;,fontdict={&#39;fontsize&#39;:12})<br>plt.show()<br>--<em>(Fig.Image1)</em></strong></pre><pre>#we can also change the axis&#39; ticks<br><strong>plt.xticks([1,2,3,4])<br>plt.yticks([0,2,4,6,8,10])</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*xklSuu5tuAMZI1FQEAKOLg.png" /><figcaption><strong>Fig.Image1</strong></figcaption></figure><blockquote><strong>Modifications:</strong></blockquote><pre><strong>plt.plot(x,y,label=&#39;legend&#39;,color=&#39;grey&#39;,linewidth=3,marker=&#39;^&#39;,markersize=8,markeredgecolor=&#39;blue&#39;,linestyle=&#39;--&#39;)<br>plt.legend()<br>plt.show()</strong><br><strong>--<em>(Fig.Image2)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*ANleviErmOfmjigkpoV1eA.png" /><figcaption><strong><em>Fig.Image2</em></strong></figcaption></figure><p>Instead of writing so many arguments, matplotlib has shorthand notation for this [color][marker][line].</p><pre><strong>plt.plot(x,y,&#39;y^--&#39;,label=”legend”)</strong> #color:y,marker:^,line:--<br><strong>plt.legend()</strong><br><strong>plt.show()<br>--(<em>Fig.Image3</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*owf37CsnLrT0ERrLgAbhuQ.png" /><figcaption><strong><em>Fig.Image3</em></strong></figcaption></figure><pre><strong>plt.savefig(&#39;graph.png&#39;,dpi=300)</strong> #saves the graph in the current directory</pre><blockquote><strong>Higher order line graphs:</strong></blockquote><pre><strong>x1=np.arange(0,4.5,0.5)<br>plt.plot(x1[:4],x1[:4]**4,&#39;r.--&#39;)<br>plt.plot(x1[3:],x1[3:]**4,&#39;y.--&#39;)<br>plt.show()</strong><br><strong>--(<em>Fig.Image4</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*0WisLsQdVqmJJ7FmcaRbUg.png" /><figcaption><strong><em>Fig.Image4</em></strong></figcaption></figure><blockquote><strong>Bar Charts: </strong>Bar charts are used when we have to show segments of information.Vertical bar charts are useful to compare different categorical or discrete variables for example: age-groups,classes etc.</blockquote><pre><strong>labels=[‘X’,’Y’,’Z’]<br>values=[2,4,1]</strong></pre><pre><strong>bars=plt.bar(labels,values)<br>bars[1].set_hatch(‘O’) # can try out *,+,/</strong></pre><pre><strong>plt.show()<br>--(<em>Fig.Image5</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*JvcJqOA0isPu7fFMHzWosg.png" /><figcaption><strong><em>Fig.Image5</em></strong></figcaption></figure><blockquote><strong>Histograms:</strong>These graphs are used to summarize discrete or categorical variables that are measured on an interval scale.for example:inflation on scale of year etc.</blockquote><pre><strong>x=np.random.randint(150,size=10)<br>plt.hist(x)<br>plt.show()</strong><br>--<strong>(<em>Fig.Image6</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*J8uYkv-KT85ng4_abElg1g.png" /><figcaption><strong><em>Fig.Image6m</em></strong></figcaption></figure><blockquote><strong>Pie Charts: </strong>A pie chart expresses a part-to-whole realtionship in our data.</blockquote><pre><strong>values=[4234,34324]<br>labels=[‘Males’,’Females’]<br>colors=[‘#eddcb2’,’#b2d6ed’]</strong></pre><pre><strong>plt.pie(values,labels=labels,colors=colors,autopct=’%0.2f %%’)<br>plt.title(“Ratio of Males and Females in an area”)</strong></pre><pre><strong>plt.show()</strong><br>--<strong>(<em>Fig.Image7</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*L1OQDk6Q9ScMOIBrkySLSQ.png" /><figcaption><strong><em>Fig.Image7</em></strong></figcaption></figure><p>We can separate each piece in pie charts using the ‘explode’ property.</p><pre><strong>values=[4234,34324,4000,3300,4100]<br>labels=[‘A’,’B’,’C’,’D’,’E’]<br>colors=[‘#eddcb2’,’#b2d6ed’,’#deedd3&#39;,’#d4a7db’,’#f2999f’]</strong></pre><pre><strong>explode=[0,0,0.4,0.4,0]</strong></pre><pre><strong>plt.pie(values,labels=labels,colors=colors,autopct=’%0.2f %%’,pctdistance=0.8,explode=explode)</strong> #pctdistance property maintains the distance of written %ages inside pie charts</pre><pre><strong>plt.title(&#39;Market Share&#39;)<br>plt.show()<br></strong>--<strong>(<em>Fig.Image8</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*1ZfKxcdzuf8cEHq4Pq97IQ.png" /><figcaption><strong><em>Fig.Image8</em></strong></figcaption></figure><blockquote><strong>Box Plots: </strong>These graphs are used to show distribution of numeric data values,especially when we want to compare them between multiple groups.</blockquote><ul><li>Take a look at the image below to find out how box plots are simplified.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufbE-ElyZnuos09oEvo0sg.jpeg" /><figcaption><strong>Box Plot Simplification</strong></figcaption></figure><pre><strong>team1=[300,310,340,230,210,160,320]<br>team2=[400,240,300,320,187,410,370]<br>team3=[200,100,210,170,180,140,220]</strong></pre><pre><strong>plt.figure(figsize=(5,7))<br>labels=[‘TEAM1’,’TEAM2&#39;,’TEAM3&#39;]<br>plt.boxplot([team1,team2,team3],labels=labels)</strong></pre><pre><strong>plt.title(‘Team Comparision’)<br>plt.xlabel(‘Teams’)<br>plt.ylabel(‘Overall Ratings’)</strong></pre><pre><strong>plt.show()<br></strong>--<strong>(<em>Fig.Image9</em>)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*Ki0v8wVCTJRRbJYYlJu8uA.png" /><figcaption><strong><em>Fig.Image9</em></strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e686aca2631" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>