<?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 Harshit Yadav on Medium]]></title>
        <description><![CDATA[Stories by Harshit Yadav on Medium]]></description>
        <link>https://medium.com/@harshit_yadav?source=rss-fe5a4924eff8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9mGZUeXtZmXNj5jK52d1Mw.jpeg</url>
            <title>Stories by Harshit Yadav on Medium</title>
            <link>https://medium.com/@harshit_yadav?source=rss-fe5a4924eff8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:28:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshit_yadav/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[The best and easiest way to manage your Aave v3 position]]></title>
            <link>https://medium.com/instadapp/the-best-and-easiest-way-to-manage-your-aave-v3-position-a073a117d3a3?source=rss-fe5a4924eff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a073a117d3a3</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[instadapp]]></category>
            <category><![CDATA[yield-farming]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Harshit Yadav]]></dc:creator>
            <pubDate>Tue, 12 Apr 2022 19:29:05 GMT</pubDate>
            <atom:updated>2022-04-12T19:29:05.761Z</atom:updated>
            <content:encoded><![CDATA[<h4>Utilize your assets to the fullest with Instadapp</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1weejaLgjWbsZjSJku3eLw.png" /></figure><p>“AAVE this name has made its mark in the world of DeFi; it is one of the oldest players in the DeFi protocols and is one of the top markets by holdings. AAVE made decentralized lending and borrowing a reality showing users they could beat the bank’s outdated loan-taking procedures. <strong>AAVE is currently #3 (at the time of writing) in the top 10 list of DeFi protocols with billions locked in billions of USD value</strong>. AAVE maintains that position by continuing to create better features with each release.</p><p>At Instadapp, we keep perfecting ourselves to better serve our community! We help users make the best of their assets by providing them out-of-the-box strategies and ways to increase their yields and manage their DeFi assets. We have prepared a brand new dashboard ready to help you manage your positions on AAVE v3 efficiently.</p><p>AAVE v3 is already integrated and live with mind-blowing strategies that can drastically improve yield generation by making better use of your assets.</p><p>This guide introduces one of the many ways you can use Instadapp to make better use of your assets. Before we move on with the major updates in AAVE V3, it will be helpful to learn how AAVE V3 is different from AAVE V2</p><p>The V2 protocol provided users with vital functionalities such as <em>Debt Tokens</em>, <em>Collateral Swaps</em>, <em>Batch Flashloans</em>, however, AAVE v2 also has some areas for improvement: It is still challenging to list new tokens, most of the protocol liquidity sits idle in the protocol smart contracts, and borrowing power can be improved etc. <strong>AAVE V3 is a step toward improving those specific areas by improving Capital Efficiency, Protocol Safety, and the Decentralization of the protocol.</strong></p><p>Aave v3 came up with <strong>three notable updates</strong> which have been integrated at Instadapp, those changes are:</p><h4>High-Efficiency mode</h4><p>This update aims to provide users with <strong>the highest borrowing power out of their collateral</strong>. This feature restricts borrowers to borrow only the assets belonging to a specific category or pool, consisting of correlated assets (e.g., stETH, sETH, alETH), generally the assets that are derivatives of the same underlying asset. This helps the user by giving better predictability and providing better health factors with increased collateral factor and a super low 1% liquidation penalty.</p><h4><strong>Portal</strong></h4><p>As the blockchain industry is growing day by day, and many chains have come up with new features, it is still difficult if someone wants to shift their supplied assets or aTokens from one chain to another (e.g. Mainnet to Polygon). The AAVE protocol has come up with a new feature to deal with this issue. <strong>AAVE Portal creates bridges between the different iterations of the AAVE v3 protocol on different chains, helping users move supplied assets or aTokens from one chain to another.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3iyHjyP2DqzuUMg0eVfhzA.png" /></figure><h4><strong>Isolation Mode</strong></h4><p><strong>Isolation Mode makes listing new assets easier for the protocol.</strong> When a new token is listed in the Isolation mode, users can only borrow Stablecoins using it as collateral. While doing this, the user’s collateral should only consist of the Isolated token. <strong>This will allow the AAVE protocol to more quickly list newer or riskier assets while minimizing the risk to the overall protocol.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*dmtl3KWsL-W8Ag-jo-STyA.png" /></figure><h3>How to use AAVE V3 on Instadapp</h3><p>This blog section will help you learn how to use Instadapp Dashboard to manage your assets with AAVE v3. <em>This tutorial is performed on Polygon Mainnet.</em></p><p>You will need a web3 wallet like <a href="https://metamask.io/">Metamask</a> or <a href="https://rabby.io/">Rabby.io</a> with some asset, for example, MATIC. We will work with a minimal amount so that you can follow along.</p><p>This part of the blog contains 3 modules:</p><ul><li>Turning E-Mode ON</li><li>Supplying to E-Mode selected Asset</li><li>Borrowing on AAVE V3</li></ul><blockquote><em>𝘕𝘰𝘵𝘦 -&gt; </em>If you are not familiar to the Instadapp Platform, you can start with the guide <a href="https://guides.instadapp.io/managing-assets/managing-assets-on-instadapp/not-able-to-see-your-wallet-balance">here</a></blockquote><h4>Module 1: Turning E-Mode ON</h4><p>This section will introduce you AAVE V3, how to navigate to the AAVE V3 page and turning E-Mode ON for your desired category.</p><p><strong>Step 1</strong>: Move to ‘AAVE V3’ under ‘Protocols’ on the left sidebar then Click on ‘E-Mode’ to list all the categories present.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QOzSLrF4_q8Ngkye" /></figure><p><strong>Step 2</strong>: Find the category you would like high borrowing power for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0tY-nmkMyDNUWNFM" /></figure><p>As you can see, currently, two categories are listed here (more will be added overtime)</p><ol><li>All — This is the <strong>default mode</strong> set. It means that you have <strong>access to borrow all tokens</strong> depending on your collateral value.</li><li>Stablecoins — <strong>This mode allows you to borrow selected assets with 97% of collateral value.</strong> This means if you deposit 100 DAI, You can borrow up to 96.99 USDC or USDT.</li></ol><p>Note — <strong>Selecting Stablecoins will make AAVE restrict your borrowing power to only Stablecoins; however, you will still be allowed to supply other assets not under this category like Matic, but you cannot borrow them.</strong></p><p><em>Instadapp has a Unique way of tackling this. You can just create multiple DSA and manage them on Instadapp with different E-Mode per your need and liking. This is further explained in later sections of the blog.</em></p><p><strong>Step 3</strong>: Select your desired E-Mode by clicking on it.</p><p>We will be selecting the Stablecoins category for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tHhx2Et4aT9NgrDt" /></figure><p><strong>Step 4</strong>: Approve the transaction to enable your E-Mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NCM_z0t-ylFPDFAu" /></figure><p><strong>Step 5</strong>: See the ‘Enabled’ label on your selected category.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PPwFuoRhRzKMAkFY" /></figure><p>Move back to the 4th step and look for the C.F of DAI before enabling Stablecoin E-Mode, its C.F was 75%, but after selecting ‘Stablecoins’, you can see the C.F is now 97% for all Stablecoins.</p><h4>Module 2: Supplying to E-Mode selected Asset</h4><p>This module will introduce you to how to deposit your assets to AAVE V3 to earn interest on them.</p><p><strong>Step 1</strong>: Click on “Supply” under the desired asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_qXc1VQJGLAtcDEW" /></figure><p><strong>Step 2</strong>: Enter the amount you want to supply and earn interest on then click on Supply and confirm the transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7IAspaH6PTRI6NP7" /></figure><h4>Module 3: Borrowing on AAVE V3</h4><p>Now, as we selected the category “Stablecoins”, we can only borrow Stablecoins for this DSA for 97% Collateral Factor. Still, you can always create multiple DSA, each employing a different E-Mode Category and bypass this restriction.</p><p><strong>Step 1</strong>: Click on ‘Borrow’ under the allowed assets.</p><p>The allowed assets for the Stablecoins category are USDC, USDT, DAI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GS2TYoxxvIJWVpk5" /></figure><p><strong>Step 2</strong>: Enter the amount you want to borrow for your supplied collateral. Click on borrow to confirm the transaction.</p><p>As you can see here, we can borrow 9.699 USDC for 10 Supplied DAI because Collateral Factor is 97 %.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sYssjXDF8UyWLjuE" /></figure><h3>Why Instadapp?</h3><p>The DeFi community has trusted us with billions worth of USD into our protocol, we take this as a great honor and view it as our duty to serve the community with the best features and services! AAVE V3 is a critical upgrade to the DeFi ecosystem and we saw this as our duty to make it available at launch to our users! We worked day and night to make sure it was integrated into our platform at launch with the latest strategies to help you make the most out of your assets.</p><p>Now that we have expressed how influential these changes are, lets review all the new AAVE V3 features and the new exciting tactics Instadapp has to make the most of your assets!</p><blockquote>Note: The information below is provided for informational purposes and is not meant to constitute financial advice.</blockquote><h4>1. Strategies</h4><p>This section will introduce you to the strategies that Instadapp provides you with a single click. You can use these strategies with different assets depending on the market conditions. All the strategies can be found on the <strong>right sidebar under “Strategies”</strong> for AAVE protocol.</p><h4><strong>1.1. Leverage / Max Mining</strong></h4><p>This strategy involves <strong>borrowing against a collateral asset and depositing the borrowed asset back</strong> to the protocol. This is done to gain better farm yields, and a single click can leverage your position up to 2x-5x depending on the asset. (5x and higher with may be possible with AAVE V3 E-Mode) For example -</p><ul><li>You can borrow ETH debt by keeping deposited ETH as collateral and depositing the borrowed ETH as collateral to gain more exposure and better yield results.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cxyHgW34ec8Z2STTncBOA.png" /></figure><ul><li>You can borrow WBTC debt by keeping deposited USDC as collateral, swapping the borrowed WBTS with USDC, and then depositing that USDC back as collateral.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WX1BQTiZ4_Sasih_LqDFng.png" /></figure><h4><strong>1.2. Save / Unwind Mining</strong></h4><p>Using this strategy allows us to <strong>use the collateral asset to exchange and pay the debts</strong>. It is majorly used to deleverage a position. Example-</p><ul><li>You can withdraw ETH as collateral and pay back the ETH debt.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DfmSBNagNnxNtKeYq31DA.png" /></figure><ul><li>You can withdraw USDC as collateral, swap USDC with ETH and payback ETH debt.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*qU7F4yxL15Nbf5d4RyRxTA.png" /></figure><h4><strong>1.3. Collateral Swap</strong></h4><p>This strategy revolves around swapping your collateral for another collateral within the protocol that can be used when the collateral is bearish and you want to save your position from being liquidated. You can do this with a single click on Instadapp with your selected assets. Example-</p><ul><li>Withdraw the USDC as collateral, then swap the USDC with ETH and deposit the ETH collateral.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bdLwERvzA0pfAPMS9K9hQ.png" /></figure><p>We have many such strategies like Debt Swap, Deposit and Borrow, Payback and Withdraw, etc., which are <strong>used to earn a lucrative yield</strong> on the assets deposited by the user.</p><h4>2 Migrating AAVE position from V2 to V3 and Cross Chain</h4><p>AAVE V3 has undoubtedly come up with excellent features for the benefit of users. On Ethereum Mainnet the AAVE <strong>V2 positions on Mainnet will automatically be upgraded.</strong></p><p>But <strong>what if you have an AAVE V2 position on Polygon and want to reap the benefits of Polygon’s AAVE V3?</strong> This is the current situation: AAVE v3 on other chains will not be automatically converted to V3 but will exist alongside the current v2 markets. That means there will be two markets on networks like Avalanche and Polygon, AAVE v2 and a AAVE v3 market.</p><p><strong>What if you want to Migrate your AAVE positions completely from one chain to another chain?</strong></p><p>Instadapp is here to provide the flexibility you need in these changing times! Instadapp has two exciting tools you can use “<strong>Aave Migration</strong>” and “<strong>Inter Chain</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lutXzWYiXORVAX6qebKIyA.jpeg" /></figure><h4><strong>2.1. Aave Migration</strong></h4><p>Instadapp’s implementation of “Aave Migration” is our <strong>refinancing method!</strong> It works like magic to migrate your <strong>V2 positions to V3 positions on the same chain</strong>. That means you can migrate your V2 position on the Polygon to V3 with a single click. Easy!</p><p>The science behind this magic is simple, we make use of the <strong>Flash Loans to help you migrate</strong> your position completely from V2 to V3 in one transaction!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2QMzSH8Y40ZpdWQ6YzsOg.png" /><figcaption>Using Refinance feature (“Aave Migration”) to move position from V2 to V3</figcaption></figure><p>This was for refinancing your V2 position to V3 on the <strong>same chain</strong> But what if you want to move your position from one chain to another chain? Here is when Instadapp’s <strong>Inter Chain</strong> feature comes into use.</p><h4>3 Breaking the E-Mode restriction using multiple DSA</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z4SzFFg5zbQxLzNt" /><figcaption>Photo by <a href="https://unsplash.com/@an_ku_sh?utm_source=medium&amp;utm_medium=referral">Ankush Minda</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>High-Efficiency Mode or E-Mode is one of the main features that has been introduced in the V3 of AAVE. As explained earlier, you can use this feature to <strong>access higher borrowing power</strong> from your collateral with the condition that the lending and borrowing should happen within the same category of assets. You will have a higher borrowing power if you collateralize and borrow the assets that are <strong>derivatives of the same underlying asset</strong>, thus correlated in value. But to make use of this, all of your <strong>borrowed assets must be of the same category</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*aSoR7mw8m1PPCcpJ" /></figure><p>For example, in the image above, to choose the stable coin category, you will have to have all your borrowed assets to be in DAI, USDC and/or USDT to enjoy the fruits of 98% Collateral Factor and 1% Liquidation Penalty. But that poses restrictions over your assets. You just cannot borrow and supply other assets when your E-Mode is ON!!.</p><p>Here is when Instadapp’s robust Defi Smart Account(DSA) comes into use! You can think of the DSA as an account linked to your wallet’s address, and the beauty of <strong>DSA is that you can have</strong> <strong>multiple DSA’s linked to your single wallet</strong> <strong>address</strong>. The DSA works on top of Instadapp’s DeFi Smart Layer (DSL) which lets the DSA interact with other protocols. Now how does this help you?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N_6wFMd9IPs9n3U7" /></figure><p><strong>Each DSA functions as an individual account</strong> for all the protocols on Instadapp. For example, if you have three DSA’s linked to your wallet and all those three DSAs each have their own addresses, and they act as three separate accounts for the AAVE protocol. <em>This is because AAVE is account based, and treats each address as one account to its protocol.</em></p><p><strong>You can have multiple DSAs linked to your primary wallet, and you have complete access to all three.</strong> By utilizing multiple DSA accounts you can have each DSA handle one of the different E-Modes each! Not only is this better for managing more assets, you are able to get the most out of E-Mode and your assets! This is the Magic and power that Instadapp presents you with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFeRr7YTOoVWqQidNSIpvA.jpeg" /></figure><p>This was just one of the MANY use cases of Instadapp’s DSA for E-Mode. From simply account management, to more complex debt management there are many more strategies and use cases for DSAs! Let’s explore them all on <a href="https://instadapp.io/"><strong><em>Instadapp</em></strong></a>.</p><h3>Developer First</h3><p>Hey fellow developers! What if I tell you that you can Deposit 1 ETH to AAVE, Borrow 100 DAI and deposit those 100 DAI on Compound and all of this in nine function arguments (three per action) in one script? It sounds like magic! This is the magic of Instadapp’s innovative spells and cast functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jmPEC95F6l0vkn22nF8OA.jpeg" /></figure><p>To get started you need to install the <strong>dsa-connect</strong> package and set up the account. Thats it! Welcome to the magically realm of Instadapp Defi!</p><p>But what is this magic exactly? Instadapp works by integrating and creating a framework for a variety of protocol contracts to interact with one another. These functionalities are expressed through dsa-connectors enabling protocols to function with each other in a sequence or script. These scripts are what consists of a spell and cast functions.</p><p>You can think of <strong>spells as trailing function calls to different protocol’s smart contracts</strong> in the script sequence. For example, “Deposit 1 ETH to AAVE” is one spell added to the script, then “Borrow 100 DAI” is another spell added to the script, then “Deposit 100 DAI on Compound” is the third spell in the script then after adding all these in this sequence we can cast this script for execution and all these actions will be taken care of by the script. To learn more on setting up to cast the spells, follow the installation guide <a href="https://docs.instadapp.io/get-started/installation">here</a>.</p><p>Now how will the spell and cast function work and help us in the case of AAVE V3? We can make use of this in a similar fashion as the example mentioned above. We can add spells interacting with the AAVE V3 functions and cast them to execution. You can execute all sorts of strategies you have with this.</p><h4>Walkthrough</h4><p>What serves better to a developer than examples? We have created an example <a href="https://terminal.instadapp.io/LwbvI5dwx"><em>script</em></a> for you that can be executed at Instadapp’s <a href="https://terminal.instadapp.io/"><em>Terminal</em></a>. This example works with minimal funds to serve you for testing purposes. The <a href="https://terminal.instadapp.io/LwbvI5dwx"><em>script</em></a><em> </em>is a compilation of 4 spells that work in a sequence as follows:</p><blockquote>Note:- Please deposit 1 Matic in DSA before executing this script</blockquote><p>1. Deposit 1 Matic from DSA to the AAVE V3 Protocol.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdfb43ff659a7f4e12acff6cbb923a30/href">https://medium.com/media/fdfb43ff659a7f4e12acff6cbb923a30/href</a></iframe><p>2. Borrow 0.5 USDC.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25c42b07689fa5f028ca87e1cf1b940b/href">https://medium.com/media/25c42b07689fa5f028ca87e1cf1b940b/href</a></iframe><p>3. Swap the USDC with Matic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ead2500eb7c80d6782fac3258fe975a/href">https://medium.com/media/6ead2500eb7c80d6782fac3258fe975a/href</a></iframe><p>4. Deposit the Matic again to the protocol.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c450221a2b441c780ef2257e20a2042a/href">https://medium.com/media/c450221a2b441c780ef2257e20a2042a/href</a></iframe><p>The transaction details of the executed <a href="https://terminal.instadapp.io/LwbvI5dwx"><em>script</em></a> can be found <a href="https://polygonscan.com/tx/0x67c621099e68f1c2505bbe837afba61fa3e111aae946007ab0f2f10c0e637303"><em>here</em></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eN2xFCelUd6QZcgdgbss2g.png" /><figcaption><a href="https://polygonscan.com/tx/0x67c621099e68f1c2505bbe837afba61fa3e111aae946007ab0f2f10c0e637303">Link</a></figcaption></figure><h3>Wrapping up</h3><p>It’s great to see that you made it. It always feels good to learn something new. The Instadapp team is determined to bring you the latest DeFi updates and concepts. This guide introduced you to how you can not just manage but get the strategies, tactics and unique hacks to generate a better yield and manage your assets well using the robust UI of the Instadapp platform. Instadapp always loves to give back to the DeFi community by presenting the users with incredible opportunities and features. This guide was just an attempt to introduce you to one of the many ways you can use Instadapp’s platform to your advantage. There are many more exciting features on the Instadapp platform to help you manage your assets. To learn more about them all:</p><p>Join the Instadapp <a href="https://discord.gg/C76CeZc">Discord</a></p><p>Follow Instadapp on <a href="https://twitter.com/Instadapp">Twitter</a></p><p>Subscribe to the <a href="https://blog.instadapp.io/">Instadapp Blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a073a117d3a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/instadapp/the-best-and-easiest-way-to-manage-your-aave-v3-position-a073a117d3a3">The best and easiest way to manage your Aave v3 position</a> was originally published in <a href="https://medium.com/instadapp">Instadapp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Guide to Unsupervised Machine Learning — Clustering]]></title>
            <link>https://medium.com/codex/your-guide-to-unsupervised-machine-learning-clustering-10ea9cd26412?source=rss-fe5a4924eff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/10ea9cd26412</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Harshit Yadav]]></dc:creator>
            <pubDate>Wed, 16 Feb 2022 15:53:52 GMT</pubDate>
            <atom:updated>2022-03-06T17:05:51.898Z</atom:updated>
            <content:encoded><![CDATA[<h3>Your Guide to Unsupervised Machine Learning — Clustering</h3><p>Building Intuition and Logic for Clustering along with Visualisation of K-Means algorithm on a dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*wD3kqnBo6h3woCDS.jpg" /><figcaption>Source — <a href="https://pixabay.com/photos/grapes-fruit-cluster-grape-5889697/">Link</a></figcaption></figure><h3>Introduction</h3><p>In previous blogs (<a href="https://medium.com/codex/getting-familiar-to-the-world-of-machine-learning-ea31974ed0c4">Getting Familiar to the World of Machine Learning</a>), we learned about Unsupervised Machine Learning. Unlike Supervised Machine Learning in this, we identify the data points in relation to other data points because this type of Machine Learning Algorithm does not make use of Labelled Data as it does in Supervised Machine Learning. If you need more clarification on the topic, try reading the “Unsupervised Machine learning” section of (<a href="https://medium.com/codex/getting-familiar-to-the-world-of-machine-learning-ea31974ed0c4">Getting Familiar to the World of Machine Learning</a>).</p><h3>Unsupervised Machine Learning</h3><p>Unsupervised Machine Learning is used when we need to find out underlying hidden patterns in an “Unlabelled Dataset”, Unsupervised Machine Learning is further classified into two sections:</p><ol><li>Clustering — Grouping of similar data points to form different cultures.</li><li>Association — Finding important relations between data points.</li></ol><p>In this blog, we will be learning how clustering works and what methodologies can we use to perform clustering over Unlabelled Data.</p><h3>Clustering</h3><p>Suppose you are presented with a basket full of flowers, and the basket can contain any number of different categories of flowers. For example, the basket may contain 5 flowers of type-1, 3 flowers of type-2 etc. The catch here is that you have Blindfolds on, and you can not see and distinguish between categories of flowers. Now how would you differentiate one type of flower from others?</p><p>Since you can not take the blindfold off, one way to distinguish between different types of flowers is to pick one flower and place it out of the basket, pick another flower and try to feel if it is similar to the first one. If it is similar, keep them together. If it feels different keep, it separated, then pick the third one and try to feel it against other categories.</p><p>When you finish, you will end up with different cultures. This is what clustering is, you compare one data point with respect to other data points and form a cluster.</p><h3>Top clustering-based algorithms</h3><p>There are different methodologies to perform clustering over unlabelled data. The method you used to segregate different categories of flowers with the blindfold on is one of the methodologies. Similar to that, there can be many ways to form clusters. In machine learning, these methodologies are known as algorithms, and there are different algorithms for clustering like:</p><ol><li>K-Means Clustering</li><li>Mean Shift clustering</li><li>DBSCAN</li><li>EM using GMM</li><li>Agglomerative Hierarchical Clustering</li></ol><p>In this blog, we will be covering the K-Means Clustering algorithm.</p><h3>K-Means Clustering</h3><p>Suppose you have a dataset that contains features of different categories of flowers. Still, you do not know how many categories are there and which data point belongs to which category, so to find the categories, we perform K-Means clustering over it to learn more from the data.</p><p>Each data point represents the flower with given PetalLength details and the PetalWidth details of the flower, and each data point might belong to some category of flower that we do not know about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*xi2Q90WDNkgG7ZqJR9lkHA.png" /><figcaption>By Author</figcaption></figure><p>Look at the images below. This is the petalWidth VS petalLength plot of the dataset of flowers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*38CZ9CabggLVyU9X1-6BLw.png" /><figcaption>petalLength vs petalWidth By Author</figcaption></figure><p>In this, all the blue dots represent a flower based on two features that are petalWidth and petalLength. Now we do not know how many types of flowers there are as all the data points look the same with different combinations of petal length and petal width.</p><p>Try finding out which data point belongs to which category. How would you do that?</p><p>The first thing you would want to start with would be to answer how many categories this data contains because without knowing how many categories are there, how would you put the data in categories.</p><p>Now suppose i tell you that there are 2 categories this data represents, say A and B. Now i want you to find which data points can be clubbed together to fall under category A and which one would fall under category B, so to answer that, we will need to find out the clusters and the exact centre point of the cluster around which the data points would be identified, this centre of the cluster is called the centroid. (You will learn this better as you move further in this blog).</p><p>So, In K-Means clustering, we are focused on finding two main things that are-</p><ol><li><strong>How many clusters are there in the data</strong> — There are some methodologies for finding the correct number of clusters in data, like the Elbow and Silhouette methods. We will get to that part later in this blog.</li><li><strong>Where are the centroids of the clusters formed</strong>— Suppose we find out that there are x categories in our data. The next thing that we want to find is where do the centres of all those x clusters lie and what data points fall under which cluster.</li></ol><p>We will be explaining the second one first. We will learn about the centroid of the clusters, and then we will learn how to find the correct number of clusters.</p><h3>Learning to form clusters of our data</h3><p>By the image above, we may assume that there are two clusters. However, this might be wrong, and we can’t simply guess it with a fluke. We will learn later how to be mathematically sure.</p><p>For the time being, let’s assume that there are originally 2 clusters in our data which means that all our data points belong to one of these two clusters.</p><p><strong>Step 1</strong></p><p>We randomly pick two data points and assume them to be at the centre of the clusters we are looking for. It would look something like this-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*HtmppE7JKMwYiO3ccfeekw.png" /><figcaption>By Author</figcaption></figure><p>In this, we assume our centroids to be at [0.42372, 0.375] and [0.8305, 0.833] now. We need to find which of the data points belongs to which of the two clusters. Let&#39;s learn that in step 2.</p><p><strong>Step 2</strong></p><p>To find the belongingness of a data point, we find the distance between the data point and the two cluster centroids, the cluster centroid, which gives the minimum distance is the cluster to which our data point belongs. See the image and explanation below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*6gmLRxz4AHqUMvXCzHddMg.png" /><figcaption>By Author</figcaption></figure><p>Let us take the point marked yellow. We need to find which cluster does this point belongs to. To do that, we find the distance between the point and the cluster centre, and the one with the minimum distance is selected as the one our data point belongs to. After doing this, we will get which data point belongs to which cluster over all the data points. It will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*3bA7OFUq3x6WLJEAJyIX9g.png" /><figcaption>By Author</figcaption></figure><p>Now we have identified which data point belongs to which cluster. As we merely guessed the centroid of our two cultures, it may not be the case that we guessed it right. Let&#39;s learn how we find the correct location of the centroid of our clusters in step 3.</p><p><strong>Step 3</strong></p><p>Now, look at the image just above. Do you think that our red centroid is at the right place with respect to the other points?</p><p>Centroid should be at the centre of all the data points present in a cluster. If we find out the average of all the data points in a cluster, we will get a new location. That location is marked with a “X” in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*D6O9Q5Kpzvre5pumRjw7bQ.png" /><figcaption>By Author</figcaption></figure><p>You see, the average location of all the red points is marked with a green cross, and the average position of all the blue points is marked with a yellow cross. These are the points at the centre of our clustered data and a better location to place our centroid. If we shift our centroid, it will look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*QNbxJ9ibu6s4qGftgzlEuw.png" /><figcaption>By Author</figcaption></figure><p><strong>Step 4</strong></p><p>But as we shifted our centroid, it may not be the case that all the red points are still close to the red centroid. We will again need to find the belongingness of each data point with respect to the closure centroids. It will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*842MmyiG1udrUrOth8kAJA.png" /><figcaption>By Author</figcaption></figure><p>Now we again follow from the second step taking these new centroids, and we keep on doing this until our centroid stops changing position. Once this happens, we can confidently say that we have found the centroids, and the data points that belong to this will fall under that cluster. This whole process can be understood visually by following the images below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*pxrWisvmsG0Rna-8x_GcXg.png" /><figcaption>By Author</figcaption></figure><p>We will get the final result as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*Yd6AwFyRRDoeREYyNjZi0g.png" /><figcaption>By Author</figcaption></figure><p>We can see the new average is the same as the centroid and it won&#39;t change in more iteration, it gets fixed, this is the required centroid that we get and we can visually see that it successfully depicts what we assumed that is we have two clusters but the question that still remains is:-</p><p>Is it really two clusters in the image? This question is still unanswered, we will be moving to that in a while.</p><p>First, let&#39;s see the above process in form of a GIF:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*G30DZvFPGguu64zNFxvJ1w.gif" /><figcaption>By Author</figcaption></figure><p>We have two clusters now, and we know which data point belongs to which of the clusters. Now suppose we want to understand how our data is spread around our centroid. The best way to do this would be to sum the squared distance of all the data points to their cluster centroid, and this value for our data comes out to be 5.179687509974783.</p><p>This number is also termed “Inertia”, inertia is calculated on the best positioning of the cluster centroids. That means that we calculate this inertia on the centroid found after iterations and when we are sure about the centroids we got.</p><h3>Learning to find the “K” in the K-Means:</h3><p>While learning to find the cluster centroids for our data we assumed that there are 2 clusters in our data but this may be wrong as we do not have any mathematical backing to that guess, let&#39;s learn how to find the correct number of clusters.</p><p>We start guessing to find the number of clusters or the categories in our dataset. We make guesses on the number of clusters present in our data. Now suppose we guess that the clusters in our data are in between the range 1 to 15. Now how to pick the best guess?</p><p>We pick the best guess by finding the placements of centroid which gives minimum inertia for different values of K(Read ahead to get the hang of it).</p><p>Lets understand this visually:</p><p>Suppose we assume that we have only one category, thus we say that there must be one cluster only but as we know that clusters have a centroid point thus this cluster must also have a centroid point, now in order to validate if k=1 is an optimal choice we try finding the optimal centroid of the cluster. To find the optimal centroid of the cluster we use the strategy used above and reach to the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*V0St6JTK5rvZjeUtOYj_4Q.png" /><figcaption>By Author</figcaption></figure><p>The inertia is the sum of square distances of the data points in the cluster to the cluster&#39;s centroid. The inertia for k=1 comes out to be 28.391514358368717 and while learning about the centroid location we found out the inertia for k=2, which came out to be 5.179687509974783 for k=3 it comes out to be 1.7050986081225123. As we increase the number of k, our loss keeps on decreasing.</p><blockquote>It only seems logical that once our k becomes equal to the number of data points we have, it will get zero as there will be no error(Think about this point for a while, it can be a brain scratcher),</blockquote><p>So if we plot it on the graph of inertia VS K (no. of clusters), it will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*l42-S-HAJDNJiHKxW9dDjA.png" /><figcaption>By Author</figcaption></figure><p>It comes out as expected, notice how the graph shifts from exponential to linear, now the point where this shift happens is called as ELBOW point and this comes out to be the number of clusters present in our data, this means our assumption that the data contains 2 categories was wrong. The correct number of clusters is 3. Let&#39;s see where our cluster centroids lie, let&#39;s visualise it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*o78IwPphn2eyMJJxHe5Yxw.png" /><figcaption>By Author</figcaption></figure><h3>Conclusion</h3><p>In this blog, we saw how the K-Means clustering algorithm works on a dataset and what should be taken care of while choosing the right number of clusters using elbow plot and how does k_means algorithm finds the centroids of the clusters formed.</p><p>Unsupervised Machine Learning is used to find out how the unlabelled data points are related to other data points and how they are clustered formed using that information, The main things to find in a clustering algorithm are the cluster centroid and the number of clusters there actually are which we can find in different ways one of which is explained above that is the elbow plot.</p><p>There are numerous applications of Unsupervised Machine learning like fraud detection, customer segmentation, feature extraction etc.</p><p>In previous blogs, we have covered, Supervised Machine Learning, and this blog explains the Unsupervised Machine Learning algorithm, The next blog will introduce you to the important parameters we need to take care of while working on the Machine Learning model.</p><p>Previous Blog — <a href="https://medium.com/codex/your-guide-to-supervised-learning-classification-6f0eeb8b7049">Your Guide to Supervised Machine Learning-Classification</a></p><ul><li><a href="https://medium.com/@harshit_yadav">Harshit Yadav - Medium</a></li><li><a href="https://medium.com/@malikSarthak">Sarthak Malik - Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10ea9cd26412" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/your-guide-to-unsupervised-machine-learning-clustering-10ea9cd26412">Your Guide to Unsupervised Machine Learning — Clustering</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your guide to Supervised Machine Learning —  Regression]]></title>
            <link>https://medium.com/codex/your-guide-to-supervised-machine-learning-regression-d6b822563e44?source=rss-fe5a4924eff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6b822563e44</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Harshit Yadav]]></dc:creator>
            <pubDate>Fri, 21 Jan 2022 15:53:30 GMT</pubDate>
            <atom:updated>2022-02-06T16:04:09.549Z</atom:updated>
            <content:encoded><![CDATA[<h3>Your guide to Supervised Machine Learning — Regression</h3><p>Learning and developing an intuition for the working of Regression</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cgYrPpVng89gKWdu" /><figcaption>Photo by <a href="https://unsplash.com/@liamcharmer?utm_source=medium&amp;utm_medium=referral">Liam Charmer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>Note</strong>: <a href="https://medium.com/codex/foundation-of-machine-learning-2-linear-algebra-and-calculus-9783d4592b98">Four pillars of Machine Learning #2 — Linear algebra and calculus</a> is the previous blog in the “Complete Machine Learning and Deep Learning for Beginners” series. It is recommended to have the prior knowledge discussed in the last of blogs.</blockquote><p>The little Code and data used in this Blog can be found ‘<a href="https://github.com/harshit-wq/blog">here</a>’, Do not worry if you do not know how to code or do not understand the code in this blog. This blog is not a coding tutorial. This blog’s purpose is to explain the concepts, you can ignore the code as this tutorial is not coding dependent, but if someone wants to dig deep, they can go through it.</p><p>For those unfamiliar with code or Libraries used, a blog will be released as a part of this series which will introduce you to coding and libraries used.</p><h3>Blog’s Outline:</h3><ol><li><strong>Introduction</strong></li><li><strong>Supervised Machine Learning</strong></li></ol><ul><li><strong>2.1 Introduction to Regression</strong></li><li><strong>2.2 Introduction to Classification</strong></li><li><strong>2.3 Continuous and Discrete Data</strong></li></ul><p>3.<strong> Regression</strong></p><ul><li><strong>3.1 Dependent and Independent Variables</strong></li><li><strong>3.2 Types of Regressions</strong></li><li><strong>3.3 Simple Linear Regression</strong></li><li><strong>3.4 Multiple Linear Regression</strong></li></ul><h3>1. Introduction</h3><p>We have already discussed supervised and unsupervised machine learning earlier in this series. In this blog, we will learn more about Regression in Supervised Machine Learning and how it works. You will need a bit of Mathematics, nothing too high; just a basic knowledge of Linear Algebra will be helpful.</p><h3>2. Supervised Machine Learning</h3><p>As discussed earlier in one of our previous blogs (<a href="https://medium.com/@harshit_yadav/getting-familiar-to-the-world-of-machine-learning-ea31974ed0c4">Getting Familiar to The World of Machine Learning</a>), when we train our model based on some labelled dataset, it falls under Supervised Machine Learning. Now, this type of Machine Learning is further divided into two parts :</p><p><strong><em>2.1 Regression</em></strong>: In Regression, we are trying to predict “Continuous Variables” (discussed ahead) like Price of a house, Number of covid cases, Price of a stock, Temperature on a particular day etc.</p><ul><li>Example: Suppose you were given data about how many hours a student studies, and you have to predict students marks.</li></ul><p><strong><em>2.2 Classification</em></strong>: In classification, we are trying to predict something called “Discrete Variable”(discussed ahead) like the category of a Flower, Human Gender, Is an email Spam or not etc., where we are sure that the output is going to be from a particular list of categories.</p><ul><li>Example: Suppose your friend owns a pet, and she tells you its characteristics and that it is one among [Rabbit, Dog, Cat, Cow]. Now you guess if it is like a Dog or a Cat etc.</li></ul><h4>2.3 Continuous and Discrete Data</h4><p>We need you to do two things for us:</p><ol><li>Guess a number.</li><li>Pick an animal from [Dog, Cat, Cow, Rabbit]</li></ol><p>Now what you did here is just learnt what discrete and continuous variables are. In the first one, we guessed some form of a number which may be anything; we are not bounded, this is continuous data it could be 10, 100, 10.10, 57.80, etc. whereas, in the second one, we have picked some value from a well-defined pool of values which are discrete.</p><h3>3 Regression</h3><p>Regression is the study and use of data to predict a continuous variable based on the findings from the dataset. To do this, we need to know about Dependent Variable and Independent Variable.</p><h4><strong>3.1 Dependent and Independent Variables:</strong></h4><p>“Dependent Variable is a variable that is dependent upon different factors that serve as independent variables.”</p><p>Got confused? don&#39;t worry read ahead</p><p>Suppose you have data which is as follows :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*vQl-95P6W4Xkm2dGa-2nvA.png" /><figcaption>Hours VS Marks. By Author</figcaption></figure><p>This data is about how many hours a student studies versus how many marks scored in the exam. In this case scenario, your dependent variable is the Marks Scored in the exam by a student, which is affected by the number of hours the student studied, which is an independent variable in this data.</p><p>So, Hours = Independent Variable, Marks = Dependent Variable and as we already know, the Marks will depend upon the number of hours studied.</p><p>Now try to reread the First statement; it would not be as confusing as before.</p><h4><strong>3.2 Type of Regressions:</strong></h4><p>Now Regression can be done in many ways. Some Regression methodologies are:</p><ol><li>Simple Linear Regression</li><li>Multiple Linear Regression</li><li>Logistic Regression</li><li>Ridge Regression</li><li>Lasso Regression</li><li>Polynomial Regression</li><li>Support Vector Regression</li><li>Decision Tree Regression</li><li>Random Forrest Regression</li></ol><p>We will cover the First 2 in this blog, and the rest will be covered later in the series as they are a bit advanced.</p><h4><strong>3.3 Simple Linear Regression:</strong></h4><p>Have you ever heard of slope in a graph? or just the equation y=mx+c? If you have, then you already know what Simple Linear Regression is. If you haven&#39;t, then we are here for you. Read ahead.</p><p>Suppose you buy two chocolates for 10$, can you guess the Price of 4 chocolates, it will be 20$ well you can come to this result in two ways :</p><p><strong><em>First</em>:</strong></p><p>Figure out the price of 1 chocolate, then calculate the price of 4 chocolates. Like if 2 chocolates are for 10$, then 1 chocolate is for 5$ that means four chocolates are for 20$</p><p><strong><em>Second</em>:</strong></p><p>Make a graph for it (a bit tedious but does the work) so suppose you ask the shopkeeper the price of 2 chocolates he tells you 10$, 20$ for 4, 30$ for 6 and so on…, so what you can do with this is sketch a graph which will look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*S2Eih_HRryfu-rOKJbkC7w.png" /><figcaption>Price of Chocolates VS Number of Chocolates. By Author</figcaption></figure><p>Now if someone asks you the price of 50 chocolates, looking at the graph, you can say that it is 250$.</p><p>Now what you did here in the second method was to create a Simple Linear Regressor. Actually, in this example, it does not make sense to use linear Regression because this is not something you would need Linear regression for. This is not an estimation but a sure thing. This was to show you how we can use graphs to relate two variables. Now we will see how we can use Linear regression for real-world data.</p><p>Let us learn how to apply Simple Linear Regression to real-world data:</p><p>Suppose you want to predict how many marks will be scored by a student if he studies for a certain number of hours, you can have a look at the data below, and you can find the whole data <a href="https://github.com/harshit-wq/The-Sparks-Foundation/blob/main/Task1.txt">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*GMw_2afUJdPyIDGjY1AE3Q.png" /><figcaption>Hours Studies VS Marks Scored. By Author</figcaption></figure><p>Now we want to predict the marks scored on the number of hours spent studying. Now to do this, we will create a Simple Linear Regression model. First, let us plot a 2-D graph of the students&#39; marks VS Hours Studied. It will look something like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cbe87599c306856e1c321456d7fe920/href">https://medium.com/media/4cbe87599c306856e1c321456d7fe920/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*6QUdsSg6XmJDN6FmckSQ2w.png" /><figcaption>By Author (Coded)</figcaption></figure><p>Now we will try to create a Linear Regression line to predict the scores. Now how to draw the line? for this, we will have to come up with a line that closely fits the data to predict the marks more accurately. Look at these graphs carefully:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*junFaQG4KAVjLmhZv39Vzg.png" /><figcaption>By Author</figcaption></figure><p>Those blue dots represent the data points, and the red line represents our predictions. In which graph do you think we are close to the accurate answer? The correct answer will be the top-right graph because our prediction line fits the data well, and our prediction will be very close to the actual answer.</p><p>But why did our intuition suggest that it should be a top-right graph? The top-right chart minimises something called Mean-Squared-Error or (MSE); the smaller it is, the better our prediction line works. Let us understand what MSE is. Look at the graphs below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af64c26ff8c4af9d9294ad4af176f9b6/href">https://medium.com/media/af64c26ff8c4af9d9294ad4af176f9b6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*d4eyRwvXPkN0H-npETiH1g.png" /><figcaption>By Author (Coded)</figcaption></figure><p>These vertical lines represent how much error was there in our prediction. In actual data, if we take an average of the square of this error, we will have something called the Mean Squared Error. Whenever we try to predict something, we look to minimize the error between the actual answer and our prediction. This error can be called “cost”; thus, we are trying to minimise this cost, and this cost or error is calculated using something called “Cost Function” in this case, the Cost Function is Mean Squared error. The less the Cost Function, or we can say Mean Squared error, the better the Model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*ebU-fUZYeOVTV8uSjKo9SQ.png" /><figcaption>Mean Squared Error. By Author</figcaption></figure><p>So, now you know which line is best for our model out of the above 4, but the question is how we got there? How do we get to those 4 lines? Let us learn that below:</p><p>So every line on a graph can be represented in an equation that is y=mx + c. Now we can manipulate the line by changing the “m” that is called slope and “c”, which is called Intercept now. Changing these two properties can change the line. Have a look below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*fTTXV9e0w5xTO3o8OTssKA.png" /><figcaption>By Author</figcaption></figure><p>Now, we can guess the combination of “m” that is the slope, and “c” that is Intercept enough number times. This is what our computer does, it checks over different combinations of “m” and “c”, and then after enough guesses, we will pick the combination that has the lowest “cost function” value, i.e. the combination of “m” and “c” that has minimum Mean Squared Error that we discussed earlier.</p><h4><strong>3.4 Multiple Linear Regression :</strong></h4><p>In simple linear Regression, we saw how we could relate one dependent variable and one independent variable together to create a Linear Regression model, but what if we have one dependent variable and two independent variables?</p><p>Suppose you want to predict the price of a house, so it will depend upon house area, water availability, electricity availability, etc. For now, let us consider that the price of the house is only dependent upon two features: electricity water availability. Now how would we predict the cost of a home using these two?</p><p>Suppose we have a dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*o6k1CcYg3mcpoma7h1UF-Q.png" /><figcaption>By Author</figcaption></figure><p>We have discussed in Simple Linear Regression about how we can approach creating a Linear Regression. If we just had two variables that can be Price VS Water OR Price VS Electricity, the graph would be plotted as :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24ed16089c2f27baa6694ba91779f2bb/href">https://medium.com/media/24ed16089c2f27baa6694ba91779f2bb/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*pyEXsj2U_tbH5ruL08FcJQ.png" /><figcaption>By Author (Coded)</figcaption></figure><p>If we apply Linear Regression over the data, we will get:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ee13db850db46d4017bf5259a6b4529/href">https://medium.com/media/0ee13db850db46d4017bf5259a6b4529/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*N3AS7mP1bzYz9XqTYfoAjg.png" /><figcaption>By Author (Coded)</figcaption></figure><p>So now we have two independent variables: electricity availability and water availability. We want to use them to predict the dependent variable house price, so we have three variables to draw it into a 3d-graph with one z-axis as the price of a house and x-axis as water availability and y-axis as electricity availability.</p><p>If we plot the data on a 3-D graph:</p><p>Notice the Positive Quadrant, i.e. (+x,+y,+z), keep the reference of +x, +y, +z axes to notice the placements of points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*BhmB7PO-Ncos--JG7_XhKw.png" /><figcaption>By Author (Site used to create the graph: <a href="https://c3d.libretexts.org/CalcPlot3D/index.html">Link</a>)</figcaption></figure><p>Now how would we fit a Linear Regression Model over this? If you notice in our Simple Linear Regression as it was 2-Dimensional, we got Regression Linear Regression Model, now as we have moved to 3-D in this case, we will get a plane? But to define a Plane in a 3-D space, we need an equation, and you can specify any plane in a 3-D space using the equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*orKi0rl6EbCR8CQA7YoIyA.png" /><figcaption>By Author</figcaption></figure><p>We saw that in the case of Simple Linear Regression, we needed an equation like y=mx + c, but the trick was finding “m” the slope and “c”, the intercept. we tried different values, which gave us different lines, and the Line that gave us the minimised Cost Function(MSE, “Mean Squared Error” in this case) gave us the required line. (Read that again if you got lost, you would get it, we have covered this in Simple Linear Regression).</p><p>We are going to follow the same procedure here. We will try different values of a, b, d and the plane that gives us the minimum MSE(Mean Squared Error) will provide us with the required plane, which will be our Regression Model. (To guess a,b,d fast, we use an Optimisation Technique called “Gradient Descent”, which will be explained in another blog).</p><p>After different tries over a,b,d, our computer came up with the values which will give us minimised MSE, and those values for this model were</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*l-5-HY1jYynjXWYR9yAYdQ.png" /></figure><p>So this is the equation of Plane that will give us Minimized MSE. If we plot this plane on our 3-D space, we will get something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*w-erIAqCHLV8NmVlRdeTLQ.png" /><figcaption>By Author (Site used to create the graph: <a href="https://c3d.libretexts.org/CalcPlot3D/index.html">Link</a>)</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a404b142d392206315a31eac111bbab6/href">https://medium.com/media/a404b142d392206315a31eac111bbab6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*ysxZlJUnX5X-5fo06JB7_A.png" /><figcaption>By Author (Coded)</figcaption></figure><p>So this will be our Linear Regression plane, which tells us the price of a house based on the feature inputs, But the question that arises here is that</p><p><strong>What if there are more than two features?</strong></p><p>Suppose you have a dataset where your dependent variable is the Price of a house. Independent variables are (House Area, No. of Rooms, No. of Floors, Water, Electricity, Locality), all these can not be represented in a 3-D graph, if we try to plot this data then we will need to have a 6-D graph, but that is not possible to visualise, we can not move ahead of 3-D space, so we will need a hyperplane, but instead of trying to understand it using hyperplane concept we will appreciate it this way:</p><p>In the 3-D space example, we saw that the Linear Regression equation was like <strong>Z = 0.19264305*X + 0.22561308*Y + 0.6171662125340589, </strong>which resembles the equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*orKi0rl6EbCR8CQA7YoIyA.png" /><figcaption>By Author</figcaption></figure><p>So in this equation, <strong>Z</strong> is the price of House, ‘<strong>x’</strong> is the feature variable (Water Availability in this case), ‘<strong>y’</strong> is the feature variable (Electricity Availability in this case) And the <strong>a,b</strong> are the weights of the feature which gives us the required line so in the example we solved earlier the weight of the feature x was <strong>0.19264305, </strong>weight of the feature<strong> y </strong>was<strong> 0.22561308 </strong>and<strong> d </strong>was the intercept which was<strong> 0.6171662125340589. </strong>So if we want to deal with<strong> </strong>a dataset where your dependent variable is the Price of a house and Independent variables are (House Area, No. of Rooms, No. of Floors, Water, Electricity, Locality) instead of going into the hyperplane theory, for now, we can follow the pattern of the above equation which will result into:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*jQI8M-8mpAJgjoi-I8AtkA.png" /><figcaption>By Author</figcaption></figure><p>Where <strong>Y</strong> is the price of a house, <strong>X1</strong> is the House Area feature, and <strong>b1</strong> is the weight of this feature, <strong>X2</strong> is the No. of Rooms feature, and <strong>b2</strong> is the weight of this feature, and so on till the Locality feature that is <strong>X5</strong> and its weight is <strong>b5</strong>, the last we are left with is <strong>e</strong> that is the Intercept.</p><p>This way, we can create a linear regression for a dataset with more features.</p><h4>Conclusion</h4><p>Linear Regression is widely used in the world of Machine Learning. It is one of the powerful yet easy algorithms to predict continuous data. There are different modifications of Linear Regressions like Ridge, Lasso which will be covered later in this series after you are made familiar with Gradient Descent, Overfitting and Underfitting etc.</p><p>It would have been a lot to digest if you were an absolute beginner to Regression. Take your time and go through Regression once more if you are not clear in the first attempt, it will get clearer.</p><p>If you found this blog helpful, kindly consider following us to receive new informative blogs from the series.</p><p>Previous Blog — <a href="https://medium.com/codex/foundation-of-machine-learning-2-linear-algebra-and-calculus-9783d4592b98">Four pillars of Machine Learning #2 — Linear algebra and calculus</a></p><p>Next blog — <a href="https://medium.com/codex/your-guide-to-supervised-learning-classification-6f0eeb8b7049">Your guide to Supervised Learning — Classification</a></p><ul><li><a href="https://medium.com/@harshit_yadav">Harshit Yadav - Medium</a></li><li><a href="https://medium.com/@malikSarthak">Sarthak Malik - Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6b822563e44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/your-guide-to-supervised-machine-learning-regression-d6b822563e44">Your guide to Supervised Machine Learning —  Regression</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Familiar to The World of Machine Learning]]></title>
            <link>https://medium.com/codex/getting-familiar-to-the-world-of-machine-learning-ea31974ed0c4?source=rss-fe5a4924eff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea31974ed0c4</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[analtyics]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Harshit Yadav]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 16:18:43 GMT</pubDate>
            <atom:updated>2022-01-21T16:58:48.792Z</atom:updated>
            <content:encoded><![CDATA[<h4>Bird&#39;s eye view of Machine Learning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iVVVKG2PUORj5YhV" /><figcaption>Photo by <a href="https://unsplash.com/@element5digital?utm_source=medium&amp;utm_medium=referral">Element5 Digital</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>Note : This is the first blog in the “Complete Machine Learning and Deep Learning for Beginners” series, the main audience for this series is anyone who wants to learn more about Machine Learning and Deep Learning or refine their ML/DL skills.</strong></blockquote><h4>This Blog’s outline</h4><ol><li>Introduction</li></ol><ul><li>Short History of Machine Learning</li><li>Future of AI</li></ul><p>2. Types of Machine Learning</p><ul><li>Supervised</li><li>Unsupervised</li><li>Reinforcement</li></ul><p>3. Importance of Relevance of Data</p><p>4. Steps every Machine Learning model goes through</p><ul><li>Data preprocessing</li><li>Exploratory Data Analysis</li><li>Model Training</li><li>Model Evaluation</li><li>Model Deployment</li></ul><p>5. Conclusion</p><p>This is just an introductory blog. If you face difficulty understanding this initially, stay with us, it will become clearer as we move forward in this series.</p><h3>Introduction</h3><p>Regression, Data preprocessing, RandomForest, Naive Bayes Classifiers all these terms are a bit intimidating to all when we first hear about them and leave some people wondering if they would be able to grasp these at first but as you move further with this series of topics it will start becoming clearer and easier, this series is to help you get rid of all the intimidation and move ahead on your Machine Learning journey with us.</p><h4>Short History of Machine Learning</h4><p>It really surprised me when I learned that the term “Machine Learning” was first coined in the year 1959!!! The work in the field of Machine Learning has been rising since then. There have been continuous developments in algorithms for both Machine Learning and Deep Learning. However, it was impossible to make computers work on them due to the lack of Computational Power. However, since the last decade, as computers advanced, they opened up many doors to test and evaluate and discover new findings in this exciting field.</p><h4>Future of AI</h4><p>Apart from a debatable topic of how AI will turn the machines against humans in the future, there are a lot more exciting things we will see in the future which will be empowered by AI, Self Driving cars that are almost here among us, Amazing robots which make complex industrial tasks really easy, restoring old photographs to new, using AI to create amazing art, automated healthcare, empowering the people who have difficulty in speaking, etc. and thus it also opens up great career opportunities for practitioners.</p><h3>Types of Machine Learning</h3><p>The best way to cover up a big topic is to dissect the topics into smaller pieces and then learn each one of them in the world of Machine Learning; the dissected pieces will be :</p><ol><li>Supervised Machine Learning</li><li>Unsupervised Machine Learning</li><li>Reinforcement Learning</li></ol><p>Let&#39;s dive into a brief introduction and example of these</p><h4>1. Supervised Machine Learning</h4><p>A bookish definition — “Supervised Machine Learning is a type of Machine Learning where we train machines using a well “Labelled” Dataset”.</p><p>Ummmm…… Okay…….., Let us try to understand this with an example.</p><p>Suppose in a pet shop you have many cats, dogs and rabbits. You have the dataset of the shop now in each data point or data instance; you will have some features of the data like the height, colour, type of tail etc., as a column of the dataset. There will be a specific column of interest that we want to train our machine on. This column’s values serve as a label for our data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*lt-j_KNEXvTcTWlNBctUpQ.png" /></figure><p>Check out the above table, now; in this table, we have 3 data points and four informative columns now based on what we are trying to do with the dataset, we will select our label column, suppose we want to predict which category does the data point belong to then “Category” will become our labelled column and the other columns will work as features and help us in predicting the Category.</p><p>Similarly, if you want to predict the tail type of the data point, based on this use case, the column named “Tail type” will serve as the labelled data column, which we will try to predict, taking other columns as features.</p><p>So when we train a machine to predict something in this way, it falls under the category of Supervised Machine Learning There are different ways to train a model but training a model will be discussed later in this series.</p><h4>2. Unsupervised Machine Learning</h4><p>According to books — “A type of Machine Learning in which we use unlabelled dataset for training purpose and machine is allowed to act on the data without any supervision.”</p><p>Okay….. So What??, Let&#39;s learn this our way again.</p><p>Suppose you want to train the machine over a dataset with no column of interest; we do not want to predict anything. It is just data, and we want to learn how the data is behaving in itself what we can learn from data. In unsupervised, machine learning is much similar to machine learning using the given dataset as humans do fascinating.</p><p>Suppose we have a dataset that looks something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*wm84VFishbktvh4OLU_blQ.png" /></figure><p>This is the data of categories of flowers, and each data point corresponds to one of these flower categories. These columns specify the value like sepal width of flower, petal length of flower etc. However, we do not know which data point belongs to which category; how would we do that?</p><p>One of the best things to consider will be how the data point relates to what data instances are forming a cluster, so while performing the unsupervised learning on this dataset, we train our machine to learn from this data; here is the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*e1pGeDmDQ9PA3lJJ-MM0Bw.png" /></figure><p>So, when we performed clustering over this data, we can see that 3 cluster centres correspond to each of the flower categories, and we can say that yes, there are three categories of flowers covered in this dataset; now, suppose we get a new data instance, and we want to know which flower category it closely resembles. So, it will search which culture the data most closely relates to, and that cluster will be the category that the data point belongs to.</p><h4>3. Reinforcement Learning</h4><p>Suppose you meet a monkey, you decide to give him a banana every time he makes a flip guess what he will do the next time he sees you. Yup, you guessed it right, he will jump and expect to get that banana. Now think of a cat drinking milk, and you keep the glass in front of it now if the cat pushes glass, then you snatch away the milk, and you do this for a few times guess what the cat will do if a glass is kept in front of her yup the cat will not push the glass because that will result in snatching milk away from her.</p><p>The above two examples tell about the reward or the punishment one gets if certain actions are performed in a certain environment. For the cat, the environment was the presence of milk and glass. For the monkey, the environment was you and the banana. Reward and punishment train the animal to do a certain action or avoid certain activities in a specific environment. This is known as reinforcement learning, and similar things can be performed with the machine.</p><p>Look at this famous Pacman example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*WCWpVRjfTvRr0Kfi31V8GQ.png" /><figcaption>source -&gt; <a href="https://towardsdatascience.com/deep-q-network-combining-deep-reinforcement-learning-a5616bcfc207">https://towardsdatascience.com/deep-q-network-combining-deep-reinforcement-learning-a5616bcfc207</a></figcaption></figure><h4>The importance of relevance of Data</h4><p>In the world of Machine Learning, everything depends on the data. Your data is the one thing that will influence the robustness and validity of your trained machine learning model like no other thing. If you go wrong in picking, selecting or collecting data, you can be sure that the final result of whatever you do will not be up to the mark, So the suitability of the data is the primary most important thing you need to take care of. There is nothing as absolutely right data; it is just the relevancy of the data to your case that matters.</p><p>Suppose you want to predict the price of a house using some datasets so if you have a dataset which has feature columns as (house area, no of. rooms, locality, surrounding, electricity) and the other dataset with feature columns as (house area, no. of rooms, locality, surrounding, electricity, availability of water) so all these things contribute to the price of a house but the second dataset is better than the first one. Hence, it is safer to say that dataset 2 is better to move forward with our use case.</p><h4>Steps every Machine Learning model takes :</h4><ol><li>Data Preprocessing</li><li>Exploratory Data Analysis</li><li>Model training</li><li>Model evaluation</li><li>Model Deployment</li></ol><p>These are just brief introductions to the topics. They all will be covered in upcoming blogs.</p><ol><li><strong>Data Preprocessing</strong></li></ol><p>Once you have the right data, you can proceed with Data Preprocessing. Data Preprocessing deals with making the data more suitable for further processes so that the machine can learn with more refined data. Like taking care of the data points where the column values are missing, or the data point is not complete.</p><p>2.<strong> Exploratory Data Analysis</strong></p><p>We try to understand the data visually and see the patterns and how the different columns are related to each other visually. Based on that, we prioritize different columns as per understanding.</p><p>3. <strong>Model Training</strong></p><p>In this step, we try and test different methodologies of training our machine on our data and select a model that gives us the best performance, among others.</p><p>4. <strong>Model Evaluation</strong></p><p>To evaluate which model is the best for our use case, we test the model on different parameters and the model which has the best result is selected for final use.</p><p>5. <strong>Model Deployment</strong></p><p>Now we have trained our Machine on our data, now to make it useable, we need to deploy it, that means to keep it somewhere (generally cloud) so that it can be used effectively and easily by the user.</p><p><strong>Note:</strong> It is not necessary to perform all these 5 steps sequentially every time, we can switch between them back and forth depending on the use case and situation and our place in the project lifecycle.</p><h4>Conclusion</h4><p>This blog introduced you to the world of Machine Learning, how Machine Learning is further divided into different subcategories, why the relevance of data is so important, and what steps need to be taken to build a good Machine Learning model. This is just an introductory blog which is the first of its series. In the upcoming blogs, we will further dive into each of these topics in deep, and you will learn the building Machine Learning model and further improve on them.</p><p>In the next blog, we will be learning about the prerequisite maths required for Machine Learning.</p><p><strong>Next Blog in the Series</strong> : <a href="https://medium.com/@malikSarthak/foundation-of-machine-learning-1-b21f7b3e5850">Foundation of Machine learning — 1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea31974ed0c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/getting-familiar-to-the-world-of-machine-learning-ea31974ed0c4">Getting Familiar to The World of Machine Learning</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>