<?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 Sai Kumar Gandhi on Medium]]></title>
        <description><![CDATA[Stories by Sai Kumar Gandhi on Medium]]></description>
        <link>https://medium.com/@saikumargandhi?source=rss-2cf973c1e3fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HdDqjJaHMhOdxkG-q_GzGw.jpeg</url>
            <title>Stories by Sai Kumar Gandhi on Medium</title>
            <link>https://medium.com/@saikumargandhi?source=rss-2cf973c1e3fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 07:44:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saikumargandhi/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[FastAPI introduction, step-by-step installation process, accessing automatic API documentation]]></title>
            <link>https://saikumargandhi.medium.com/fastapi-introduction-installation-step-by-step-access-api-documentation-d5efc9ef97a2?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5efc9ef97a2</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[documentation]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Fri, 29 Mar 2024 06:15:48 GMT</pubDate>
            <atom:updated>2024-05-03T08:57:31.350Z</atom:updated>
            <content:encoded><![CDATA[<p>FastAPI is a tool to help you create web applications quickly and easily. Imagine you want to open a lemonade stand, but instead of a stand, it’s a website where people can order lemonade from you. FastAPI helps you set up this “lemonade stand” so you can start serving customers ASAP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5aTGX9HwQgXXPLsF.png" /></figure><h3>Understanding FastAPI in Simple Terms:</h3><ul><li>What is FastAPI? Think of FastAPI as a set of instructions and tools that helps you build your website or app where people can come and interact, like ordering food or posting on social media.</li><li>Why use FastAPI? It’s like having a high-speed blender at your lemonade stand. It helps you serve your customers faster and more efficiently, with less waiting time and more happy faces.</li></ul><h3>Installing FastAPI Step by Step:</h3><p>Before we start, you need to have Python installed on your computer. Python is like the basic ingredient needed for your recipes at the lemonade stand. If you’re not sure if you have Python, you can check by opening your command line (Terminal on Mac/Linux, Command Prompt on Windows) and typing:</p><pre>python --version</pre><p>If you see a version number, you’re good to go. If not, you’ll need to install Python from the <a href="https://www.python.org/">official Python website</a>.</p><h4>Step 1: Set Up a Virtual Environment</h4><p>A virtual environment in Python is like having a special fridge for your lemonade stand where you keep all your ingredients separate from your family’s groceries. This way, your ingredients don’t get mixed up with anything else.</p><ul><li>Open your command line tool.</li><li>Navigate to the folder (I have created a FastAPI folder) where you want your project to live.</li><li>Create a virtual environment by typing:</li></ul><pre>python -m venv venv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*hbZiLEn3YCckjQBgFzTGqA.png" /></figure><p>Activate it with:</p><ul><li>On Windows:</li></ul><pre>.\venv\Scripts\activate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*gOjN54UHAp06MpoEfB1eXQ.png" /></figure><ul><li>On Mac/Linux:</li></ul><pre>source venv/bin/activate</pre><h4>Step 2: Install FastAPI</h4><p>Now, let’s get the main ingredient for our project, FastAPI. Installing FastAPI is like ordering the perfect set of tools and decorations for your lemonade stand.</p><ul><li>With your virtual environment activated, type:</li></ul><pre>pip install fastapi[all]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hEhNJzY5oNUt05dJLqCcQ.png" /></figure><p>This command tells the Python package manager (pip) to bring FastAPI and all its friends (dependencies) to your project (virtual environment).</p><h3>Congratulations! 🎉</h3><p>You’ve just set up FastAPI on your computer. It’s like you’ve laid down the foundation of your lemonade stand, and you’re ready to start building it up and serving customers.</p><h3>What’s Next?</h3><p>Great! You’ve got your FastAPI “lemonade stand” set up, and now you’ve got your first “menu item” ready. This piece of code you’ve written is like telling your stand, “Whenever someone comes up and asks for the main menu, just say ‘Hello, World’.” Let’s go through how to make this work so that when people visit your stand (in this case, your web application), they get greeted properly.</p><h3>Step 1: Save Your Code</h3><p>First, you need to save your code in a file so your computer knows what to do when people visit your lemonade stand. Let’s call this file main.py. The .py part tells your computer, &quot;Hey, this is a Python file!&quot;</p><ul><li>Open a text editor (like Notepad, TextEdit, or something more fancy like VSCode).</li></ul><pre>from fastapi import FastAPI<br><br>app = FastAPI()<br><br>@app.get(&quot;/&quot;)<br>def read_root():<br>    return {&quot;Hello&quot;: &quot;World&quot;}</pre><ul><li>Paste your code into the editor.</li><li>Save the file as main.py in the same folder where you set up FastAPI and your virtual environment.</li></ul><h3>Step 2: Run Your FastAPI App</h3><p>Now, you’re going to tell your computer to start running your lemonade stand so it can start serving your visitors. To do this, you’ll use a command in the terminal that says, “Hey, use Uvicorn (a lightning-fast server) to run my FastAPI app.”</p><p>Here’s the magic spell to do that:</p><pre>uvicorn main:app --reload</pre><pre>fastapi dev main.py</pre><ul><li>Open your command line tool.</li><li>Make sure you’re in the same directory as your main.py file.</li><li>Make sure your virtual environment is activated. If not, activate it like we did before.</li><li>Type in any one of the command above and press Enter. Both commands work same, fastapi dev is released recently to get uvicorn executed internally. Use <strong>fastapi dev</strong> for development and <strong>fastapi run</strong> for production purpose.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*LxxBjJZw9TexrCCqHblLHA.png" /></figure><p>Let’s break down what this command means:</p><ul><li>uvicorn is the program you&#39;re telling your computer to use. It&#39;s a super-fast server that works well with FastAPI.</li><li>main:app tells Uvicorn, &quot;Look in the main.py file for my application named app.&quot;</li><li>--reload is like telling it, &quot;Please automatically restart if I make any changes to the menu or anything else. I want to see changes in real-time.&quot;</li></ul><h3>Step 3: Visit Your Lemonade Stand</h3><p>Once Uvicorn is running, it’ll tell you something like “Uvicorn running on http://127.0.0.1:8000&quot; (this may vary slightly). This address is like the location of your lemonade stand on the internet.</p><ul><li>Open your web browser.</li><li>Type in http://127.0.0.1:8000 or http://localhost:8000 in the address bar.</li><li>Press Enter.</li></ul><p>You should see a page that says {&quot;Hello&quot;: &quot;World&quot;}. Congratulations, you&#39;ve just served your first customer at your digital lemonade stand!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*sIfm3QkDXzjJM2L1KGgGSg.png" /></figure><h3>What’s Next?</h3><p>Now that you’ve got the basics down, you can start expanding your menu. In FastAPI terms, this means adding more routes (URL paths) and functions to handle different requests.</p><p>FastAPI automatically generates this documentation for you. It’s like having a magic book that writes itself every time you create a new lemonade flavor or change the recipe. You don’t have to spend hours writing and updating your menu and instruction manual; FastAPI does it for you.</p><h3>Seeing Your Documentation</h3><p>When you run your FastAPI app, not only is your web application up and running, but FastAPI also creates a web page that displays your API documentation. This is done using two major tools:</p><ul><li>Swagger UI: This is like an interactive menu. You can see all the available “flavors” (API routes), and it lets you try them out right there. You can find this by visiting http://127.0.0.1:8000/docs your web browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kT_eKihLUsm4ngF6EawQcg.png" /></figure><ul><li>ReDoc: This provides a more traditional, read-only view of your menu. It’s great for printing out or for when you just want to browse the options without interacting with them. This can be accessed at <a href="http://127.0.0.1:8000/redoc.">http://127.0.0.1:8000/redoc</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQQmyP1GOTpHu-z5xOplow.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5efc9ef97a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Offline PWA: A Step-by-Step Guide with Sample Code]]></title>
            <link>https://saikumargandhi.medium.com/building-an-offline-pwa-a-step-by-step-guide-with-sample-code-feefda85db33?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/feefda85db33</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[pwa]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Sat, 29 Apr 2023 18:17:17 GMT</pubDate>
            <atom:updated>2023-04-29T18:17:17.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uvcPRiXw6Pw_DrGiFSGXg.jpeg" /><figcaption>Building offline PWA (Source: freepik.com)</figcaption></figure><p>In today’s world, users expect applications to work even when they don’t have an internet connection. Building an offline Progressive Web App (PWA) can provide a seamless experience for users, allowing them to continue using your app even when they are offline. In this article, we’ll walk through the steps of building an offline PWA using service workers and caching.</p><p><strong>Getting Started:</strong> To get started, let’s set up a basic PWA with a manifest and service worker. The manifest provides metadata about the app and allows it to be installed on the user’s device. The service worker is the backbone of the PWA and enables offline functionality.</p><p>First, create a file called manifest.json and add the following content:</p><pre>{<br>  &quot;name&quot;: &quot;My PWA&quot;,<br>  &quot;short_name&quot;: &quot;PWA&quot;,<br>  &quot;theme_color&quot;: &quot;#ffffff&quot;,<br>  &quot;background_color&quot;: &quot;#ffffff&quot;,<br>  &quot;icons&quot;: [<br>    {<br>      &quot;src&quot;: &quot;/images/icon.png&quot;,<br>      &quot;sizes&quot;: &quot;192x192&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;<br>    }<br>  ],<br>  &quot;start_url&quot;: &quot;/&quot;<br>}</pre><p>This manifest includes the name and short name of the app, as well as an icon and start URL.</p><p>Next, create a file called service-worker.js and add the following content:</p><pre>self.addEventListener(&#39;install&#39;, event =&gt; {<br>  event.waitUntil(<br>    caches.open(&#39;my-cache&#39;).then(cache =&gt; {<br>      return cache.addAll([<br>        &#39;/&#39;,<br>        &#39;/index.html&#39;,<br>        &#39;/styles.css&#39;,<br>        &#39;/script.js&#39;,<br>        &#39;/images/logo.png&#39;<br>      ]);<br>    })<br>  );<br>});<br><br>self.addEventListener(&#39;fetch&#39;, event =&gt; {<br>  event.respondWith(<br>    caches.match(event.request).then(response =&gt; {<br>      return response || fetch(event.request);<br>    })<br>  );<br>});</pre><p>This service worker caches the app shell (HTML, CSS, JS, and images) when the user first visits the site. It then intercepts network requests and responds with cached content when available.</p><p><strong>Caching: </strong>Now that we have a basic PWA set up with a service worker, let’s implement caching to provide offline functionality. Caching allows us to store resources locally on the user’s device so they can be accessed even when there is no internet connection.</p><p>To implement caching, we’ll use the Cache API. In the install event of the service worker, we&#39;ll open a cache and add our app shell files to it:</p><pre>self.addEventListener(&#39;install&#39;, event =&gt; {<br>  event.waitUntil(<br>    caches.open(&#39;my-cache&#39;).then(cache =&gt; {<br>      return cache.addAll([<br>        &#39;/&#39;,<br>        &#39;/index.html&#39;,<br>        &#39;/styles.css&#39;,<br>        &#39;/script.js&#39;,<br>        &#39;/images/logo.png&#39;<br>      ]);<br>    })<br>  );<br>});</pre><p>This code opens a cache called “my-cache” and adds the app shell files to it. When the service worker is installed, these files will be cached.</p><p>To serve cached content, we’ll update the fetch event of the service worker to check the cache for a response:</p><pre>self.addEventListener(&#39;fetch&#39;, event =&gt; {<br>  event.respondWith(<br>    caches.match(event.request).then(response =&gt; {<br>      return response || fetch(event.request);<br>    })<br>  );<br>});</pre><p>This code checks the cache for a response to the current request. If a cached response is found, it is returned. If not, the request is forwarded to the network.</p><p><strong>Service Workers:</strong> Service workers are a critical component of offline PWAs, as they enable us to intercept network requests and provide cached content. They also allow us to handle cache invalidation and updates.</p><p>To implement service workers, we’ll use the navigator.serviceWorker API in JavaScript. First, we&#39;ll register the service worker in our main script file:</p><pre>if (&#39;serviceWorker&#39; in navigator) {<br>  window.addEventListener(&#39;load&#39;, () =&gt; {<br>    navigator.serviceWorker.register(&#39;/service-worker.js&#39;)<br>      .then(registration =&gt; {<br>        console.log(&#39;Service worker registered:&#39;, registration);<br>      })<br>      .catch(error =&gt; {<br>        console.log(&#39;Service worker registration failed:&#39;, error);<br>      });<br>  });<br>}</pre><p>This code checks if the serviceWorker API is available and registers the service worker by calling navigator.serviceWorker.register(). We can also handle errors if the registration fails.</p><p>Now that we have a service worker registered, we can test our app in offline mode. If we disable our internet connection and refresh the page, we should still see our app shell content. This is because the service worker is intercepting requests and serving cached content.</p><p><strong>Cache Invalidation:</strong> Now that we have caching implemented, we need to handle cache invalidation to ensure that users always have up-to-date content. One way to do this is to use a versioning system for our app shell files.</p><p>First, we’ll update our service worker to use a cache name that includes the version number:</p><pre>const cacheName = &#39;my-cache-v1&#39;;<br><br>self.addEventListener(&#39;install&#39;, event =&gt; {<br>  event.waitUntil(<br>    caches.open(cacheName).then(cache =&gt; {<br>      return cache.addAll([<br>        &#39;/&#39;,<br>        &#39;/index.html&#39;,<br>        &#39;/styles.css&#39;,<br>        &#39;/script.js&#39;,<br>        &#39;/images/logo.png&#39;<br>      ]);<br>    })<br>  );<br>});<br><br>self.addEventListener(&#39;activate&#39;, event =&gt; {<br>  event.waitUntil(<br>    caches.keys().then(keys =&gt; {<br>      return Promise.all(keys<br>        .filter(key =&gt; key !== cacheName)<br>        .map(key =&gt; caches.delete(key))<br>      );<br>    })<br>  );<br>});</pre><p>This code adds a version number to the cache name and deletes any old caches when the service worker is activated.</p><p>Now, whenever we update our app shell files, we can simply update the version number in our service worker and the old cache will be automatically deleted.</p><p><strong>Conclusion:</strong> In this article, we walked through the steps of building an offline PWA using service workers and caching. We saw how to use the Cache API to store resources locally on the user’s device, and how to use service workers to intercept network requests and provide cached content. We also learned how to handle cache invalidation and updates using versioning.</p><p>With these techniques, you can build PWAs that provide a seamless experience for users, even when they are offline.</p><p><strong>Happy coding!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feefda85db33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install Flutter in Windows (Step by Step)]]></title>
            <link>https://saikumargandhi.medium.com/how-to-install-flutter-in-windows-step-by-step-9123a834d32c?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/9123a834d32c</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[studio]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[sdk]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Sat, 23 Oct 2021 21:39:32 GMT</pubDate>
            <atom:updated>2021-10-23T21:41:20.149Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZme1bfxErVfKsJx.jpg" /><figcaption>Image Source: Google</figcaption></figure><ol><li>Download the following installation bundle to get the latest stable release of the Flutter SDK: <a href="https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_2.5.3-stable.zip">https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_2.5.3-stable.zip</a> or <a href="https://flutter.dev/docs/get-started/install/windows">https://flutter.dev/docs/get-started/install/windows</a></li><li>Now create a folder anywhere, and extract the zip and move it into the created folder (Like I have create an folder called flutter in D drive). So I have extract the zip and placed it in D:\flutter.</li><li>Now we have to add the flutter path in the user variables. Click windows button, and search for environmental variables, click edit environmental variables, now select user variables. Open path in user variables (if path is not there create PATH, and enter the flutter bin path). For example the user variable path should have D:\flutter\flutter_windows_2.5.3-stable\flutter\bin</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*piEuy_ukgR1uBZ_xVH8o1w.jpeg" /><figcaption>Path for user variables</figcaption></figure><p>4. Now open the command prompt, and type “ where flutter dart ” and press enter to verify that path has been set correctly. You will get flutter, and dart installation paths indicating flutter path is set correctly and we can access flutter from anywhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*DJyB4o9HjgXDySemeD2-sw.png" /><figcaption>Checking flutter, and dart paths</figcaption></figure><p>5. Now, open the path just before bin, and type the “ flutter doctor ” to get the flutter installation status, and also verify whether all requirements are set correctly or not. The flutter doctor checks all issues, and if there are any errors it gives them in bold. Check image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*xTfpxIGBKDVTXO7rMZdplw.png" /><figcaption>Running flutter doctor, it shows any issues. At this stage we will have some errors, as we haven’t configured sdk yet</figcaption></figure><p>6. Now, we have to install the cmdline-tools components on our own. Open Android studio, click on more actions, select sdk manager. Select -&gt; <strong>Android SDK</strong> -&gt; <strong>SDK Tools</strong> -&gt; Then Check <strong>Android SDK Command-line Tools(latest)</strong> and download and install it. You can check this link for more information: <a href="https://flutter-examples.com/flutter-command-line-tools-component-is-missing/">https://flutter-examples.com/flutter-command-line-tools-component-is-missing/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gML6ZpF9AIjYCKNAvYeYSw.png" /><figcaption>Installing Android SDK command-line tools (latest)</figcaption></figure><p>7. After command-line tools component installation is done, run flutter doctor in the command prompt again, to check that command-line error is resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*k4hNJOfIF34G_JeY2_EBFA.png" /><figcaption>command-line tools issue is resolved</figcaption></figure><p>8. Now to resolve the Android Licenses, type the given command in the prompt. Type “ flutter doctor — android-licenses” and hit enter. You will get multiple prompts, and accept all prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7uPwexuSLGytGXRHmEzcw.png" /><figcaption>All new licenses are accepted</figcaption></figure><p>9. Now run the “flutter doctor” again to verify that all issues have been resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XeW7RfuIUcVMkAbNeVelMQ.png" /><figcaption>All issues have been resolved</figcaption></figure><p>10. Now add the Android SDK path to the user variables. To get Android SDK path, open Android studio, click more actions, click SDK manager, Copy the SDK path location which is available at the top, and enter this path in the user variable path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ht5AZR_02_H_ZcPtdBpzmQ.png" /><figcaption>Adding Android Studio SDK path to the User variables path</figcaption></figure><p>11. That’s it, now you can connect your mobile to the laptop and workout your flutter applications or try the flutter code on the Emulator.</p><p>Thank you for reading the article, if you like the article follow or give claps to the article 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9123a834d32c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding out Optimum Neighbours (n) number in the KNN classification using Python]]></title>
            <link>https://medium.com/analytics-vidhya/finding-out-optimum-neighbours-n-number-in-the-knn-classification-using-python-9bdcfefff58c?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bdcfefff58c</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Tue, 22 Jun 2021 19:25:47 GMT</pubDate>
            <atom:updated>2021-07-09T06:47:36.598Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*SjBEgwWJTXjp4VjhdtQJTw.png" /><figcaption>Source: Research Gate</figcaption></figure><p><strong>Classification Algorithms in Machine Learning: </strong>There are several instances where we need to identify the unknown object or data that belongs to which class by using Machine Learning. This is called Classification, and there might be an ‘m’ number of classes involved in the problem. There are various types of Classification models available in Python such as GuassianNB, DecisionTree, RandomForest, KNN with n neighbors, LogisticRegression, and SVM Classifiers. For now, we will discuss how KNN works and how to decide optimum ’n’ neighbors for maximum accuracy.</p><p><strong>KNN Classifier: </strong>KNN Classifier falls under the Supervised Classification algorithm which yields better results when compared to other classification models. KNN can be used for both classification and also regression problems. While training it tries to identify patterns from the example of the same class and identifies how each class differs from other classes. Then it maps those examples, and classes on a graph with borders at the edges of the Classes. When a new object or example is given for predicting which class it should fall under, the KNN will find the attributes associated with the given example and compares them to the various classes given in the training. The example belongs to a class if the properties of the class match that of the example.</p><p>For example, we have trained the KNN with two classes as Flying and Non-Flying animals. Now we need to identify to which class does a Chicken belongs. At first look, other classifiers will classify chicken into Flying animals due to their wings. But the KNN compares all the properties of chicken with given classes. In this case, chicken would be placed at the edge of both Flying and Non-FLying animals as it has wings but cannot fly using them. Now Gaussian distance is calculated between the chicken and other neighbor samples in the graph. If chicken matches with more neighbors of a class mean that chicken belongs to that class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*0Pqqx6wGDfFm_7GLebg2Hw.png" /><figcaption>Source: kdnuggets</figcaption></figure><p><strong>How to figure out Optimal ’n’ neighbors: </strong>Based upon ’n’ neighbors used in the KNN classifier the same example might fall under various classes. So how to figure out optimal ’n’ number for better accuracy and low error rates? To answer this we need to draw a graph between Error Rate vs K Value. Let’s see how to draw this graph using Python.</p><p>Import the StandardScaler and KNeighborsClassifier, and transform the training and testing datasets. We also need Matplotlib for drawing the graphs. You can install these packages using the <strong>pip</strong>. (Don’t forget to import matplotlib. I have imported it in previous steps as <strong>plt</strong>)</p><pre><em>#feature Scaling  </em><br><strong>from</strong> <strong>sklearn.preprocessing</strong> <strong>import</strong> StandardScaler<br><strong>from</strong> <strong>sklearn.neighbors</strong> <strong>import</strong> KNeighborsClassifier<br><br>st_x= StandardScaler()    <br>x_train= st_x.fit_transform(X_train)    <br>x_test= st_x.transform(X_test)</pre><p>Now find out the various error rates for various ’n’ neighbors. You can use the range function for this purpose. I have found error rates and stores them in an array for 1 to 40 neighbors.</p><pre>error_rate = []<br><strong>for</strong> i <strong>in</strong> range(1,40):<br> knn = KNeighborsClassifier(n_neighbors=i)<br> knn.fit(x_train,y_train)<br> pred_i = knn.predict(x_test)<br> error_rate.append(np.mean(pred_i != y_test))</pre><p>Now we need to plot these Error Rates against the Neighbor values to see which ’n’ neighbor got a low error rate. For this, we can use matplotlib package. I am also printing the lowest error rate and corresponding ’n’ neighbor value over the plot for quick results.</p><pre>plt.figure(figsize=(10,6))<br>plt.plot(range(1,40),error_rate,color=&#39;blue&#39;, linestyle=&#39;dashed&#39;,marker=&#39;o&#39;,markerfacecolor=&#39;red&#39;, markersize=10)<br>plt.title(&#39;Error Rate vs. K Value&#39;)<br>plt.xlabel(&#39;K&#39;)<br>plt.ylabel(&#39;Error Rate&#39;)<br>req_k_value = error_rate.index(min(error_rate))+1<br>print(&quot;Minimum error:-&quot;,min(error_rate),&quot;at K =&quot;,req_k_value)</pre><p>The graph would like the below image. So for best accuracy, we need to use ‘n=10’ for the KNN classifier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*4DS32DovsmR2k08tiCerZw.png" /></figure><p>I am going to train the KNN classifier with the dataset for n=10 neighbors and see how much accuracy I have got. I have saved the model into <strong>y_pred</strong></p><pre><em>#Fitting K-NN classifier to the training set  </em><br><strong>from</strong> <strong>sklearn.neighbors</strong> <strong>import</strong> KNeighborsClassifier  <br>classifier= KNeighborsClassifier(n_neighbors=req_k_value, metric=&#39;minkowski&#39;, p=2 )  <br>classifier.fit(x_train, y_train) <br>y_pred= classifier.predict(x_test)</pre><p>Now I will predict the value for the testing dataset, at the same time I am also calculating the accuracy and confusion matrix for the classifier we have trained.</p><pre><em>#Creating the Confusion matrix  </em><br><strong>from</strong> <strong>sklearn.metrics</strong> <strong>import</strong> confusion_matrix  <br>print(&quot;KNN - 10 neighbors Accuracy score and Confusion matrix&quot;)<br>print(accuracy_score(y_pred,y_test))<br>print(confusion_matrix(y_test, y_pred))<br>print(&quot;-------------------------&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*RNnJTP1M_iN_3sQJBVyIYw.png" /><figcaption>Accuracy of 88.52 for n=10 neighbors</figcaption></figure><p>Let&#39;s beautify the Confusion matrix using the matplotlib.</p><pre>plot_confusion_matrix(classifier, x_test, y_test)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*zIkO-LObUUZG1QJO-5VzzA.png" /><figcaption>Confusion Matrix for KNN with n=10 (optimal) neighbors</figcaption></figure><p><strong>Conclusion: </strong>By using the above steps we will be able to use optimum ’n’ neighbors to get maximum accuracy for the training dataset with a low error rate. However, in some cases, accuracy may be high due to Overfitting and Underfitting as training data may be very small. So, to be safe do calculate the Recall, Precision, F-Measure, Specificity, Sensitivity, ROC Score, and draw the ROC curve also. I will discuss how to calculate these in upcoming posts.</p><p><strong>Stay Tuned 😉</strong></p><p><strong>Note:</strong> If this helped you in learning anything, do click on claps. Do let me know what you think of the article in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bdcfefff58c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/finding-out-optimum-neighbours-n-number-in-the-knn-classification-using-python-9bdcfefff58c">Finding out Optimum Neighbours (n) number in the KNN classification using Python</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Immersive Technologies (VR, AR, and MR), Applications and Challenges]]></title>
            <link>https://saikumargandhi.medium.com/immersive-technologies-vr-ar-and-mr-89f07dbe1b4?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/89f07dbe1b4</guid>
            <category><![CDATA[ar]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[vr]]></category>
            <category><![CDATA[emerging-technology]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Tue, 22 Jun 2021 16:35:50 GMT</pubDate>
            <atom:updated>2021-06-22T16:37:27.394Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction: </strong>There has been a lot of scientific advancements if we compare the technologies being used by the human before the industrial revolution to the present world. Exchanging information will not take more than 10 seconds with anyone around the globe, we can travel to anyplace mostly in less than a day, make the computers and smart machines work for us to perform boring, monotonous jobs which requires accuracy and precision while we can concentrate on doing creative, and challenging tasks. Now we are at a point of time where we interact with the digital information of objects, locations, environments both virtually and even physically. This kind of immersive technology is called Extended Reality which can be further classified into 3 types based on how we interact with digital information as Virtual Reality, Augmented Reality, and Mixed Reality.</p><p><strong>Overview of how Virtual Reality (VR) works:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NPrYHx_hZJkfHOXAs928A.jpeg" /><figcaption>Source: theverge.com</figcaption></figure><p>Virtual Reality as the name suggests allows us to interact with the digital information of the objects, locations, or environment which has been captured using special gadgets over the 360-degree view. To use Virtual Reality we need special hardware called VR Headset which projects the digital information directly onto our eyes at the same time allowing us to have a 360-degree view giving us a good immersive experience. We can control our field of vision by moving our heads in different directions. Nowadays we can simply insert mobiles running VR Games or Videos into the VR Headset and interact with the digital information.</p><p><strong>Overview on how Augmented Reality (AR) works:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ujrXn0quos6Y5d4q9zU03Q.jpeg" /></figure><p>Augmented Reality is also a type of immersive technology but varies vastly when compared to Virtual Reality. In the Augmented Reality we can interact with the digital information of the objects or environment which is being projected or shown onto our real world which gives us a feeling that the object or environment is really in the real world. There has been a lot of advancements in the Augmented Reality field to improve the immersive experience more than ever. We don’t need a special kind of hardware to run the Augmented Reality other than normal smartphones in our hands. Special software is needed to be installed in our mobile which will use the camera and shows the digital information on the content captured by the camera. We can view the objects in all directions in 3D view.</p><p><strong>Overview on how Mixed Reality (MR) works:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*9VH5WPbpKDC0Mn4awkIDRw.jpeg" /></figure><p>Mixed Reality is an extension of Virtual Reality and provides us with an even greater immersive experience. Mixed Reality allows us to interact with the digital information of the objects, or environment both Virtually and physically at the same time. Just like VR here also we need special hardware called MR Headset and some special handheld gadgets or gloves or external sensors which will track the movement of the hands and provides us interaction over the objects or environment physically.</p><p><strong>Applications of VR:</strong></p><ul><li>In Military: We can use Virtual Reality to train the soldiers in combative locations like in war, we can also run various immersive simulations for air-force officers.</li><li>In Medicine: This immersive experience can also the trainee doctors to practice various complicated surgeries and study the human organs virtually and plan for surgeries.</li><li>In Education: We can explain complicated topics by showing their digital information to the students, and they will also understand it better in this way.</li></ul><p><strong>Applications of AR:</strong></p><ul><li>In Medicine: Doctors can be trained on the Human organs as they can be viewed in the 3D model rather than in virtual reality.</li><li>In Fashion: Using AR we can show how an item or dress looks on the customer for customization without customers trying the items or dresses.</li><li>In Tourism: We can use AR to provide Augmented Tour Guides who can explain things without being present at the location.</li></ul><p><strong>Applications of MR: </strong>As MR is being explored recently there are some fewer applications in practice now. But MR is the future of immersive technologies with a lot of scope in the future.</p><ul><li>In Design: We can use mixed reality to design a product digitally as we can interact with digital information physically</li><li>In Gaming: Immersive gaming is possible as we can interact with the in-game items physically and virtually at the same time.</li></ul><p><strong>Challenges to Implement the VR, AR, and MR: </strong>Like every new technology has lots of challenges and hardships before making them usable by everyone there are some challenges that needs to be addressed by VR, AR and MR to be used in real-world such as:</p><ul><li>Hardware Requirements: As we have discussed till now the Virtual Reality and Mixed Reality need some special hardware such as external sensors and special hardware Headsets to interact with digital information. These Headsets are a bit expensive. While AR doesn’t need special hardware but it would need the latest smartphone with inbuilt sensors to render the digital information onto the real world.</li><li>Limited Content: For both VR and MR which provides us a 360-degree point of view we need to gather digital information of objects or the environment in 360 degrees at the same time using special cameras. For AR we need to generate 3D models for objects and the environment.</li><li>Physical Risks: As these are immersive technologies we might lose the sense of the real world we are in. There are lots of instances where people are involved in accidents and in the worst-case died in accidents while using these immersive technologies. The best example would be a lot of accidents and traffic deaths where people playing Pokemon-Go a classic example of how AR can be used while playing it on live traffic.</li></ul><p><strong>How organizations can prepare for VR, AR, and MR:</strong></p><ul><li>Create Digital Data regarding their products in various environments, it’s great if they can add customizations to the products.</li><li>Create Awareness among the customers on how to use the VR, AR, and MR to try out them virtually and how to interact with them.</li><li>Promote Brand using the VR, AR, and MR games and related content on social media and digital platforms.</li><li>Share all the VR, MR, and AR digital information generated by the companies openly for reuse by others. IN this way we are promoting the usage of digital information providing all companies with a lot of options rather than creating content every time and for every object.</li></ul><p><strong>Conclusion: </strong>It is exciting to use immersive technology and being able to interact with the digital information of the objects or environment without it being actually present near us. But care should be taken while using VR, AR, and MR in order to avoid tragedies like traffic accidents and road kills. There are a lot of applications regarding VR, AR, and MR as there are a lot of advancements in this field nowadays. So companies should take appropriate steps to ensure they can keep up with advancements with these technologies and promote the usage of these technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89f07dbe1b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolution of Industrial Revolution]]></title>
            <link>https://saikumargandhi.medium.com/evolution-of-industrial-revolution-77a9ad14148f?source=rss-2cf973c1e3fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/77a9ad14148f</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[emerging-technology]]></category>
            <category><![CDATA[industrial-revolution]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[smart]]></category>
            <dc:creator><![CDATA[Sai Kumar Gandhi]]></dc:creator>
            <pubDate>Tue, 22 Jun 2021 16:19:22 GMT</pubDate>
            <atom:updated>2021-06-22T16:19:22.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*da0nN8jmhnq7yx4vespK1g.png" /><figcaption>Source: Wikipedia</figcaption></figure><p><strong>Introduction: </strong>Nowadays we are enjoying the benefits of machines and several gadgets in everyday life. We can send information from any place to any place in the world within seconds and everything can be accessed using just a smartphone that can fit inside your palm. For centuries the changes in technologies and communication dictate the job opportunities and new skills required for finding a job. This transition is considered as Industrial Revolution and they can be divided into mainly 4 industrial revolutions.</p><p><strong>Industrial Revolution — 1: </strong>The first industrial revolution is also known as the original industrial revolution. This happened in the late 18th century where the power of steam and mechanization replaced most of the manual labor. Till the late 18th century all the jobs and works need to done using manual labor. With the advent of steam-based mechanizations into the industries, the production time decreased very much with an increase in inaccuracy.</p><p><strong>Industrial Revolution -2: </strong>As the first industrial revolution advent the use of steam-based mechanizations, energy usage efficiency is very less. In the 2nd industrial revolution of the late 19th century and the beginning of the 20th century, electricity is used as a primary energy resource for mechanical tools instead of steam. Assembly line jobs are also introduced this time increasing the efficiency of the job process for mass production.</p><p><strong>Industrial Revolution -3: </strong>This took place in the ’70s of the 20th century. This happened due to the rapid advancements in electrical components like Transistors, Integrated circuits allowing partial automation of several assembly line process jobs. With the advent of more technical gadgets, the automation process has been advanced more and more.</p><p><strong>Industrial Revolution -4: </strong>This is also called as Smart Factories revolution due to the usage of intelligent ai and other advancements in information and communication technologies. Due to these changes, we can make more changes as more information can be exchanged done in the Industrial revolution-3. All these lead to fully automated industries, affect production costs, make decisions based on previous data using data mining techniques, and low downtime in production. Digitalization would be the most noticeable feature of this era.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77a9ad14148f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>