<?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 Ajay Muktha on Medium]]></title>
        <description><![CDATA[Stories by Sai Ajay Muktha on Medium]]></description>
        <link>https://medium.com/@ajaymuktha?source=rss-1cd833534437------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*VcQ86eP8OAczzZ9ztaQl9g.jpeg</url>
            <title>Stories by Sai Ajay Muktha on Medium</title>
            <link>https://medium.com/@ajaymuktha?source=rss-1cd833534437------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:25:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajaymuktha/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[useState() in React]]></title>
            <link>https://medium.com/@ajaymuktha/usestate-in-react-c2555c1becf7?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2555c1becf7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 15:52:10 GMT</pubDate>
            <atom:updated>2023-01-07T15:52:10.785Z</atom:updated>
            <content:encoded><![CDATA[<p>Introducing state in React</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJCXqrp-PSpTfn4EolrZ8w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Safar Safarov</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>React is a JavaScript library for building user interfaces. A user interface is anything we put in front of users to have them interact. React uses components to display the content on the page. It was developed by Facebook in 2013 and used for Mobile and web applications.</p><p>We have two types of components in React namely class-based and functional-based components.</p><p>Class Based Components are known as Stateful Components. It extends the component class from react. It must have the render() method to return HTML and it&#39;s complex to read. It contains life cycle methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/0*Klq9Yq4ohgGX6lO5.png" /><figcaption>Class-Based Component</figcaption></figure><p>Functional Components are also known as Stateless components. These are simply JavaScript functions with no render method as class-based components. The JSX code will be written inside the return to render it. These can also be created using arrow functions(ES6), with the introduction of hooks in the 16.8 version, we can manage the state in Functional components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/0*X3bM7nFXr_jrvbGd.png" /><figcaption>Functional Component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/0*ahOpRMyqTEKlr1YQ.png" /><figcaption>Arrow Function(ES6)</figcaption></figure><h4>About useState:</h4><p>It helps us to add a state to the functional components. Whenever we define useState(), it returns two things, the first one is the current value of the state and the second is the function that allows us to update the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IklAYrAfByiXZDMkDVePnQ.png" /><figcaption>useState syntax</figcaption></figure><p>In the above snippet, we initialized the count state with a value of 0 and it will always give us the current state value, we make use of the second argument which is setCount to update the state value.</p><h4>Implementation</h4><p>Create a new project using create-react-app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*vuAxy5_Zc728GtghvMzCUQ.png" /><figcaption>Creating React App</figcaption></figure><p>Let&#39;s import useState() hook from react and create two input elements inside the form tag to take the input values of the author and title. We also need to create a submit type to add those values to the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*qyPiI-8Pd5cTbSSd-Jwb_g.png" /></figure><p>We will create two states. One is for the author’s name, and the other is for the book&#39;s name. We will also create another state for the book list which stores all these state values and displays them in the list format.</p><p>Whenever users enter some value in the input box, we need to keep track of it, we make use of onChange event to fulfill this purpose and set that entered value as per the input text type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*Af9AfTBHOUEp6WX3T_UZKQ.png" /></figure><p>We need to write a method to add the author and title to the book&#39;s state. We will take the title and author as arguments and add those values to the book state using setBooks method. The state contains the values of previous books as well as new book. We also need to pass this as the onSubmit method inside the form so that the values will be added once we click on Add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*8M-_VsW0YwR_ZN7f-lc1Ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*tktpYyYJkfOPETlf-7HqLg.png" /></figure><p><strong>Displaying Books:</strong></p><p>We will iterate through the books array using the map method and display the list of books in the UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*S7pHtIm39w2lCxg5IDViXQ.png" /></figure><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*vcLDQsy6xPoEjpHqNXaZtA.png" /></figure><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a>. Check out my blogs on Machine Learning, Deep Learning, and React.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2555c1becf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accordion in React]]></title>
            <link>https://medium.com/@ajaymuktha/accordion-in-react-3713509f1074?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/3713509f1074</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 10:31:21 GMT</pubDate>
            <atom:updated>2022-06-01T11:06:26.314Z</atom:updated>
            <content:encoded><![CDATA[<p>Building Accordion from scratch</p><p>Accordion menus can be used to display FAQs, allows users to toggle between hiding and displaying content in a webpage. In this blog we will cover how to develop an accordion menu in React from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2LAiuBDgvyzG-_XZNNTp4Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@clark_fransa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Arnold Francisca</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Project Setup</h4><p>Create a new project using create-react-app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*QWIrQQ7qlaV_fgwycLY29A.png" /><figcaption>Creating React App</figcaption></figure><p>Now Let’s create a new component for questions and import it in App.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*Z4n-IF-zr43ecvVVM0P8eA.png" /><figcaption>Question.js</figcaption></figure><p>Now we need data to display content in accordion, we will create a new file for data and add some dummy data inside it and import the file in App.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*ED7QPGmUOc4XXnqYY4e6FQ.png" /><figcaption>data.js</figcaption></figure><h4>React Icons</h4><p>Let’s install React Icons for Accordion menu and import few icons into our new component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*qTLWLxfm1cmVMRErO81WUA.png" /><figcaption>Installing React Icons</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*IeX6kcbhtboJHlhnCuGUJA.png" /><figcaption>importing icons in Question.js</figcaption></figure><p>Now, we will map the data and pass data as props from App component into Question component. As we have five questions, we will get five questions in the display.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*LaNtQliL2dAr6p0Tj4pb4g.png" /><figcaption>App.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*zjqxOd0CpXzBM6KMK6ulGw.png" /><figcaption>Output</figcaption></figure><p>We will accept the data into Question component and lets display the data. You can find style sheet in the code link mentioned at last.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*iU1raRTUyrVQyqSY-v5dMA.png" /><figcaption>Question.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*QTkoeJbpLLMqTseXa0mnqQ.png" /><figcaption>Output</figcaption></figure><p>Create a useState hook of boolean type that will conditionally render the information based on boolean value. If the state value is true, it will display additional information of the question, if it’s false, it will hide the information. We need to use AND logic (&amp;&amp;) to implement this functionality</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*Z4T7b00vDxd9rufMJs6cVA.png" /><figcaption>Question.js</figcaption></figure><h3>How to Open and Close the Accordion Menu</h3><p>We will attach an on-Click event that will toggle the showDetails state and will display accordingly. In addition to that, to change the icons dynamically based on the condition we will use Ternary operator. It evaluates the condition and executes the block of code based on the condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*AeYLOiwik_MeMTYuXOQZ7g.png" /><figcaption>Ternary operator syntax</figcaption></figure><p>If the condition is true, exp1 is executed</p><p>If the condition is false, exp2 is executed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*mkxd9-MD34uzFFAI_xu4bg.png" /><figcaption>Added Ternary Operator</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*pHUQvHMIVK7wAQ6zfUufAQ.png" /><figcaption>Final Output</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*KFU_2L4P5UEmOmV7wtua2g.png" /><figcaption>Final Output</figcaption></figure><p>You can find the link for the code below</p><p><a href="https://github.com/ajaymuktha/React-Accordion">GitHub - ajaymuktha/React-Accordion</a></p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning, React and Deep Learning.</p><ul><li><a href="https://medium.com/@ajaymuktha/introduction-to-react-a9e766a6f596">Introduction to React</a></li><li><a href="https://pub.towardsai.net/beginners-guide-to-cloud-computing-af2e240f0461">Beginners Guide to Cloud Computing</a></li><li><a href="https://medium.com/dataseries/introduction-to-convolutional-neural-networks-5a227f61dd50">Introduction to Convolutional Neural Networks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3713509f1074" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modals in React]]></title>
            <link>https://towardsdev.com/modals-in-react-b2d31ecfcef5?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2d31ecfcef5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Sun, 08 May 2022 14:08:08 GMT</pubDate>
            <atom:updated>2022-06-03T06:49:05.437Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step by step guide on building modals in React</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YjfOanhazw8oQW2p.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vincentiu?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Vincentiu Solomon</a> on <a href="https://unsplash.com/s/photos/space?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>A Modal is a message box/pop-up that is shown on the top of the screen. These are used in different contexts from alerts to inputs. In this blog, we will learn how to implement a modal in React JS.</p><p>If you would like to brush up on basics or would like to learn about react, check out the blog below</p><p><a href="https://medium.com/@ajaymuktha/introduction-to-react-a9e766a6f596">Introduction to React</a></p><h3>Create React App</h3><p>Let’s create a new React app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/0*XEU96JvH7PLbgJ3Y.png" /><figcaption>Creating React App</figcaption></figure><p>Create a new component in src and import it in App.js and add some text and a button in the new component. We can make use of Children Props to make the modal re-usable. I will explain this in the next blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/0*fuTJ3qE5bHPYz2ZC.png" /><figcaption>Modal.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/0*AbKPxJ0BzdHYerOI.png" /><figcaption>App.js</figcaption></figure><h3>Adding Styles</h3><p>To make it appear as a dialogs/modal, let us add some stylings by creating a new CSS file in the src folder. Import that CSS file into the new component that we have added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/0*s7yEjLlc6kmoWUgw.png" /><figcaption>Styles of Modal Component</figcaption></figure><p>It looks better :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*_hwZ8fxW8DcBfzXF.png" /></figure><h3>Using Functions as Props:</h3><p>We need to create a useState() hook of boolean type. This state will control whether the modal should be shown or not. If the state value is true, it will show the modal else it will hide it.</p><p>When the user clicks on the close button in the Modal component we need to change the value of the state to false so that it will close. We can’t directly change that state in the child component because the state is defined in the Parent component. We can create a function in the parent component and pass it as props to the child component to solve this. Pass this function as a prop to the Child component.</p><p>Now accept the function by de-constructing it and attaching it to the on-Click event on the close button so that whenever we click on close, the state value changes to false, and the modal will be closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*eHr70LPBDjRsJuvq.png" /><figcaption>App.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/0*O3kmSh7U24QAVUXG.png" /><figcaption>Modal.js</figcaption></figure><h3>Time to Hide</h3><p>Now let us implement logic to hide the modal whenever we click on close. We can conditionally show the UI only if it is true using AND (&amp;&amp;) logic. Using the AND logic we’ll show the modal only if it is true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/0*PUVikOgjTw3lVfAP.png" /><figcaption>App.js</figcaption></figure><h3>Showing the Modal</h3><p>By default, the modal value will be false. We need to add a button in App.js to show the modal once we click. We need to add a button in App.js and attach an on-click event that will change the state value to true to show the modal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*isFQz5KmTCg93tEc.png" /><figcaption>App.js</figcaption></figure><p>You can find the link for the code below</p><p><a href="https://github.com/ajaymuktha/ModalApp-React">GitHub - ajaymuktha/ModalApp-React</a></p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a>. Check out my blogs on Machine Learning, Deep Learning, and React.</p><ul><li><a href="https://medium.com/dataseries/introduction-to-convolutional-neural-networks-5a227f61dd50">Introduction to Convolutional Neural Networks</a></li><li><a href="https://medium.datadriveninvestor.com/introduction-to-knn-k-nearest-neighbors-56d2d39915fb">Introduction to KNN(K-Nearest Neighbors)</a></li><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2d31ecfcef5" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/modals-in-react-b2d31ecfcef5">Modals in React</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to React]]></title>
            <link>https://towardsdev.com/introduction-to-react-a9e766a6f596?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9e766a6f596</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Wed, 04 May 2022 07:36:13 GMT</pubDate>
            <atom:updated>2022-06-10T06:24:36.703Z</atom:updated>
            <content:encoded><![CDATA[<p>Building steps for your first React Application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtP-0rzg3A3icwo4qVfmIQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Caspar Camille Rubin</a> on <a href="https://unsplash.com/s/photos/react.js?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Hello everyone, welcome to my blog on introduction to React, In this blog, we will discuss some important topics and will also make a counter app in react which will boost your confidence to dig deep into the concepts of React.</p><h4>What is React?</h4><p>As per the official documentation, React is a JavaScript library for building user interfaces. A user interface is anything we put in front of users to have them interact. React uses components to display the content in the page. It was developed by Facebook in 2013 and used for Mobile and web applications.</p><h4>Components in React</h4><p>Here, we break down our application/website into components which are small pieces of code that are reusable. For instance, the footer in your site or button is a component, and the header and navbar are also considered a component.</p><p>We have two types of components</p><ol><li>Functional Components</li><li>Class-Based Components</li></ol><h4>Functional Components</h4><p>These are also known as Stateless components. These are simply JavaScript functions with no render method as class-based components. The JSX code will be written inside return to render it. These can also be created using arrow functions(ES6).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*Py0kdVSoAiv7-UYXMfU3Lw.png" /><figcaption>Functional Component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*xDwvNrIqL1vCAikDptpWnw.png" /><figcaption>Arrow Function</figcaption></figure><h4>Class-Based Components</h4><p>These are known as Stateful Components. It extends component class from react. It must have the render() method to return HTML and its complex to read when compared with Functional Components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*ddU8JvLboOzI74H4iKJmIA.png" /><figcaption>Class-Based Components</figcaption></figure><h4><strong>Virtual DOM</strong></h4><p>DOM stands for <strong>Document Object Model. </strong>It represents the UI of the application. Whenever there is a change in your application, the DOM gets updated to reflect that change in UI. Manipulation of DOM is slow and is very expensive to handle.</p><p>React introduced a feature called Virtual DOM. In this concept whenever we make any changes in the application, the virtual DOM is updated and it is compared with the previous Virtual DOM and only the changes that were done gets updated in the Real DOM in the best method which decreases the load on performance.</p><h4>State</h4><p>It is a JavaScript object that holds information. These are mutable which means we can change the values. Whenever the values in the state update/change, the component will re-render. It makes the components dynamic. To change the data, we make use of <strong>this.setState </strong>in Class-based components and <strong>useSatate() </strong>hook in Functional Based Component.</p><h4>JSX</h4><p>JSX stands for JavaScript XML. In this, we can write HTML code inside JavaScript. This is rendered to the normal browser JavaScript by the pre-processors like Babel.</p><h4>Props</h4><p>These are used to pass data from one component to another component as parameters. Props are immutable so we cannot modify them inside the child component. We can access the data using <strong>this.props </strong>else we can de-structure it and call the values directly in JSX.</p><h4>Installation Setup</h4><ol><li>NodeJS and NPM</li><li>Code-Editor (Atom/VS Code…)</li></ol><h4>Nodejs:</h4><p>We can install node.js using the link below, please install which is recommended for most users.</p><p><a href="https://nodejs.org/en/">Node.js - Run JavaScript Everywhere</a></p><p>After installing it, restart your system and open the command prompt, and try verifying if it&#39;s installed or not using the below commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*AQgLMmdEezg5IpoPWUIMKg.png" /><figcaption>node installation</figcaption></figure><p>Create a new folder in your machine, navigate to that folder, and open cmd, there in-order to create react application we must use the below command.</p><p><strong>npx create-react-app appname</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*K1rtmKpaCwE2O-VHmQlQJQ.png" /><figcaption>creating react-app</figcaption></figure><p>It will take some time to create a react project. Once it&#39;s done, it will be shown as below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*MgoDTe_YNgi3DePPSf0UAg.png" /><figcaption>after app creation</figcaption></figure><p>Now navigate inside your react application folder using <strong>cd </strong>and enter the command shown in the image to run your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*LTHM3YW4mburoMRp03YrQw.png" /><figcaption>To Start Application</figcaption></figure><p>It will run in localhost and shown as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*hEtY9cw6hy16HXhzevIzlg.png" /><figcaption>Home Page</figcaption></figure><p>Open your project folder in the code editor, I will be using VS Code for this demo. Our project structure looks like the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*PS359paMvkMdPwX0e7-o3A.png" /><figcaption>Folder Structure</figcaption></figure><p>In React application, there are several files and folders. Some of them are as follows:</p><ol><li><strong>node modules:</strong> This folder contains all the necessary libraries which are required to run your application. Whatever library you are importing in your application, should be installed and must be present in the node modules folder.</li><li><strong>public:</strong> It holds the public assets of the application. It contains the index.html where we can change the title of our app. We can also add scripts and stylesheets. In addition to that, we can also store images.</li><li><strong>src:</strong> This is the main folder of our React application. We will create our components and screens inside this folder. It also contains test scripts.</li><li><strong>package.json:</strong> It holds metadata related to our project. It gives information about the dependencies used so that it would be easy to install and use in other systems.</li><li><strong>README.md:</strong> It can be useful to write a summary of the project. It uses markdown markup language to create content.</li></ol><p>After making desired changes, Webpack recompiles the code, and the page will refresh automatically, and changes are reflected on the browser screen.</p><h3>Counter Application</h3><p>It&#39;s time to make a Counter application. Create a component in the src folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*tnKB7X5Wiaz8nn-FAMDtew.png" /><figcaption>created component called Counter</figcaption></figure><p>Now we will create a functional component and import the useState hook. The code will be as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*Rcl79tIAdrEfmi9rmh6Eeg.png" /></figure><h4>Creating HTML elements and importing Counter.js</h4><p>Now inside return, we need to add three buttons namely +, -, and reset</p><ul><li><strong>+</strong>: To Increment the counter value</li><li><strong>-</strong> : To Decrement the counter value</li><li><strong>Reset</strong>: To reset the counter value to 0.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*6jdmTyb4XLAbGdaE5b6GrA.png" /></figure><p>Open your App.js file and remove the header section then import your component as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*RqLHQYog-URps9Ga9v8uVg.png" /></figure><h4>Create States and Functions</h4><p>We will create a state called <strong>countNum</strong> which stores the counter value. Initially, the state value will be 0. Whenever the user clicks on <strong>+ </strong>or -, the value will change. We will use three functions to control the state value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*wLYOPDNAbSsEs7bKAxizMQ.png" /></figure><p>We change the value of the counter using <strong>setCountNum. In order</strong> to display the counter value, we use {countNum} inside &lt;p&gt; tag. We made use of on-click events in the corresponding functions for logic.</p><h4>Adding Styles</h4><p>The app is working as expected, now we will add some styles to it. Add the below-mentioned CSS styles in App.css</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*XalrLHNjhL9X3dlLTyDr8w.png" /><figcaption>CSS styles</figcaption></figure><h4>Final Output:</h4><p>Below is an image of the browser view of this app. It&#39;s fully functional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*tJQI64WIxCD5GToctHgLfA.png" /><figcaption>Final Demo</figcaption></figure><p>You can find the link for the code below</p><p><a href="https://github.com/ajaymuktha/CounterApp">GitHub - ajaymuktha/CounterApp</a></p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning and Deep Learning.</p><ul><li><a href="https://medium.com/dataseries/data-preprocessing-with-python-3914d3e9dd30">Data-Preprocessing with Python</a></li><li><a href="https://towardsdatascience.com/introduction-to-transfer-learning-c59f6f27e3e">Introduction to Transfer Learning</a></li><li><a href="https://towardsdatascience.com/image-classifier-using-tensorflow-a8506dc21d04">Image Classifier using TensorFlow</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9e766a6f596" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/introduction-to-react-a9e766a6f596">Introduction to React</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginners Guide to Cloud Computing]]></title>
            <link>https://pub.towardsai.net/beginners-guide-to-cloud-computing-af2e240f0461?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/af2e240f0461</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 00:03:07 GMT</pubDate>
            <atom:updated>2020-10-18T00:03:07.434Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsai.net/p/category/cloud-computing">Cloud Computing</a></h4><h4>A comprehensive guide on the basics of cloud computing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKY1flVxYMMGeldL4xLbjg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@scienceinhd?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Science in HD</a> on <a href="https://unsplash.com/s/photos/server?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Imagine you would like to train a deep learning model where you have thousands of images, but your system does not have any GPU. It would be hard to train large training models without GPU, so you will generally use google collab to train your model using google’s GPU’s.</p><p>Consider your system memory is full, and you have important documents and videos to be stored and should be secured. Google drive can be one solution to store all your files, including documents, images, and videos up to 15GB, and offers security and back-up.</p><p>Above mentioned scenarios are some of the applications of Cloud Computing, one of the advantages of using cloud computing is that <strong>you only pay for what we use.</strong></p><h3>What is Cloud?</h3><p>Cloud computing refers to renting resources like <strong>storage space</strong>, <strong>computation</strong> <strong>power</strong>, and <strong>virtual machines</strong>. You only pay for what you use. The company that provides these services is known as a<strong> cloud provide</strong>r. Some examples of cloud providers are <strong>Microsoft Azure</strong>, <strong>Amazon Web Servies</strong>, and<strong> Google Cloud Platform</strong>.</p><p>The cloud’s goal is to provide a smooth process and efficiency for the business, start-ups, and large enterprises. The cloud provides a wide range of services based on the needs of the enterprises.</p><h3>Types of Cloud Computing</h3><p><strong>IaaS — Infrastructure as a Service</strong></p><p>In this, cloud suppliers provide the user with system capabilities like storage, servers, bandwidth, load balancers, IP addresses, and hardware required to develop or host their applications. They provide us virtual machines where we can work. Instead of buying hardware, with IaaS, you rent it.<br>Examples of IaaS include DigitalOcean, Amazon EC2, and Google Compute Engine.</p><p><strong>Saas — Software as a Service</strong></p><p>Most people use this as a daily routine. We get access to the application software. We do not need to worry about setting up the environment, installation issues, the provider will take care of all these.</p><p>Examples of Saas include Google Apps, Netflix.</p><p><strong>Paas — Platform as a Service</strong></p><p>It provides services starting from operation systems, programming environment, database, tests, deploy, manage, and updates all in one place. It generally provides the full life cycle of the application.</p><p>Examples of Paas include Windows Azure, AWS Elastic Beanstalk, and Heroku.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*8teN1nnjU_pDqqKECU5EfQ.jpeg" /><figcaption>Credits: Microsoft</figcaption></figure><h3>Benefits</h3><p>Most of the enterprises are moving to the cloud to save money on infrastructure and administration costs and most of the new companies are starting from the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFynpPKC08pbuGwyMKwNXA.png" /><figcaption>Image by <a href="https://pixabay.com/users/tumisu-148124/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3337536">Tumisu</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3337536">Pixaba</a>y</figcaption></figure><h4>cost-effective</h4><p>If we are using cloud infrastructure, we do not need to invest in purchasing hardware, servers, computers, buildings, and security. We do not even need to employ data engineers to manage the flow. Everything is taken care of by the cloud.</p><h4>scalable</h4><p>One of the best things in the cloud is decreasing or increasing the workload depending on the incoming traffic to our webpages. If it has high traffic, we can increase the workload by adding some servers. If the traffic suddenly starts showing a declining movement, it is flexible to dispatch the added servers.</p><p>We have two options in order to provide flexible services depending on the needs</p><ol><li>Vertical Scaling</li><li>Horizontal Scaling</li></ol><p>In<strong> Vertical Scaling, </strong>we add resources to increase the servers’ performance by adding some memory and Processors.</p><p>In <strong>Horizontal Scaling</strong>, we add servers to provide a smooth process for sites when we have more incoming traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*w7AzsJ5WbeS5rUWyyMT4hQ.png" /></figure><h4>reliable</h4><p>In case of a disaster or grid failures, the cloud ensures that your data is safe and will not be depleted away. Redundancy is also added in the cloud to ensure that we have another same component to run the same task if one component fails.</p><h4>global</h4><p>Cloud has a lot of data centers all around the world. If you want to provide your services to a particular region that is far away from your place, you can make it happen with no downtime and less response time with the cloud’s help.</p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning and Deep Learning.</p><ul><li><a href="https://medium.com/dataseries/what-is-machine-learning-c1332527f3ff">What is Machine Learning?</a></li><li><a href="https://medium.com/dataseries/data-preprocessing-with-python-3914d3e9dd30">Data-Preprocessing with Python</a></li><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af2e240f0461" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/beginners-guide-to-cloud-computing-af2e240f0461">Beginners Guide to Cloud Computing</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polynomial Regression with Python]]></title>
            <link>https://medium.com/dataseries/polynomial-regression-with-python-430c74127115?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/430c74127115</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Mon, 05 Oct 2020 13:37:11 GMT</pubDate>
            <atom:updated>2020-10-05T13:37:11.094Z</atom:updated>
            <content:encoded><![CDATA[<p>A comprehensive guide on how to perform polynomial regression</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b8jvWSRvhSt26LHXgBiUQA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fabioha?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">fabio</a> on <a href="https://unsplash.com/@fabioha?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Artificial Intelligence (AI) and machine learning technology have been developing rapidly in recent years. We see both of them in our life daily. If you look behind the scenes, you can observe a lot of applications in existence ranging from medical applications to customer recommendations. The fields of AI are making a major breakthrough that no one has ever imagined.</p><p>If you are a newbie and need to brush up about regression, have a look at my articles on Linear Regression and Multiple Regression which helps you understand it.</p><ul><li><a href="https://medium.com/swlh/introduction-to-machine-learning-algorithms-linear-regression-39d422efa7dc">Introduction to Machine Learning Algorithms-Linear Regression</a></li><li><a href="https://medium.com/datadriveninvestor/introduction-to-machine-learning-algorithms-multiple-linear-regression-a65c7ae8c2a6">Introduction to Machine Learning Algorithms-Multiple Linear Regression</a></li></ul><h3>Linear Regression</h3><p>Linear Regression is one of the most used techniques for fitting a straight line to a linear data<em>. </em>If we try to fit a straight line to nonlinear data, the model would undergo underfit and the performance would be poor and we end up getting less prediction rate and high error rate. An example can be shown below for such a case</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/0*isKbhCo4Py1nmuLu.jpeg" /><figcaption>Linear Regression curve</figcaption></figure><p>In the above graph, we can observe that the linear regression model doesn’t fit well for the given data points. Some points lie above the line while others lie below the line. This gives rise to a significant error in our model. A simple straight line might not be the best case for the above dataset.</p><p>Sometimes we can have a more complex distribution of data. It’s hard to fit a straight line to these data. The relationship between the dependent and independent variables is complex.</p><h3>What is Polynomial Regression?</h3><p>In Simple Linear Regression, we use a straight line to fit our dataset. But in some datasets, when the dataset is non-linear it’s hard to fit a line. Therefore we use Polynomial Regression. It is represented by the equation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/0*fgtjSp-mheD_SrPd.jpeg" /><figcaption>Polynomial Regression equation</figcaption></figure><p>It is a form of regression in which the relationship between an independent and dependent variable is modeled as an nth degree polynomial. An example of Polynomial Regression can be shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*gVpxBDFWwpJFADsf.jpeg" /><figcaption>PolynomialRegression Curve</figcaption></figure><h3>Advantages</h3><ul><li>It provides a better relationship between independent and dependent variables.</li><li>It fits under a wider range of quadratic equations.</li></ul><h3>Disadvantages</h3><ul><li>The presence of outliers will affect the results.</li></ul><h3>Let’s Code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*maMB7F1JTlu_eQ0-2HNYfA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@joshuaryanphoto?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Joshua Reddekopp</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Here we use the scikit-learn library to import the linear regression model and use it directly. There are many datasets available online for linear regression. You can find the dataset and code in the below link</p><p><a href="https://github.com/ajaymuktha/Machine-Learning">ajaymuktha/Machine-Learning</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d94adb67b83d62fd03cf63b0315b3f28/href">https://medium.com/media/d94adb67b83d62fd03cf63b0315b3f28/href</a></iframe><p><strong>Numpy</strong> → It is a library used to perform mathematical operations on arrays.</p><p><strong>Pandas</strong> → To load the data file as a Pandas data frame and analyze the data.</p><p><strong>Matplotlib</strong> → I’ve imported pyplot to plot graphs of the data.</p><h3>Import data</h3><p>Our file is in the CSV(Comma Separated Values) format, so we import the file using pandas. Then we split the data into Dependent and Independent variables. X is considered as Independent variables and Y is considered as Dependent variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f7797375e228869d51316badb17b8fb/href">https://medium.com/media/1f7797375e228869d51316badb17b8fb/href</a></iframe><p>Here, we don’t need to split the data into train and test set as it only contains ten columns and the second reason is that we are going to make an accurate prediction which is based on a real-world scenario and we need to train the model with maximum info that is available.</p><p>The goal of our model is to predict the salary of an employee based on his/her position, the independent variable X contains the position level of an employee and the dependent variable Y contains the Salary.</p><h3>Let’s fit the data</h3><p>From Sklearn, sub-library Linear Regression we import Linear Regression and we fit the model on the training data. The main reason behind creating a Linear Regression model is to compare it with the Polynomial Regression model and determine which model performs well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be0ef6c0fc1d190ef9a402996ae13f55/href">https://medium.com/media/be0ef6c0fc1d190ef9a402996ae13f55/href</a></iframe><h3>Polynomial Fit</h3><p>From Sklearn, sub-library preprocessing, we import PolynomialFeatures. We create an object for it and mention the required degree of the polynomial. We will create another Linear Regression object through which we will fit our X_poly and Y.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e364cec5c914e88c0d05e9b3292668d/href">https://medium.com/media/3e364cec5c914e88c0d05e9b3292668d/href</a></iframe><h3>Let’s plot our model!!</h3><p>Here we will create two scatter plots for comparing how the Linear Regression model and Polynomial Regression models performed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/599c3d0a4124570aec41740af36227e1/href">https://medium.com/media/599c3d0a4124570aec41740af36227e1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/0*naQXHhs-qXZ3CQ1j.jpeg" /><figcaption>Linear Regression plot</figcaption></figure><p>The Linear Regression model performed bad and the accuracy is poor, let’s plot the polynomial regression model on the same data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ae7a0f4a131ede27bd5ddd642636870/href">https://medium.com/media/7ae7a0f4a131ede27bd5ddd642636870/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/0*LfiArTQ3bmVsP_vM.jpeg" /><figcaption>Polynomial Regression plot</figcaption></figure><p>It seems like our model performed well, Here is a summary of what I did: I have loaded in the data, split the data into dependent and independent variables, fitted a Linear Regression model and Polynomial Regression model on the data, and visualized how the model performed on two different models.</p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning and Deep Learning.</p><ul><li><a href="https://medium.com/dataseries/what-is-machine-learning-c1332527f3ff">What is Machine Learning?</a></li><li><a href="https://medium.com/dataseries/data-preprocessing-with-python-3914d3e9dd30">Data-Preprocessing with Python</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=430c74127115" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dataseries/polynomial-regression-with-python-430c74127115">Polynomial Regression with Python</a> was originally published in <a href="https://medium.com/dataseries">DataSeries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Machine Learning?]]></title>
            <link>https://medium.com/dataseries/what-is-machine-learning-c1332527f3ff?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1332527f3ff</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Tue, 29 Sep 2020 12:39:17 GMT</pubDate>
            <atom:updated>2020-09-30T10:20:34.568Z</atom:updated>
            <content:encoded><![CDATA[<p>All you need to know about Machine Learning</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H5t3IbdLTSyw6TdAt-rSzg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@askkell?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andy Kelly</a> on <a href="https://unsplash.com/s/photos/automation?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Artificial Intelligence (AI) makes it possible for machines to learn from experience, adjust to new inputs, and perform human-like tasks. People across different domains are trying to apply AI to make their jobs a lot easier.</p><p>These fields are developing rapidly in recent years. We see both of them in our life daily. We can observe many applications, ranging from medical applications to customer recommendations. The fields of AI are making a significant breakthrough that no one has ever imagined.</p><p>For example, doctors use AI applications to provide personalized medicine and X-ray readings. In retail, AI provides virtual shopping capabilities that offer personalized recommendations and discuss the purchase options with the consumer. Banking AI techniques can identify which transaction is likely to be fraudulent.</p><h3>Machine Learning</h3><p>It is the development of computer programs that allow computers to learn automatically without human intervention. We can call it as a tool for transforming information into knowledge. From the past 40 years, a lot of data is generated and is kept aside and not used for analyzing purposes. Here comes the role of Machine Learning; these techniques are used to analyze the data, extract meaningful insights, visualize data, and find many more valuable patterns in data. We can even predict future events using the data provided through which we can make decisions.</p><h3>Applications</h3><p>We are already interacting with Machine Learning every day; sounds surprised? It’s true, whenever you are searching for an item and when you reopen your device, you can find the advertisements regarding it. When it comes to Netflix, with the help of recommendation algorithms, it can recommend movies on your favorite genre. Some applications of Mchine Learning includes</p><ul><li>Advanced machines will be delivered an accurate diagnosis of a patient.</li><li>It helps you in classifying whether the received mail is spam or not.</li><li>Voice recognition, image search is possible due to Machine Learning.</li><li>Search engines offer recommendations based on your previous search.</li></ul><h3>Terminology in Machine Learning</h3><h4>1. Dataset</h4><p>It is a collection of data in a tabular form. It is composed of rows and tables. Every column describes the particular feature, and every row corresponds to the value of that feature. Generally, the dataset will be in CSV(Comma Separated Value) format. We can even use TSV(Tab Separated Values) and many other types.</p><h4>2.Train Set</h4><p>The dataset is divided into test and train. The training dataset is considered for training our model so that our model learns the relations between the data and can provide better predictions.</p><h4>3.Test Set</h4><p>This data set is used to measure how well our model is performed by comparing the expected results and our data.</p><h4>4.Validation Set</h4><p>A subset of the dataset from the training set is considered for validation.</p><h4>5.Accuracy</h4><p>Accuracy is a measure of how well the model is performed.</p><h4>6. Categorical data</h4><p>Categorical data has discrete qualitative values. For example, the colors of the cars are red, blue, white, black.</p><h4>7.Feature Engineering</h4><p>The process of determining which features might be useful during training a model</p><h4>8.Imputation</h4><p>It is a technique used for handling missing values in the data.</p><h3>Steps in Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1X6mray94LLG3Q3ppiT6w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@franki?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Franki Chamaki</a> on <a href="https://unsplash.com/s/photos/machine-learning?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Get the Data</h4><p>Based on your problem statement, you need to collect the data as per it. The quality and quantity of data gathered determines your model performance.</p><h4>Data Preparation</h4><p>The collected data may not be in the required form. For example, a machine learning model won’t accept categorical data, and it would be a problem if the data has missing values, and when the data is not normalized.</p><p>In this step, we need to fill the missing data. If necessary, we can drop those missing values. We need to convert the categorical values into numerical values. All values on the independent side should be categorized. It would be difficult for the mode to take it as input and train.</p><h4>Choosing a Model</h4><p>We have many machine learning models, and model selection plays a vital role in determining the predictive power of the problem statement. For continuous value prediction, we generally use regression models, and for categorical class prediction, we use classification algorithms like Logistic Regression, Decision Trees, and many more.</p><h4>Training</h4><p>Once the data organized, we divide the data into a train set and test set based on randomness. We train our model with our training data to understand the relations within the data and make better predictions.</p><h4>Evaluating</h4><p>Once our model is trained, we evaluate the model performance using test data. We make use of some evaluation metrics to measure the performance of our model. For example, in classification models, we make use of Precision, Recall, F1 score.</p><h4>Parameter Tuning</h4><p>If the evaluation is successful, then we proceed with the next step. If the evaluation result is low, there are chances that our model has a drawback of <strong>underfitting</strong> or <strong>overfitting. </strong>In this case, make sure you adjust the learning rate of the model and also increase the number of echos and try changing the other hyper-parameters.</p><h4>Prediction</h4><p>Prediction is the final stage of our model, where we consider whether our model is ready to face real-world or practical applications. This stage is what the end-users see when they use the machine learning model within their respective industry.</p><h3>Types of Machine Learning</h3><h4>Supervised Machine Learning</h4><p>Supervised Learning is where the data is labeled, and the program learns to predict the output from the input data.</p><p><strong>Regression:</strong></p><p>In regression problems, we are trying to predict a continuous value. Examples are:</p><ul><li>What is the housing price in Tokyo?</li><li>What is the value of cryptocurrencies?</li></ul><p><strong>Classification:</strong></p><p>In classification problems, we are trying to predict a discrete number of values. Examples are:</p><ul><li>Is this email spam?</li></ul><h3>Unsupervised Learning</h3><p>Unsupervised Learning is a type of machine learning where the model learns the structure of the data based on unlabeled examples.</p><p><strong>Clustering</strong> is a common unsupervised machine learning approach that finds patterns and structures in unlabeled data by grouping them into clusters.</p><p>Examples</p><ul><li>Consumer sites clustering users for recommendations</li><li>Search engines to group similar objects in one cluster.</li></ul><h3>Semi-supervised Learning</h3><p>Supervised learning algorithms are trained on datasets that have labels that are added by domain experts. Unsupervised Algorithms are trained on unlabelled data to determine feature importance on their own patterns using data.</p><p>Semi-supervised learning algorithms are trained on a combination of labeled and unlabeled data. It consists of a small amount of labeled data and a large amount of unlabelled data.</p><h3>Reinforcement Learning</h3><p>Reinforcement Learning(RL) is a technique that enables an agent to learn in an interactive environment using feedback from its own actions and experiences. It uses rewards and punishments as signals for positive and negative feedback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*QGgq-EH_OXFVnShEfcwxSw.png" /><figcaption>Credits:researchgate.net</figcaption></figure><p>Reinforcement Learning has four essential elements:</p><ol><li><strong>Agent.</strong> The program you train to perform a specific task.</li><li><strong>Environment</strong>: A place where an agent learns and performs an action.</li><li><strong>State</strong> — It refers to the environment of the agent.</li><li><strong>Action.</strong> A move made by the agent, which changes its state in the environment.</li><li><strong>Rewards. </strong>The evaluation of an action, which can be positive or negative.</li></ol><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning and Deep Learning.</p><ul><li><a href="https://medium.com/swlh/introduction-to-machine-learning-algorithms-linear-regression-39d422efa7dc">Introduction to Machine Learning Algorithms-Linear Regression</a></li><li><a href="https://medium.com/datadriveninvestor/introduction-to-machine-learning-algorithms-multiple-linear-regression-a65c7ae8c2a6">Introduction to Machine Learning Algorithms-Multiple Linear Regression</a></li><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1332527f3ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dataseries/what-is-machine-learning-c1332527f3ff">What is Machine Learning?</a> was originally published in <a href="https://medium.com/dataseries">DataSeries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data-Preprocessing with Python]]></title>
            <link>https://medium.com/dataseries/data-preprocessing-with-python-3914d3e9dd30?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/3914d3e9dd30</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Tue, 29 Sep 2020 11:29:08 GMT</pubDate>
            <atom:updated>2020-09-29T18:54:08.533Z</atom:updated>
            <content:encoded><![CDATA[<p>Making data understandable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5cpyPF0pN_DMYgdB51wJw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lukechesser?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Luke Chesser</a> on <a href="https://unsplash.com/s/photos/data?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Considering the fact that high-quality data leads to better predictions, data preprocessing has become a fundamental step in data science and machine learning. We’ll talk about the importance of processing data and discuss different approaches in sequence.</p><h3>What is Data PreProcessing</h3><p>It is a technique that transforms raw data into an understandable format. Real-world data(raw data) is always incomplete and that data cannot be sent through models as it would cause certain errors. That is why we need to preprocess data before sending it through a model.</p><p>Here are the steps I have followed;</p><ol><li>Import libraries</li><li>Read the Dataset</li><li>Split the dataset into independent and dependent</li><li>Handling missing values</li><li>Handling categorical values</li><li>Standardization/ Feature Scaling</li></ol><h3>Step 1: Import Libraries</h3><p>The first step is usually importing the libraries that will be needed in the program. A library is essentially a collection of modules that can be called and used. Here we will be using</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8519421bcf8b0ff61efb72767c1c1fb/href">https://medium.com/media/f8519421bcf8b0ff61efb72767c1c1fb/href</a></iframe><p><strong>Pandas</strong>: We use pandas for data manipulation and data analysis.<br><strong>Numpy</strong>: It is a fundamental package for scientific computing with Python.</p><h3>Step 2: Import the Dataset</h3><p>Most of the dataset’s come in .csv(comma-separated value) format. It’s important to keep the dataset in the same folder as your program and read it using a method called<em> read_csv</em> which can be found in the library called <em>pandas</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9261d0fe7b7794ebefba3425dfb39ef/href">https://medium.com/media/d9261d0fe7b7794ebefba3425dfb39ef/href</a></iframe><h3>Step 3: Split the data into independent and dependent features</h3><p>We will create a matrix of features in our dataset by creating an Independent variable(X) and a dependent variable (Y).To read the columns, we will use <em>iloc </em>of <em>pandas</em> which takes two parameters — [row selection, column selection].</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e290e180ea6806536c906db4db1fb5d7/href">https://medium.com/media/e290e180ea6806536c906db4db1fb5d7/href</a></iframe><p>: as a parameter, it selects all rows in the data. For columns, we have -1, which means all the columns will be selected except for the last one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JnxdcB5Y7-11ji6yU7qE3g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mjessier?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Myriam Jessier</a> on <a href="https://unsplash.com/s/photos/data-analysis?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Step 4: Handling Missing Values</h3><p>Sometimes we find some data is missing in the dataset. Missing values need to be handled carefully because they reduce the quality of any of our performance matrix and prediction. No model can handle these NULL or NaN values on its own so we need to deal with it. Firstly, we need to check whether we have null values in our dataset or not. We can do that using the isnull() method.</p><p>Handling the missing values is one of the greatest challenges faced by analysts because making the right decision on how to handle it generates robust data models. Let us look at different ways of imputing the missing values.</p><h4>Deleting Rows</h4><p>This is the most commonly used method. We either delete a row which has null values and a particular column if it has more than 60% of missing values. This method is only used when that column does not affect the model&#39;s prediction that is that feature has less significance or no significance for predicting the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea47caed208a7004d8ff1338ab76431b/href">https://medium.com/media/ea47caed208a7004d8ff1338ab76431b/href</a></iframe><h4>Replacing With Mean/Median/Mode</h4><p>This method can be applied to the features which consist of numerical data. We can calculate the mean, median, or mode of the feature and replace it with the missing values. This method gives better results compared to the removal of rows and columns.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9da23bcf63f577d62b86bb2163c0e137/href">https://medium.com/media/9da23bcf63f577d62b86bb2163c0e137/href</a></iframe><h3>Handling Categorical Data</h3><p>Sometimes our data is in text form. We can find categories in text form. It gets complicated for machines to understand texts and process them since the models are based on mathematical equations and calculations. Therefore we need to encode the data into numbers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d67b6cd87ba32e8cdbe35f428babc8e1/href">https://medium.com/media/d67b6cd87ba32e8cdbe35f428babc8e1/href</a></iframe><p>To make this happen we import a library called <em>LabelEncoder from scikit-learn </em>which we will use for the task<em>. </em>We will create an object of that class. We will call our object labelencoder_X. <em>fit_transform </em>method in the LabelEncoder class will help us.</p><p>Now, the text has been replaced by numbers, what if there are more than two categories we keep assigning integers to different categories which lead to confusion. Suppose we have four categories and we assign the first category with 0 and the last category with 3. However, since 1 is greater than 0 and 3is greater than 1 the equations in the model we think 3 has the highest priority than 0. In order to resolve this problem, we use dummy variables where we will have n number of columns for n categories for that we make use of <em>OneHotEncoder</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dac26534d55bbf13551029b901bc8f3b/href">https://medium.com/media/dac26534d55bbf13551029b901bc8f3b/href</a></iframe><p>We will import another class called <em>OneHotEncoder from scikit learn. </em>we will create an object of that class and consider a parameter called categorical_features which takes a value of the index of the column and use fit_transform() for OneHotEncoding as well.</p><p>ColumnTransformer allows the input to be transformed separately and the features generated are concatenated to form a single space. It is useful for a heterogeneous data transformations</p><h3>Feature Scaling</h3><p>It is used to standardize the values of Independent variables. It is a method used to limit the range of variables so that they can be easily compared.</p><h4>Why is it necessary?</h4><p>Most of the machine learning models are based on Euclidean distances. The square difference with the lower value in comparison to the far greater value will almost be treated as if it does not exist. We do not want that to happen. That is why it is necessary to transform all our variables into the same scale.</p><p>Most of the Machine Learning models are based on Euclidean distances. Consider if the square root value of (x2-x1) is greater than (y2-y1), then (y2-y1) will be neglected. We don’t want this to happen. That is why it is necessary to transform all our variables into the same scale. There are two ways you can do this.</p><h3>Normalization</h3><p>With the help of Normalization, we scale the feature values in between 0.0 and 1.0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*xOuWfQsjWRlpHxhv3UhgzA.png" /></figure><h3>Standardization</h3><p>It scales features to have a mean of zero and a standard deviation one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*yFw-7hoa7qe0cSWAPXqsDw.png" /></figure><p>we need to import StandardScaler from the scikit preprocessing library and create an object of that class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c28c01dd45240b13ebe2ca9dd4e64d02/href">https://medium.com/media/c28c01dd45240b13ebe2ca9dd4e64d02/href</a></iframe><p>It’s time to fit and transform our X_train set. When we apply Standard Scaler to our training and testing sets. We need to fit and transform only to the training set, In case of the test set, we need to transform, no need to fit it to the test set. This will transform all the values to a standardized scale.</p><p>Thank you for reading my article. I will be happy to hear your opinions. Follow me on Medium to get updated on my latest articles. You can also connect with me on<a href="https://www.linkedin.com/in/mukthasaiajay/"> Linkedin</a> and <a href="https://twitter.com/saiajay5">Twitter.</a> Check out my blogs on Machine Learning and Deep Learning.</p><ul><li><a href="https://medium.com/swlh/introduction-to-machine-learning-algorithms-linear-regression-39d422efa7dc">Introduction to Machine Learning Algorithms-Linear Regression</a></li><li><a href="https://medium.com/datadriveninvestor/introduction-to-knn-k-nearest-neighbors-56d2d39915fb">Introduction to KNN(K-Nearest Neighbors)</a></li><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3914d3e9dd30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dataseries/data-preprocessing-with-python-3914d3e9dd30">Data-Preprocessing with Python</a> was originally published in <a href="https://medium.com/dataseries">DataSeries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Transfer Learning]]></title>
            <link>https://medium.com/data-science/introduction-to-transfer-learning-c59f6f27e3e?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/c59f6f27e3e</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Tue, 04 Aug 2020 15:37:03 GMT</pubDate>
            <atom:updated>2020-08-04T15:37:03.713Z</atom:updated>
            <content:encoded><![CDATA[<h4>A comprehensive guide on transfer learning from scratch</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3w5y1U2ItR25RwH0QB80g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@shotbycerqueira?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Shot by Cerqueira</a> on <a href="https://unsplash.com/s/photos/space?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>We as humans have the ability to transfer the knowledge gained in one task to use it another task, the easier is the task the easier is to utilize the knowledge. Some simple examples would be:</p><ul><li>Know Math and Statistics → Learn Machine Learning</li><li>Know how to ride a bicycle → Learn how to ride a Motor Bike</li></ul><p>Most of the Machine Learning and deep learning algorithms so far are designed to focus on solving specific tasks. These algorithms are again rebuilt if any distribution changes and it would be hard to rebuilt and retrain it as it requires computational power and a lot of time.</p><p>Transfer learning is all about how to use a pre-trained network and apply it to our custom task, transferring what it learned from previous tasks.</p><p>Transfer learning is where we take architecture like VGG 16 and ResNet which are the result of many architectures and extensive hyperparameter tuning based on what they have already learned we apply that knowledge to a new task/model instead of starting from scratch which is called Transfer learning.</p><p>Some of the Transfer Learning models include:</p><ul><li>Xception</li><li>VGG16</li><li>VGG19</li><li>Resnet, ResnetV2</li><li>InceptionV3</li><li>MobileNet</li></ul><h4>Implementing Medical Application Using Transfer Learning</h4><p>In this application, we will detect whether the person is having pneumonia or not. We use a Kaggle dataset for this classification. The link to the dataset and code is given below.</p><p><strong>Dataset Link:</strong></p><p><a href="https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia">Chest X-Ray Images (Pneumonia)</a></p><p><strong>Code Link:</strong></p><p><a href="https://github.com/ajaymuktha/DeepLearning/blob/master/TransferLearning/transfer-learning.ipynb">ajaymuktha/DeepLearning</a></p><p>The Dataset consists of a Train set and Test set with subfolders as normal and pneumonia. Pneumonia has the chest x-ray images of people who are suffering from pneumonia and the normal folder has images who are normal i.e free from lung disease.</p><h3>Installing Tensorflow</h3><p>You can either use Google Colab if your PC or laptop doesn’t have a GPU or else you can use Jupyter Notebook. If you use your system, upgrade pip and then install TensorFlow as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*XAIKZKm5Cg4kMudj.jpeg" /><figcaption>tensorflow.org</figcaption></figure><h4>Import Libraries</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d9e5fb1215b17edbfcc8b41208181a6/href">https://medium.com/media/5d9e5fb1215b17edbfcc8b41208181a6/href</a></iframe><h4>Re-Size Images</h4><p>Here, we will be resizing all the images to 224*224 because we use the VGG16 model and it accepts images of size 224*224.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2afa9036a4c7e8035bc35b8df6152ee0/href">https://medium.com/media/2afa9036a4c7e8035bc35b8df6152ee0/href</a></iframe><h4>Train and Test path</h4><p>We will specify the train and test path fro training.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86132a487c35b0993f58b9837253a768/href">https://medium.com/media/86132a487c35b0993f58b9837253a768/href</a></iframe><h4>Importing VGG16</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73f86629553e846249cfbc66721f0e6c/href">https://medium.com/media/73f86629553e846249cfbc66721f0e6c/href</a></iframe><p>Here, we will import the VGG16 model weights for our application. We should declare an <strong>image size</strong> to the model, which we have done in the previous step, argument 3 represents that the image will accept RGB image i.e the color image. To train our model, we use <strong>imagenet</strong> weights and <strong>include_top = False </strong>means it will remove the last layers from the model.</p><h4>Training Layers</h4><p>Models like VGG16, VGG19, Resnet, and others have been trained on thousands and thousands of images and these weights are used to classify thousands of classes so we use these models weights for classification of our model, so we do not need to train the model again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ffd1440ed63b3bf65b0ae80953ab28b/href">https://medium.com/media/7ffd1440ed63b3bf65b0ae80953ab28b/href</a></iframe><h4>Number of Classes</h4><p>we use<strong> glob</strong> to find out the number of classes in our model. The number of subfolders in our train folder represents the number of classes in our model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/644824b695ecb41ef6789271480bc8b1/href">https://medium.com/media/644824b695ecb41ef6789271480bc8b1/href</a></iframe><h4>Flattening</h4><p>Whatever we got as output from VGG16, we are going to flatten it and we removed the last layers from VGG16 so that we can keep our own output layer. we replace the last layer with the number of categories we have in our problem statement. We consider softmax as our activation function and we are appending it to x.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12dd2893ab1b81b503db4834711652b4/href">https://medium.com/media/12dd2893ab1b81b503db4834711652b4/href</a></iframe><h4>Model</h4><p>We will wrap it into a model where the input refers to what we have from VGG16 and output refers to the output layer that we created in the previous step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76aa802c489a315a6ac030cf9cd95c6d/href">https://medium.com/media/76aa802c489a315a6ac030cf9cd95c6d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/712cf877884c4c56962548665ae5aee2/href">https://medium.com/media/712cf877884c4c56962548665ae5aee2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*JE4_tryFBh9ZwQlP-Aiq5Q.jpeg" /></figure><p>The above picture is the summary of our model and in the dense layer, we have two nodes because of two different categories we have<strong> pneumonia</strong> and <strong>normal.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4TBfhu-v3-3tJsmzC86XCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@justinoneto?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Justino Neto</a> on <a href="https://unsplash.com/s/photos/space?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Compile</h4><p>We compile our model using categoricaa_cross_entropy as loss, adam optimizer, and accuracy as metrics. If you are not aware of what these terms mean, I will mention the link to my blogs at the last of the article where I explain all these terms in clear.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f14d9f92d9dd684083cd40e2c32378a8/href">https://medium.com/media/f14d9f92d9dd684083cd40e2c32378a8/href</a></iframe><h4>Pre-Processing</h4><p>We will apply some transformations on the training images to avoid overfitting, if we do not perform we get a large difference between the accuracy of the training set and the test set.</p><p>We perform some geometrical transformations like flipping the image horizontally, flipping vertically, zoom in, zoom out and many more can be performed, we apply it so that our model won’t over learn our training images. We perform the above methods using the <strong>ImageDataGenerator</strong> class.</p><p>We don’t apply transformations for the test set because we only use them to evaluate, the only task to do with our test set is to rescale the images because in the training part we defined a target size for the image that could be fed into the network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/149c6379e12d81124b418f56f9424f35/href">https://medium.com/media/149c6379e12d81124b418f56f9424f35/href</a></iframe><p><strong>flow_from_directory</strong> will connect the Image Augmentation process to our training set. We need to mention the path of our training set. <strong>Target size</strong> is the size of the image that should be fed into the Neural Network. <strong>Batch size</strong> is defined as the no of images in a batch, the<strong> class mode</strong> would be categorical as we only have two outputs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b2acab1663a040356e7f758d242fcc4/href">https://medium.com/media/8b2acab1663a040356e7f758d242fcc4/href</a></iframe><p>Now we define the test set that imports our test images from the directory. We do define the batch size, target size, and class mode as same mentioned in the training set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a02c41abc0813ee6656fdee300d0d611/href">https://medium.com/media/a02c41abc0813ee6656fdee300d0d611/href</a></iframe><h4>Fit the Model</h4><p>We will fit our model and declare the number of epochs as five, steps per epoch would be the length of the training set and validation steps would be the length of the test set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/591df01316b133f14ab07e4b38b400a7/href">https://medium.com/media/591df01316b133f14ab07e4b38b400a7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*zCauF0keclshVa3j7YeTbg.jpeg" /></figure><p>That&#39;s great, we achieved an accuracy of around 97.7% and validation accuracy of 91.5%, that’s the power of transfer learning. Hope you enjoyed this tutorial on Transfer Learning. If you would like to know about how Artificial Neural Networks and Convolutional Neural Networks work along with an application, check out my blogs below:</p><ul><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li><li><a href="https://towardsdatascience.com/building-an-ann-with-tensorflow-ec9652a7ddd4">Building an ANN with Tensorflow</a></li><li><a href="https://medium.com/dataseries/introduction-to-convolutional-neural-networks-5a227f61dd50">Introduction to Convolutional Neural Networks</a></li><li><a href="https://towardsdatascience.com/image-classifier-using-tensorflow-a8506dc21d04">Image Classifier using TensorFlow</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c59f6f27e3e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/introduction-to-transfer-learning-c59f6f27e3e">Introduction to Transfer Learning</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Classifier using TensorFlow]]></title>
            <link>https://medium.com/data-science/image-classifier-using-tensorflow-a8506dc21d04?source=rss-1cd833534437------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8506dc21d04</guid>
            <category><![CDATA[deep]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sai Ajay Muktha]]></dc:creator>
            <pubDate>Tue, 28 Jul 2020 14:20:26 GMT</pubDate>
            <atom:updated>2020-07-28T14:20:26.077Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step by step guide on how to create an image classifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTAXD3yL71N4BKVO5s2Z_g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jeremythomasphoto?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jeremy Thomas</a> on <a href="https://unsplash.com/s/photos/space?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>If you are not aware of how Convolutional Neural Networks work, check out my blog below which explain about the layers and its purpose in CNN</p><p><a href="https://medium.com/dataseries/introduction-to-convolutional-neural-networks-5a227f61dd50">Introduction to Convolutional Neural Networks</a></p><p>We are going to work on cats and dogs dataset which means our network will predict whether the provided image is a cat or a dog. You can find the link for the dataset and code below</p><ul><li><a href="https://www.kaggle.com/tongpython/cat-and-dog">Cat and Dog</a></li><li><a href="https://github.com/ajaymuktha/DeepLearning/blob/master/Convolutional%20Neural%20Networks/cnn.py">ajaymuktha/DeepLearning</a></li></ul><p>I took around 10,000 images from the dataset for easy computation and made a validation folder and placed some random images of cats and dogs to test the classifier after training.</p><p>The dataset contains two folders<strong> Train</strong> and T<strong>est. </strong>The Train folder contains two folders which consist of images of cats and dogs which are used for training. The Test folder also consists of two folders which consist of images of cats and dogs which are used for evaluating the model. The training set consists of 8000 images of cats and dogs and the test set consists of 2000 images and cats and dogs</p><h3>Installing Tensorflow</h3><p>You can either use Google Colab if your PC or laptop doesn’t have a GPU or else you can use Jupyter Notebook. If you use your system, upgrade pip and then install TensorFlow as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/0*veS_ZXK6SlnO-dRP.jpeg" /><figcaption>tensorflow.org</figcaption></figure><h3>Import dependencies</h3><p>In the above lines of code, I just imported all the libraries I will be needing in the process</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca6d3292ea3b8717cd8b815ddcb5c897/href">https://medium.com/media/ca6d3292ea3b8717cd8b815ddcb5c897/href</a></iframe><h3>DataPreprocessing</h3><h4>Preprocessing of Training Set</h4><p>We will apply some transformations on the training images to avoid overfitting, if we do not perform we get a large difference between the accuracy of the training set and the test set.</p><p>We perform some geometrical transformations like flipping the image horizontally, flipping vertically, zoom in, zoom out and many more can be performed, we apply it so that our model won’t over learn our training images. We perform the above methods using the <strong>ImageDataGenerator</strong> class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257175cd2810eab087fcd073f59b356f/href">https://medium.com/media/257175cd2810eab087fcd073f59b356f/href</a></iframe><p><strong>train_datagen</strong> is the instance of ImageDataGenerator class that will apply all the transformations on the images in the training set, the rescale method will apply feature scaling to all the pixels in the images so that it would be in the range of 0 to 1. Now we need to connect it to our training dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc1798658684af7da480bc768d5ee7f6/href">https://medium.com/media/bc1798658684af7da480bc768d5ee7f6/href</a></iframe><p><strong>flow_from_directory</strong> will connect the Image Augmentation process to our training set. We need to mention the path of our training set. <strong>Target size</strong> is the size of the image that should be fed into the Neural Network. <strong>Batch size</strong> is defined as the no of images in a batch, the<strong> class mode</strong> would be binary as we only have two outputs either a cat or a dog.</p><h4>Preprocessing Test Set</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23e2d7396a9bace1b8d31273a1c46f58/href">https://medium.com/media/23e2d7396a9bace1b8d31273a1c46f58/href</a></iframe><p>We don&#39;t apply transformations for the test set because we only use them to evaluate, the only task to do with our test set is to rescale the images because in the training part we defined a target size for the image that could be fed into the network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f32a8c0ddd64c92f6736655f83e4fd69/href">https://medium.com/media/f32a8c0ddd64c92f6736655f83e4fd69/href</a></iframe><p>Now we define the test set that imports our test images from the directory. We do define the batch size, target size, and class mode as same mentioned in the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbD-SzNRK_kNHDWNUVSJDQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vincentiu?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Vincentiu Solomon</a> on <a href="https://unsplash.com/s/photos/space?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Building CNN</h3><p>The Convolutional Neural Network is a series of Sequential layers, so here we define it with a Sequential Class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15ebdc322f893482058bb9fc36ef9bc9/href">https://medium.com/media/15ebdc322f893482058bb9fc36ef9bc9/href</a></iframe><h4><strong>Convolution Layer</strong></h4><p>We use<strong> add a </strong>method to add the layers, Firstly we add Convolutional layers Conv2D class, we need to pass three parameters inside this which are</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d993de323d0c488df941127a23b93100/href">https://medium.com/media/d993de323d0c488df941127a23b93100/href</a></iframe><p><strong>filters</strong> → No of Feature Detectors you need to apply for the image, it is also known as kernels.</p><p><strong>kernel-size</strong> → need to define a kernel size for your feature detector in terms of no of rows and columns.</p><p><strong>input_shape</strong> → Whenever we add the first layer in any deep learning model, we need to specify the input_shape, as we are dealing with the images we need to provide the target size we mentioned above in the training set, 3 refers to the RGB channel.</p><p><strong>activation_function</strong> → We need to specify the activation function which triggers the mechanism.</p><h4>Pooling</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7dd1c3c6d6fcd64adbbe3c9fb195644/href">https://medium.com/media/a7dd1c3c6d6fcd64adbbe3c9fb195644/href</a></iframe><p>Here, we consider Max Pooling class and we need to specify two arguments</p><p><strong>pool_size</strong> → It is the size of the frame which we apply for the obtained feature detector in the Convolution layer.</p><p>stride → By how much the frame should be shifted in all four directions</p><p>Now, we apply the Second Convolutional layer to our network</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94216a311e0a92602ce5132b1a987676/href">https://medium.com/media/94216a311e0a92602ce5132b1a987676/href</a></iframe><h4>Flattening</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba59195eb16325f065f1794dc1ca2588/href">https://medium.com/media/ba59195eb16325f065f1794dc1ca2588/href</a></iframe><p>Here, we convert all the convolution and max-pooling layers into One-Dimensional which will become the input to the fully connected layer.</p><h4>Fully Connected Layer</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f0e296350eb9174c4a498d575c57966/href">https://medium.com/media/8f0e296350eb9174c4a498d575c57966/href</a></iframe><p>The arguments that we pass into our Dense Layer are the number of hidden neurons as units, activation function we use would be relu.</p><h4>Output Layer</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebf030374a311ee2770c86bd67b93e22/href">https://medium.com/media/ebf030374a311ee2770c86bd67b93e22/href</a></iframe><p>The number of output units would be 1 as we are going to predict only one class and the activation function would be sigmoid activation function.</p><h3>Training the CNN</h3><h4>Compiling the CNN</h4><p>We consider the compile method in which we take two arguments one is a compiler which is adam and a loss function which is binary_crossentropy and we choose metrics as accuracy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/676e33d57a662e5dacf13a9e8c8c4ebe/href">https://medium.com/media/676e33d57a662e5dacf13a9e8c8c4ebe/href</a></iframe><h4><strong>Training the CNN</strong></h4><p>We’ll be using the fit method to train with the training set and also use the test set to evaluate the model. We will run it on 25 epochs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f8733ce28532e774365e83db92d7828/href">https://medium.com/media/1f8733ce28532e774365e83db92d7828/href</a></iframe><h4>Prediction</h4><p>Let us predict by taking a random image, for that, we import the essential libraries NumPy … and image for performing image operations. We use <strong>load_img</strong> function which loads image in PIL format, we mention the path of the test image and also it should have the same size as the training image. Then we use img_array function which converts the image to array fro preprocessing as the model expects it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/825d2679e1d838d54bdc2320f7bf9197/href">https://medium.com/media/825d2679e1d838d54bdc2320f7bf9197/href</a></iframe><p>Our CNN model is trained as batches of images, not as an individual image, so we need to add an extra dimension. We will be adding an extra dimension in order to access the individual image. We do it using<strong> expand_dim</strong> function in NumPy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ae1525554d9b93690af51d5233862ca/href">https://medium.com/media/6ae1525554d9b93690af51d5233862ca/href</a></iframe><p>We use the predict method on test images and also access the labels of the image from the batch size and use if-else condition to check whether the image is cat or dog.</p><p>That’s all for now, hope you enjoyed this tutorial on the classification of cats and dogs, In my next blog, I will explain you about the importance of Recurrent Neural Networks and implement an application of it from scratch.</p><p>If you would like to know about how Artificial Neural Networks work along with an application, check out my blogs below:</p><ul><li><a href="https://towardsdatascience.com/introduction-to-artificial-neural-networks-ac338f4154e5">Introduction to Artificial Neural Networks</a></li><li><a href="https://towardsdatascience.com/building-an-ann-with-tensorflow-ec9652a7ddd4">Building an ANN with Tensorflow</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8506dc21d04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/image-classifier-using-tensorflow-a8506dc21d04">Image Classifier using TensorFlow</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>