<?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[Guidona - Medium]]></title>
        <description><![CDATA[GUIDONA SOFTPEDIA PRIVATE LIMITED is a young yet extremely dependable organization that is not making brands tech-savvy rather making Technology brand savvy. We would love to be associated with you at the business challenge stage rather than just execution. - Medium]]></description>
        <link>https://medium.com/guidona-softpedia?source=rss----466176dbf1d2---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Guidona - Medium</title>
            <link>https://medium.com/guidona-softpedia?source=rss----466176dbf1d2---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:34:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/guidona-softpedia" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating modern dashboards in Tableau]]></title>
            <link>https://medium.com/guidona-softpedia/creating-modern-dashboards-in-tableau-2182499a48df?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/2182499a48df</guid>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[covid19]]></category>
            <dc:creator><![CDATA[Megha]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 13:00:46 GMT</pubDate>
            <atom:updated>2021-06-19T13:00:46.282Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is data visualization?</strong></p><p>Data visualization is a graphical representation of the data procured. This technique helps decision-makers and analysts to act quickly based on the visualized data.</p><p>This is a simple tutorial on how to make a modern-looking dashboard on the data provided by WHO on the current COVID situation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*645SGXxB1C25Mhtzg2EYCA.png" /><figcaption>COVID-19 Dasboard</figcaption></figure><p><strong>About Tableau Public</strong></p><p>Tableau Public is a free platform that allows users to publically share and explore visualizations online. You can make an account and download the application from <a href="https://public.tableau.com/s/">https://public.tableau.com/s/</a></p><p>After downloading the application, it will take you to the main screen that will have different options to import your data from different sources. Here, we will import an excel file. To do this:</p><ul><li>Click on <strong>Microsoft Excel</strong></li><li>Select the desired Excel file and click <strong>Open</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xw4oeDyFdZoKUp8EjVDxyw.png" /><figcaption>Importing the dataset</figcaption></figure><p>To add another data source:</p><ul><li><strong>Data &gt;</strong>&gt;<strong>New Data Source</strong></li><li>Click on <strong>Microsoft Excel</strong></li><li>Select the desired Excel file and click <strong>Open</strong></li></ul><p>On the left, we can see that our sheets in the excel file are displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jn235lyUkhQveEABxB-ABQ.png" /><figcaption>Analyzing the data-source</figcaption></figure><p>We can even directly join both the datasets by simply adding connections:</p><ul><li>Click <strong>Add</strong> (in front of connections)</li><li>Select the desired dataset</li><li>Drag the sheet of the dataset in the view</li><li>A window will appear for selecting the column from each dataset that we wish to use as a plug</li><li>Select the type of join</li></ul><p>After having a closer look at our data, we can begin with our analysis by selecting <strong>Sheet 1</strong></p><p><strong>Maps</strong></p><ul><li>On dragging the location to the sheet and the New cases column to the <strong>Color</strong> tab, we get all the locations present in our dataset.</li></ul><p>Select a map chart from the <strong>Show Me</strong> tab. We get a map with locations having a range of colors, where the darker color represents a higher number of cases than the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VELSlO_9_9y_aIw1kOxXvQ.png" /><figcaption>Map Chart</figcaption></figure><p>There might be locations that are unrecognized by Tableau. We can easily resolve this by simply editing them.</p><ul><li>Select <strong>Edit Locations</strong></li><li>Select the column containing the locations</li><li>Simply type in the locations and select them from drop-down</li><li>Or enter the latitude and longitude instead</li><li>If you do not want those locations, simply click <strong>Filter data</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUuPP4Vz5g2V08FcABeSBw.png" /><figcaption>Editing locations</figcaption></figure><p>To make the visual more attractive, we can assign an icon to every country, where the size of the icon can represent the number of cases.</p><ul><li>Drag New cases to size (gives automatic circles of different sizes on respective countries)</li><li>Select <strong>Shape</strong> mark from the drop-down</li><li>Now, the icon(s) can be downloaded from websites like <a href="https://www.flaticon.com/">https://www.flaticon.com/</a></li><li>Add the PNG pictures to <strong>Documents </strong>&gt;&gt; <strong>My Tableau Repository </strong>&gt;&gt; <strong>Shapes </strong>&gt;&gt; *folder name*</li><li>Select <strong>Reload Shapes</strong></li><li>Select the desired icon</li><li>Press <strong>Apply </strong>&gt;&gt; <strong>OK</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WuKNLCB5FpDz4Y5UmUzlyA.png" /><figcaption>Replacing circles with icons</figcaption></figure><p><strong>Formatting the map</strong></p><p>We can select the theme of the map :</p><ul><li><strong>Maps</strong> &gt;&gt; <strong>Background Maps</strong> &gt;&gt; *select the theme*</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*8U8VCDafJM3Zg-fzCnrycA.png" /><figcaption>Selecting map background</figcaption></figure><p>You can also select how dark/light you want the background of the map to be and what parts you want to show on the map by selecting <strong>Map Layers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*RyO111rYoxYkpJTCnALwYw.png" /><figcaption>Formatting the map background</figcaption></figure><p><strong>Editing the Tooltip</strong></p><p>Tooltips can help engage the audience with data at a far deeper level. When we hover over a mark, the tooltip displays relevant data and details from another/same visualization filtered to that mark.</p><ul><li>Select Tooltip from Marks</li><li>Change the font color, style, and size according to the requirements of your dashboard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdTOXng7Nms0vQ0DDZxL6Q.png" /><figcaption>Tooltip</figcaption></figure><p><strong>The Line Charts</strong></p><p>We need to show the trend of cases. For this we will need a Time variable, here, the Date reported can do that task.</p><p>We need to make sure that the data type of date is actually a Date and not a String or Number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*JuvXli8HzlQS5xX6W4Pa0A.png" /><figcaption>Changing data types</figcaption></figure><ul><li>Drag Date reported to Columns section</li><li>Drag New Cases to Rows section</li><li>Convert Date from Year to <strong>Month</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*3HGKE84H3jROX4uo9vt-uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptxl2ab7GPcagrPozcnDcw.png" /><figcaption>First-line chart</figcaption></figure><p>The formatting is optional and similar to the one done for the map.</p><p>To change the color of the line,</p><ul><li>Select <strong>Color</strong> &gt;&gt; <strong>Edit Colors</strong></li><li>If the desired color is not present in the drop-downs, <strong>double click</strong> on the color in the left panel, and a new window will appear where we can formulate a new color or just add the new hex code for the color entirely</li></ul><p>Let’s add the number of deaths as well and observe the trends. To see both the graphs in a single chart;</p><ul><li>From the drop-down menu of SUM(New Deaths), select <strong>Dual Axis</strong>, to view both the charts on the single axis</li><li>Right-click on the y-axis and select <strong>Synchronize Axis</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wH4fl_MCPliolQnokjpueg.png" /><figcaption>Dual Axis</figcaption></figure><p>The following chart discloses the fact that there is a tremendous difference between the numbers of cases and deaths. The deaths are in thousands, whereas; the cases are in millions. Therefore, we prefer to assign different charts (or different sheets) to both the trends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYkG_62aHWX0krss95vQdg.png" /><figcaption>Synchronized axis</figcaption></figure><p>Similarly, a line chart for the number of deaths can be configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xf3cEmTIGWRMce2NwRRoA.png" /><figcaption>Number of deaths over time</figcaption></figure><p>To rename the axis:</p><ul><li>Double click the axis</li><li>Rename the title</li></ul><p>To remove the grid and axis lines:</p><ul><li><strong>Right-click</strong> on the chart</li><li>Select <strong>Format</strong> &gt;&gt; <strong>Format Lines</strong></li><li>Turn the desired lines on or off</li></ul><p>You have now completed a small portion of the target dashboard. The next step is to add scorecards and more charts, followed by formatting those charts, adding actions, and making an attractive layout in Figma.</p><p><strong>Links for datasets:</strong></p><ul><li><a href="https://github.com/owid/covid-19-data/tree/master/public/data">https://github.com/owid/covid-19-data/tree/master/public/data</a></li><li><a href="https://covid19.who.int/WHO-COVID-19-global-data.csv">https://covid19.who.int/WHO-COVID-19-global-data.csv</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2182499a48df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/creating-modern-dashboards-in-tableau-2182499a48df">Creating modern dashboards in Tableau</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django with NoSQL database]]></title>
            <link>https://medium.com/guidona-softpedia/django-with-nosql-database-5351de91d5fd?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/5351de91d5fd</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[pymongo]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[djongo]]></category>
            <dc:creator><![CDATA[Akanksha Parmar]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 19:35:18 GMT</pubDate>
            <atom:updated>2021-06-10T19:35:18.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GY6Ypb5U_zLhoI383LjGcw.png" /></figure><h3><strong>What is NoSQL?</strong></h3><p>A NoSQL generally means that it is a non-relational, distributed, flexible and scalable database. It is an approach to database management that can accommodate a wide variety of data models, including key-value, document, columnar, and graph formats. Additional common NoSQL database features include the lack of a database schema, data clustering, replication support, and eventual consistency, as opposed to the typical ACID (atomicity, consistency, isolation, and durability) transaction consistency of relational and SQL databases.</p><p>NoSQL has become the industry norm for handling data for analyzing, real-time applications, and storage due to its flexibility and scalability over a SQL database. One such popular database is MongoDB.</p><p>NoSQL databases are not officially supported by Django itself. There are, however, several side projects and forks which allow NoSQL functionality in Django. Here is a quick guide on how we can use <strong><em>Djongo</em></strong> to connect Django and MongoDB with just a few changes in the configuration file.</p><h3><strong>What is Djongo?</strong></h3><p>Djongo is a SQL to MongoDB query transpiler. It allows us to use MongoDB as a backend database for our Django project without changing any other modules.</p><p>Djongo is a smarter approach to database querying. It is an extension of the traditional <a href="https://www.djangoproject.com/">Django ORM</a> framework. It maps python objects to MongoDB documents, a technique popularly referred to as Object Document Mapping or ODM.</p><blockquote><strong>Requirements</strong></blockquote><ol><li>Python 3.6 or higher.</li><li>MongoDB 3.4 or higher. (If you are using nested queries then MongoDB 3.6 or higher is required.)</li></ol><blockquote><strong>Installation</strong></blockquote><pre>pip install djongo</pre><p>In the settings.py file of your project, add:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C74%252C74%252C1%2529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D15.5px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DDATABASES%252520%25253D%252520%25257B%25250A%252520%252520%2527default%2527%25253A%252520%25257B%25250A%252520%252520%252520%252520%2527ENGINE%2527%25253A%252520%2527djongo%2527%25252C%25250A%252520%252520%252520%252520%2527NAME%2527%25253A%252520%2527your-db-name%2527%25252C%25250A%252520%252520%25257D%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C74%25252C74%25252C1%252529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D15.5px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DDATABASES%25252520%2525253D%25252520%2525257B%2525250A%25252520%25252520%252527default%252527%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%252527ENGINE%252527%2525253A%25252520%252527djongo%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%252527NAME%252527%2525253A%25252520%252527your-db-name%252527%2525252C%2525250A%25252520%25252520%2525257D%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1845425b1ec63d57d0115819c639a80/href">https://medium.com/media/b1845425b1ec63d57d0115819c639a80/href</a></iframe><p>In case you are using a hosted MongoDB cluster then,</p><blockquote>Install dnspython</blockquote><pre>pip install dnspython</pre><p>add the following in settings.py:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C74%252C74%252C1%2529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14.5px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DDATABASES%252520%25253D%252520%25257B%25250A%252520%252520%252520%252520%252520%2527default%2527%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%2527ENGINE%2527%25253A%252520%2527djongo%2527%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252522CLIENT%252522%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2527name%2527%25253A%252520%2527%25253Cdb-name%25253E%2527%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2527host%2527%252520%25253A%252520%2527%25253Chost-name%252520or%252520ip%252520address%25253E%2527%25252C%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2527username%2527%25253A%252520%2527%25253Cdb-username%25253E%2527%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2527password%2527%252520%25253A%252520%2527%25253Cpassword%25253E%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%25257D%25250A%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C74%25252C74%25252C1%252529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14.5px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DDATABASES%25252520%2525253D%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%252527default%252527%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527ENGINE%252527%2525253A%25252520%252527djongo%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252522CLIENT%25252522%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527name%252527%2525253A%25252520%252527%2525253Cdb-name%2525253E%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527host%252527%25252520%2525253A%25252520%252527%2525253Chost-name%25252520or%25252520ip%25252520address%2525253E%252527%2525252C%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527username%252527%2525253A%25252520%252527%2525253Cdb-username%2525253E%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527password%252527%25252520%2525253A%25252520%252527%2525253Cpassword%2525253E%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/976a170b280b89b40bf9d6572213dbda/href">https://medium.com/media/976a170b280b89b40bf9d6572213dbda/href</a></iframe><p>Run the following commands to generate schema of the MongoDB database</p><pre>python manage.py makemigrations</pre><p>The above command scans and creates a new migration file</p><pre>python manage.py migrate</pre><p>The initial migration file for Django Tastypie can be migrated using the ‘migrate’ command. This creates __schema__ in MongoDB collection for all the default Tastypie models.</p><p>Django migrations schemas are automatically created when the command to migrate the model is executed.</p><p>That’s it! Our database setup is done and we are ready to use MongoDB as a backend database for our Django project, we can now create database models in models.py files of our project apps and then use commands makemigrations and migrate to create migrations and apply those migrations.</p><p>Based on what Django wants to do in SQL, Djongo creates equivalent MongoDB statements that result in creating a collection instead of a table.</p><p>For example, let us create a model named Person with first_name and last_name as its fields.</p><p>add the following code to models.py</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C74%252C74%252C1%2529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%252520django.db%252520import%252520models%25250A%25250A%252523%252520Create%252520your%252520models%252520here.%25250A%25250Aclass%252520Person%2528models.Model%2529%25253A%25250A%25250A%252520%252520%252520%252520first_name%252520%25253D%252520models.CharField%2528max_length%25253D30%2529%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25250A%252520%252520%252520%252520last_name%252520%25253D%252520models.CharField%2528max_length%25253D30%2529%25250A%252520%252520%252520%252520%25250A%252520%252520%252520%252520%25250A%252520%252520%252520%252520%25250A%252520%252520%252520%252520%25250A%252520%252520%252520%252520&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C74%25252C74%25252C1%252529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%25252520django.db%25252520import%25252520models%2525250A%2525250A%25252523%25252520Create%25252520your%25252520models%25252520here.%2525250A%2525250Aclass%25252520Person%252528models.Model%252529%2525253A%2525250A%2525250A%25252520%25252520%25252520%25252520first_name%25252520%2525253D%25252520models.CharField%252528max_length%2525253D30%252529%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520last_name%25252520%2525253D%25252520models.CharField%252528max_length%2525253D30%252529%2525250A%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/895aefb9edb2d6d4041ecbce42064324/href">https://medium.com/media/895aefb9edb2d6d4041ecbce42064324/href</a></iframe><p>In MongoDB, there is no concept of columns since MongoDB is schema-less and does not contain tables. It contains the concept of collections and a collection has different types of documents to store items. The above code will create a collection named Person with fields first_name and last_name.</p><p>Register this model in admin.py</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C74%252C74%252C1%2529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%252520django.contrib%252520import%252520admin%25250A%25250Afrom%252520.models%252520import%252520Person%25250A%25250A%25250A%252523%252520Register%252520your%252520models%252520here.%25250A%25250Aadmin.site.register%2528Person%2529%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25250A%25250A%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C74%25252C74%25252C1%252529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%25252520django.contrib%25252520import%25252520admin%2525250A%2525250Afrom%25252520.models%25252520import%25252520Person%2525250A%2525250A%2525250A%25252523%25252520Register%25252520your%25252520models%25252520here.%2525250A%2525250Aadmin.site.register%252528Person%252529%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525250A%2525250A%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/67e6e7318fc19f8a0c7b307f50b2fac7/href">https://medium.com/media/67e6e7318fc19f8a0c7b307f50b2fac7/href</a></iframe><p>Add some values to our Collection using the following code in views.py:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C74%252C74%252C1%2529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%252520django.shortcuts%252520import%252520render%25250Afrom%252520django.http%252520import%252520HttpResponse%25250Afrom%252520.models%252520import%252520Person%25250A%25250A%25250A%252523%252520Create%252520your%252520views%252520here.%25250A%25250Adef%252520home%2528request%2529%25253A%25250A%252520%252520%25250A%252520%252520%252520%252520p%252520%25253D%252520Person%2528first_name%25253D%252522Akanksha%252522%25252C%252520last_name%25253D%252522Parmar%252522%2529%25250A%252520%252520%252520%252520p.save%2528%2529%25250A%252520%252520%252520%252520return%252520HttpResponse%2528%252522Welcome%2521%252522%2529%25250A%252520%252520%25250A%252520%252520&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C74%25252C74%25252C1%252529%26t%3Dvscode%26wt%3Dsharp%26l%3Dauto%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D12px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D0px%26ph%3D0px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D13.5px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%25252520django.shortcuts%25252520import%25252520render%2525250Afrom%25252520django.http%25252520import%25252520HttpResponse%2525250Afrom%25252520.models%25252520import%25252520Person%2525250A%2525250A%2525250A%25252523%25252520Create%25252520your%25252520views%25252520here.%2525250A%2525250Adef%25252520home%252528request%252529%2525253A%2525250A%25252520%25252520%2525250A%25252520%25252520%25252520%25252520p%25252520%2525253D%25252520Person%252528first_name%2525253D%25252522Akanksha%25252522%2525252C%25252520last_name%2525253D%25252522Parmar%25252522%252529%2525250A%25252520%25252520%25252520%25252520p.save%252528%252529%2525250A%25252520%25252520%25252520%25252520return%25252520HttpResponse%252528%25252522Welcome%252521%25252522%252529%2525250A%25252520%25252520%2525250A%25252520%25252520&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd140990c5c1dc1dc63455d95e2bc904/href">https://medium.com/media/dd140990c5c1dc1dc63455d95e2bc904/href</a></iframe><p>Run the following commands to migrate</p><pre>python manage.py makemigrations</pre><pre>python manage.py migrate</pre><p>Open MongoDB compass and connect to your database you will find a collection named Person with values that you’ve added to it as a document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vs4wujTy_PvJ1l7Zp5ZwAA.png" /></figure><p>The above image shows the documents of a collection.</p><p>In this blog, I’ve discussed how to connect a MongoDB database with your Django project using djongo and illustrated the same with the help of an example.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5351de91d5fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/django-with-nosql-database-5351de91d5fd">Django with NoSQL database</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conversational AI]]></title>
            <link>https://medium.com/guidona-softpedia/conversational-ai-bea709a42a80?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/bea709a42a80</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[e-commerce-business]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[rasa]]></category>
            <dc:creator><![CDATA[Saurav Joshi]]></dc:creator>
            <pubDate>Sat, 06 Mar 2021 20:25:33 GMT</pubDate>
            <atom:updated>2021-03-06T20:25:33.901Z</atom:updated>
            <content:encoded><![CDATA[<p>Language across the globe is incredibly complex and hence pretty tough to interpret and understand. Humans can easily understand the semantics while computers cannot. Conversational AI’s are a step ahead of traditional Chatbot systems. Conversational AI is a technology that enables machines to naturally understand the input from humans and also interact with humans via language. It bridges the communication barrier between machines and humans and allows communication flow to be easier and more natural. It has the ability to decipher multiple languages and comprehend what is being said by the user, based on the intent performs a particular task and then based on the task carries the communication forward to get the minute details about it so that the task can be performed more efficiently and accurately.</p><h3>Conversational AI Simplistic Example</h3><p>Talking about conversations, it happens almost in every field and hence every industry nowadays requires a 24x7 available system which would satisfy the customer’s requirement. Conversational AI has developed a great interest in the industry and is available everywhere. Let us consider a simplistic example to understand why it is so important. Consider a Conversation AI bot situated on an E-commerce application receiving a lot of traffic every day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*TFFRU8JWndBrqTL4soH_FQ.png" /></figure><p>If humans were solving millions of queries each day then not only it would increase the cost of the company by hiring many employees but also would be hectic for the employees to navigate so many customers to the desired location. Hence, a well-trained Conversation AI comes into the picture solving these above disadvantages. It not only handles so many queries but also provides many advantages one of them being 24x7 availability.</p><p>Here we will look at a simplistic demonstration of an E-commerce Chatbot whose resultant conversation image is seen above using RASA which is an Open Source machine learning framework to automate text- and voice-based assistants.</p><p>The conversation flow will be somewhat like this. The Conversational AI will greet the customer. The customer will search for a product by asking the assistant to show him/her some products. The AI will respond with the best result of the search and that is how the conversation will flow. Let&#39;s look at the code one file at a time.</p><h4>NLU.yml</h4><p>This file basically consists of all the possible intents in the data and its examples. Examples are mainly used to train the data concerning the intent. So for example here: Greet intent is trained with all possible examples like hi, hello, etc. Similarly, Search Product intent is trained with examples such as I am looking for a dress, etc. The more the number of examples the better the Conversational AI will be.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/878d3b43b8c4465aa1d44dc29da484e5/href">https://medium.com/media/878d3b43b8c4465aa1d44dc29da484e5/href</a></iframe><h4>Domain.yml</h4><p>The Domain defines the Universe in which the assistant operates. It consists of everything — intents, entities, slots, actions, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6f503c68a16e052eae23cc75ba5b0fe/href">https://medium.com/media/c6f503c68a16e052eae23cc75ba5b0fe/href</a></iframe><h4>Stories.yml</h4><p>Stories in Rasa are used to build a dialogue management model which is mainly handled by Rasa Core. It consists of many stories and each story is made up of a sequence of intents and actions. When a particular intent is matched, the respective action from the domain.yml file is called.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efc0abdface93256535c1062b757c7f2/href">https://medium.com/media/efc0abdface93256535c1062b757c7f2/href</a></iframe><p>Here the resultant conversation is seen using rasa x. As seen in the initial output image, although the customer did not enter the exact query as what was mentioned in the nlu.yml to train the assistant, the customer entered — ‘I am searching for a dress’, the assistant was able to classify the intent correctly. Hence, because of Natural language understanding, Machine Learning, and Natural language processing techniques, it can understand human language correctly.</p><p>The code for the particular Conversation AI in E-commerce application can be found here at this Github repository: <a href="https://github.com/sauravjoshi23/Medium/tree/master/E-Commerce-Chatbot">https://github.com/sauravjoshi23/Medium/tree/master/E-Commerce-Chatbot</a></p><h3>Traditional Chatbot vs Conversational AI</h3><h4>Traditional Chatbots</h4><p>Chatbots are rule-based, domain restricted, well-bounded, simple, and inefficient chat systems. It has well-defined categories from which interactions happen with humans. A well-defined or linear communication flow is followed. So for example, if there are 4 problems namely A, B, C, and D so the chatbot will respond only when the user refers to those problems. Any sort of problem out of those categories will not have a meaningful answer. These chatbots are inefficient because they will only answer in an if-else manner as they rule-based and secondly, they don&#39;t have the ability to learn while the conversation is taking place.</p><p>Some of the characteristics of Old Traditional Chatbots located in any industry are:</p><ul><li>It provides a 24x7 support facility.</li><li>It follows key-word based communication flow.</li><li>Button-focused Interface.</li><li>No ability to learn while the communication is in place.</li><li>Navigation-focused property.</li></ul><h4>Conversational AI</h4><p>Conversational AI uses Natural Language Processing, Natural Language Understanding, and Machine Learning to handle the human variance in communication between humans and machines. It mainly focuses on a dialogue flow system which is far better than the rule-based system of the traditional chatbots. This technology remembers personalities and old conversations to continue the flow and give a better experience to the user. It can be used to build both text and voice-based assistants. It interprets the context of every conversation and also makes use of automation capabilities to bridge the process gaps.</p><p>Some of the characteristics of Conversational AI’s located in any industry are:</p><ul><li>It provides a 24x7 availability.</li><li>It is multilingual.</li><li>It provides user authentic support facility.</li><li>Pre-trained with multiple previous user intents.</li><li>Ability to learn while the communication is taking place.</li></ul><h3>Components of Conversational AI</h3><p>Conversational AI has 3 main functional components and 2 interactive components. Let us talk about each of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTbjC2CU-Ole36-287IOiw.png" /><figcaption>Natural Language Processing</figcaption></figure><ol><li><strong>User/Customer:</strong> This entity will interact with the frontend of the webpage where the Conversational AI is deployed. Related to a specific organization, the user can generate a query to be fed to the conversational AI to start a dialogue.</li><li><strong>Natural Language Understanding:</strong> Natural Language Understanding (NLU) is a branch of Natural Language Processing (NLP) that assists machines to comprehend the human language by breaking down important elements of speech. It decodes user’s words regardless of how it has been stated as input. Even if there are grammatical mistakes or shortcuts present in the input data, AI will be able to understand the user’s intent.</li><li><strong>Machine Learning:</strong> Machine Learning helps to determine the correct response or category depending on the fetched user’s intent from the previous component. The accuracy varies depending upon the type of machine learning algorithm used to process the data. It also has the ability to learn from past data for better outcomes or accuracy.</li><li><strong>Natural Language Generation: </strong>Natural Language Generation (NLG) is a branch of Natural Language Processing (NLP) that generates outputs or responses to incoming intents fetched by the Natural Language Understanding component.</li><li><strong>Chatbot System:</strong> This is an interactive and responsive component as it displays the output produced by the previous components on the web interface which is seen by the user/customer.</li></ol><h3>Conversational AI for All</h3><p>Conversational AI has many advantages for <strong>all </strong>the users. Let us look at them and how they benefit from them.</p><h4>Customers</h4><p>Customer Engagement is one of the most important properties of Conversational AI in any industry. The main aim of it is not only to provide the information that is asked for but also to provide a seamless interaction or communication between the AI and the customer. Continuing communication is also an additional property that Conversation AI provides for existing users where the conversation starts from where it was ended last time to give customers a better and a rich experience. With this advanced technology, customers hereby don’t need to search for results themselves, they can just start a conversation with the Conversational AI and finally, it leads the customer to its goal in a couple of steps. It can help the customer find specific information, customize settings, search options, and many more.</p><h4>Employees</h4><p>Employees in the field of IT, HR’s, Civil, etc can benefit from Conversation AI. Any simple IT-related queries can be attended by a trained AI rather than the professional itself which helps him work on a more important and hard task. Similarly, HR people can set up or train their AI in such a way to carry out a basic HR round with an ability to save the information given by the user which then could be referred when the professional has time. In the civil industry, as the language is quite complex for a normal person to understand, the AI can easily direct the customer to its goal instead of a professional manually guiding the customer via different communication help.</p><h4><strong>Industry</strong></h4><p>For any industry as a whole, Conversational AI can help set up or increase the demand of the industry. It can increase sales, productivity rate, and customer interaction rate. It can save time for its employees and also reduce the overall cost of the company as Conversational AI’s would work on a specific task and the employees on some another. It could benefit by providing a frictionless platform by smartly recommending customers with new products and timely offers. As these provide 24x7 facilities and are active throughout the day, they can reach new customers from any timezone.</p><h3>Conclusion</h3><p>Conversational AI has many advantages over traditional old tech chatbots. Nowadays most companies prefer to have Conversational AI’s on their website as they provide more flexibility, scalability, and higher productivity. We saw a simplistic conversational AI in the E-commerce field as to how easy it can classify the intent of the customer and provide the customer with the best result. We also saw the importance of Natural Language Processing to build such Conversational AI’s. Lastly, we saw how Conversational AI benefits the entire industry, not only the customers, employees but also the industry as a whole.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bea709a42a80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/conversational-ai-bea709a42a80">Conversational AI</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ajaxify in Django From Multiple Endpoints]]></title>
            <link>https://medium.com/guidona-softpedia/ajaxify-in-django-from-multiple-endpoints-730a0d71bcb5?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/730a0d71bcb5</guid>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Saurav Joshi]]></dc:creator>
            <pubDate>Fri, 19 Feb 2021 07:57:27 GMT</pubDate>
            <atom:updated>2021-02-19T07:57:27.835Z</atom:updated>
            <content:encoded><![CDATA[<p>Often in Django, there is a requirement of GETting or POSTing data from multiple endpoints on the main page of the website. AJAX stands for <strong>A</strong>synchronous <strong>J</strong>avaScript <strong>A</strong>nd <strong>X</strong>ML. It basically assists us in communicating with the server. It sends and receives information in multiple formats such as JSON, XML, HTML, etc. Websites that do not use AJAX, when they communicate with servers normally have to refresh the page in order for the changes to be reflected not the page. On the contrary, websites that use AJAX, allow webpages to be updated asynchronously by exchanging data from servers and even reflecting those changes without the page being reloaded.</p><p>In this article, the focus is mainly on the implementation side. The 2 endpoints will specifically do the following task respectively :</p><ul><li>Form submission message from the endpoint 1</li><li>Normal Message from the endpoint 2</li></ul><h3>Description of the Application</h3><p>The application on which the demonstration is done is actually a form-based webpage. The form asks for the first name and the last name of the user. It also has a submit button that submits the information. The frontend or the UI is not considered much as the main goal is to focus on how such a process happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FvEpEDHJ02liMv66Zl3m5A.png" /></figure><p>So here, as soon as the user fills in the required information and submits the form, 2 messages are displayed, one saying “<strong>Message from Point 1: Form has been successfully submitted”</strong> and the other saying “<strong>Message from Point 2: “</strong>+firstname+<strong>” “</strong>+lastname+<strong>” you have successfully submitted the form!!!” </strong>where ‘firstname’ and ‘lastname’ is the information of the user that he/she entered. This particular information is stored and then passed to the function which communicates with the 2nd endpoint.</p><p>Before we start the implementation, the reader must be quite familiar with Python, Django, basics of Javascript and HTML.</p><h3>Implementation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*lx-CV1wnyPypnZRQL6YQcg.png" /></figure><p>The image here is the project tree as to how the files are arranged just to get an idea about the project. The templates directory in the mainapp contains the index.html file which the HTML file which gets rendered on the webpage. The index.js file inside the static/js directory is used for the AJAX setup. Apart from these, there few more important files namely: views.py which takes request return a response, and urls.py which is used for URL mapping. We will only understand and look at these important files.</p><h4>Index.html</h4><p>The focus is mainly on the body tag which kind of displays the entire data on the webpage. Here, a form is made with 2 input tags and a submit button. Output1 and Output2 are divisions basically to render the message from the 2 endpoints. Here {% csrf_token %} is used for CSRF token handling. The <strong>CSRF token</strong> only ensures that only forms that have originated from trusted domains can be used to POST the data back. Finally, the index.js is defined inside the script tag for client-side scripting.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e792c331f01b6d9ea3f958dc5fc83333/href">https://medium.com/media/e792c331f01b6d9ea3f958dc5fc83333/href</a></iframe><h4>Urls.py</h4><ul><li>The first URL mapping is used for the index view function which ultimately renders the HTML page on the respective URL map.</li><li>The second URL mapping is used for the form_ajax view function which helps in sending and receiving data from the form submission to the webpage.</li><li>The third URL mapping is used for the message_ajax view function which helps in sending and receiving data to the webpage.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3ea293a6d2e1e9b7449845394f8d915/href">https://medium.com/media/b3ea293a6d2e1e9b7449845394f8d915/href</a></iframe><h4>Views.py</h4><ul><li>Index function renders the Index.html on the webpage.</li><li>Form_ajax function receives a POST request from the form submission. It fetches the first name and the last name. If both are not null, then as a success a JSON response containing the message, first name, and last name is sent back so that the same data could be sent to the function(inside index.js) which further communicates with the endpoint 2.</li><li>Message_ajax function receives a POST request from the javascript function written on the index.js file. It fetches the first name and the last name. As a success, an HTTP response containing the message is sent back.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a90bcdc2dc18be7bbe0240830e31b0ea/href">https://medium.com/media/a90bcdc2dc18be7bbe0240830e31b0ea/href</a></iframe><h4>Index.js</h4><ul><li>On Form Submission, a POST request is made with JSON data containing first name, last name, csrfmiddlewaretoken, and the data type value. Here, the endpoint1 is referenced as form_ajax URL. As we discussed earlier, in return we receive success or error messages. If it was a success, we output the received data on the webpage and finally call the ‘message_ajax’ function of index.js which communicates with the 2nd endpoint. Else we receive an error which can then be printed in the console.</li><li>The data received is then used to communicate with the 2nd endpoint. Here, the endpoint1 is referenced as message_ajax URL. Similarly, here the data sent as a POST request contains first name, last name, csrfmiddlewaretoken, and the data type value. The output received is then rendered on the webpage else the error is printed in the console.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/774f7155bd4bf666ffc7b1c9971ba54b/href">https://medium.com/media/774f7155bd4bf666ffc7b1c9971ba54b/href</a></iframe><h3>Output</h3><p>Here as we can see on submission we get 2 messages, one from each endpoint without refreshing the webpage. Message 1 from endpoint 1 indicating the form has been successfully submitted and a message from endpoint 2 indicating that the username has successfully submitted the form. The second endpoint was just for the demonstration purpose and does not hold any significant value on the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fL5Pxv2ZfWMlZL6ogl_jKQ.png" /></figure><h3>Conclusion</h3><p>The main goal of the article was to communicate with multiple endpoints on a single webpage in Django. In my case, I have chosen 2 endpoints just for demonstration purpose but there can be many depending upon the application which is being built. AJAX was the key behind such a use case which helps us solve the problem. This particular application with such use can help save a lot of time as the page does not refresh every time a request is made or when any sort of communication happens. The website as a whole also looks complete and amazing.</p><p>The entire project can be found out at this Github repository: <a href="https://github.com/sauravjoshi23/Medium/tree/master/AJAXify_In_Django_From_Multiple_EndPoints">https://github.com/sauravjoshi23/Medium/tree/master/AJAXify_In_Django_From_Multiple_EndPoints</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=730a0d71bcb5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/ajaxify-in-django-from-multiple-endpoints-730a0d71bcb5">Ajaxify in Django From Multiple Endpoints</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chatbots Value In Industry]]></title>
            <link>https://medium.com/guidona-softpedia/chatbots-value-in-industry-66450aa7c758?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/66450aa7c758</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[chatbot-development]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <dc:creator><![CDATA[Saurav Joshi]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 14:39:17 GMT</pubDate>
            <atom:updated>2021-02-11T14:39:17.585Z</atom:updated>
            <content:encoded><![CDATA[<p>The main goal of this article is to help readers understand everything about Chatbots and how they are evolving in the industry. These are the topics that will be specifically covered:</p><ul><li>The ultimate aim of a Chatbot</li><li>Use Cases of Chatbots in various Industries</li></ul><h3>The Ultimate Aim of a Chatbot</h3><p>Artificial Intelligence, Natural Language Processing, and Natural Language Understanding have evolved a lot in recent times. Along with them, their applications also have made a lot of noise. One of the applications is Chatbot. A chatbot is basically a software application that understands and processes human language and guides the human to a specific target with minimal effort. The ultimate aim of the chatbot is to support and upscale businesses, reduce the amount of effort the customer has to put in to satisfy his requirements as the Chabot is always one step away from providing service and also available 24x7 in any field or industry whatsoever. Faster replies, accurate customer service is provided to the customer from chatbots. From the company point of view, chatbots help them to increase conversion rates, lowering support costs, and mainly accelerating the sales cycle.</p><h3>Use Cases of Chatbots in various Industries</h3><p>Now let us see how the use of Chatbots has positively affected the Industry revolution.</p><h4>Healthcare Industry</h4><p>Chatbots have not only assisted the patients but also helped the doctors and other assistants as well. Let us consider some use cases where it is helpful.</p><ul><li>A chatbot can help patients <strong>schedule appointments</strong> within a couple of minutes. The patient can add all the necessary details like symptoms, scheduled time, personal details, etc via a form attribute assisted by the chatbot so that the doctor is already informed about the patient&#39;s query and hence a lot of time is saved.</li><li>A chatbot can also work as a <strong>health tracker</strong> for patients. It can manage the patient&#39;s daily routine given to it as an input from the doctor like is the patient taking the medicines on time? Is the patient drinking hot water? etc. So here the doctor necessarily does not have to keep track of the daily activity of the patient rather it can solve other patient&#39;s problems as well.</li><li>Nowadays, bots are made for patients to help <strong>detect symptoms</strong>. From the input provided by the user about a specific disease, the bot can process the information, understand it, and finally help narrow down the cause behind such disease. It can also then suggest the patient&#39;s potential treatment plan to help cure the disease.</li></ul><h4>Legal Industry</h4><p>Not every person is well acquainted with all the rules proposed in the legal industry hence a Chatbot really makes the job easier for many people. Let us consider some use cases where it is helpful.</p><ul><li>Various real-world case studies, the relevant contact information of various lawyers, laws, and policies of different departments, states, and countries can be known through a chatbot with just a click. Normally we would have to search above mentioned information on the web or various other tagged sources but now it is possible through chatbots which make the task a lot easier. In a nutshell, it can easily assist in <strong>acquiring and managing information.</strong></li><li>Legal Chatbots <strong>save time and money</strong>. From a survey, most of the customers in the legal industry choose their lawyers if they answer their first call or email. Chatbots can carry out the initial consultation with the customer at any given point of time with accurate legal information as it is available 24x7.</li><li>Legal Chatbots can easily <strong>generate legal documents</strong>. With a few basic questions answered related to a particular field, it can manage the information gathered and generate a document, report, or a legal brief within minutes. It does not only save the time and effort of the customer but also enhances the reach of the firm.</li><li>One of the most time-consuming tasks that lawyers perform is conducting due diligence. <strong>Legal due diligence</strong> is the process of collecting, understanding, and assessing all the legal risks associated. Hence, chatbots here automate and speed up the process and gives the lawyers more time to work on some other task. It basically reviews a ton of documents and creates a full report for the same.</li></ul><h4><strong>Banking Industry</strong></h4><p>Banking and financial channels are quite complex to understand for a normal user. A normal employee cannot chart a single customer roadmap down as there are multiple customers hitting the site everyday and hence a less complex way is required to complete a lot of similar tasks like this. Let us consider some use cases where it is helpful.</p><ul><li>Banking Chatbots can assist their customers with <strong>Financial Advice</strong>. Such chatbots have the access to customer&#39;s financial data and so with all the spending and earnings, they can set and manage plans beneficial for the customer. It is all possible with advanced machine learning and deep learning algorithms.</li><li>From the company&#39;s point of view, chatbots can help <strong>save costs</strong>. First of all, chatbots are relatively cheaper to create and manage compared to a human equivalent. Compared to other applications it is also easy to develop with relatively less code but definitely, it needs intelligent people to work on it. Secondly, if there are no chatbots, then humans would have to answer every request manually 24x7 which is also not a feasible solution.</li><li>Traditional banking applications are quite complex to understand. Whereas Chatbots on the other hand are relatively <strong>easier to converse</strong> with as it seems we are having a conversation with a human itself. The experience can also improve as and when more and more conversations take place between the customer and the bot.</li></ul><h4>Education Industry</h4><p>Nowadays, chatbots are playing an important role in the education industry as they help not only the teachers but also the students by acting as virtual assistants. Let us consider some use cases where it is helpful.</p><ul><li>Educational Chatbots act as virtual assistants and provide <strong>enhanced student engagement</strong>. As students are very much familiar with social networking sites and how conversation happens over there, similarly these chatbots bring the same kind of experience for the student so that they do not feel different and can surely understand topics quite comfortably.</li><li><strong>Feedback forms </strong>are an important part of any educational institution as they need to know the progress of each student and their opinions about the teaching of a teacher and so on. Chatbots can provide easy assistance in filling these feedback forms and answering any such related queries. This feedbacks if recorded manually may not be secure but with the help of technology, any data recorded via chatbots is always secure.</li><li>Educational Chatbots provide <strong>management assistance</strong> to the students. Whether it be school going students or college going students, each of them has a lot of work to do, hence they are not able to properly and efficiently manage their work and eventually are not able to submit the work on time. Chatbots using various machine learning and deep learning algorithms can recommend student the best possible plan he/she should follow in order to submit the work on time.</li><li>Educational Chatbots present on the main site can <strong>guide </strong>the parents as well as other students to the target they are looking for. Easy and an interactive roadmap is shown via a chatbot in order to assist the customer. The queries are understood by the chatbot so that it can show and display accurate results to the customers.</li></ul><h4>E-Commerce Industry</h4><p>The benefits of Chatbots in this industry are many. Let us consider some use cases where it is helpful.</p><ul><li>E-Commerce Chatbots provide <strong>24x7 customer support</strong>. The customer might be in any corner of the world, the requirements can arise at any moment of time hence customer support needs to be available throughout the day. This not only satisfies the customer’s need but also makes them happy.</li><li>E-Commerce Chatbots provide <strong>product recommendations</strong>. Some of the chatbots from the customer’s purchase history can recommend them newer and better-related products. Some chatbots collect data about style, fashion, etc, in real-time and then recommend them with related products.</li><li>A new user to a specific e-commerce store that he/she has not previously visited or known about can be <strong>guided </strong>by a chatbot. The interaction can help him/her to know more about the store and in a way increase the reach of the company and also makes the customer more comfortable.</li></ul><h3>Conclusion</h3><p>Chatbots are evolving day by day as it is a direct link between the industry and the users. We saw that almost every industry uses Chatbots to its maximum potential whether it be Healthcare Industry, Legal Industry, Banking Industry, Education Industry, E-Commerce Industry, and many more. The good part is that they are not only beneficial to the industry but also to the customers who use the products provided by these industries. All in all, Chatbots are a great addition to the industry and everyone needs to know their value.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66450aa7c758" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/chatbots-value-in-industry-66450aa7c758">Chatbots Value In Industry</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</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 Stock?]]></title>
            <link>https://medium.com/guidona-softpedia/what-is-stock-9e98b6945bac?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/9e98b6945bac</guid>
            <category><![CDATA[stocks]]></category>
            <category><![CDATA[mutual-funds]]></category>
            <category><![CDATA[stock-market]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[investing]]></category>
            <dc:creator><![CDATA[Yashika Balani]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 16:39:36 GMT</pubDate>
            <atom:updated>2021-02-10T16:39:36.497Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MBOJ0YQr_Wni8zTwVQRdjg.jpeg" /></figure><p>Before beginning with the formal and recognized definitions of Stock and the Stock Market, it is better to first understand the base and the concept that it is built upon. As leaners say, it is always better to add your personal touch to knowledge while learning, which leads me to tell you about one of my memories when I had to unwillingly giveaway my favorite chocolates because duh- I have siblings!</p><p>I had three chocolates of two brands each, namely, Dairy Milk and KitKat and I was asked to share it with two of my siblings. But that is simply not how sibling relationship works. I only agreed to give them the chocolates after they offered me the pastries that I liked in exchange. After a long discussion, all three of us had two chocolates each i.e. I had one bar of Dairy Milk and one bar of KitKat, just like my siblings plus the pastries.</p><p>However, the fair chocolate distribution is not the important point here. Our focus should be on the fact that I divided what was mine into three equal parts and gave away my ownership to my siblings in exchange for something. That leads us to the most basic element of Stocks which is Ownership. Here, I am no less than a company which divides it’s Capital into parts and then give it away to the people for money that they need.</p><h3>What is Stock?</h3><p>Stock is the term used to describe the ownership of any company. It represents the part of the company that is owned by a shareholder. When we say that, I have 5% stocks of ABC Company, then it directly means that I own 5% of that Company. It is also referred to as Equity sometimes. Equity, in financial terms refers to the value which the company is liable to pay to its shareholders. Sometimes, it is mixed with Capital but it must be kept in mind that Capital is the amount of money which is invested to start or operate a business entity whereas Equity is a much wider concept.</p><p>For a clearer understanding of this theory, it is necessary to know the difference between the myths and realities that revolve around it.</p><h3>Solving the Myths</h3><p><strong>1. I can’t do the investment myself if I am not from a Commerce Background.</strong><br> <br> FALSE- Investment is about money and knowing the market. With a good knowledge of how things are by reading more about the market in newspapers or magazines, anyone can invest in the market without any worries. It is not important to have a commerce background to invest in shares. In recent times, Mutual Funds Investments are also a good way to invest your precious rupees.</p><p><strong>2. Stock Market is full of risks.</strong><br> <br> TRUE- One of the interesting things about the Stock Market is that it can lead to profits and losses within few nights. You never know what is going to happen and hence, preventive measures are very limited which leads to the market being full of risks. Before deciding for the investment, one must keep in mind that there is no profit without risk. Therefore, risks are the static feature of this market.</p><p><strong>3. Investments leads to immediate profits.</strong><br> <br> FALSE- Patience is required at every step of this market. An individual can’t expect one day returns. The return on the investment is very great in this market which is one of the reasons that people invest in it. It depends upon what type of company an individual invests in. For instance, Blue Chips companies are considered good for investing as they can lead to profits sooner than other companies. For the other ones, it may even take years to receive profit from your investment.</p><p><strong>4. Shares and Stocks are the exact same. </strong><br> <br> FALSE- Shares and Stocks are not the exact same at all. We can refer to the chocolate distribution at the start of the blog, There, the pack of all the chocolates and pastries I had at the end was my stock whereas one bar of Dairy Milk that I had can be called as my share. <br> In easy words, Stock is the word used to describe ownership of one or more companies while Share is used when we are talking about one particular company. These terms are sometimes use together and are similar but they do not mean the exact same thing.</p><p><strong>5. I need a huge amount of money to invest.</strong><br> <br> FALSE- Investors in the market even start with Rs.1,000 as per the rates of the shares at the respective time. You can surely gradually increase the amount of money that you invest but you don’t need heavy bills at the initial step.</p><h3>Stock Market</h3><p><em>The Stock market is the congregation or aggregation of buyers and sellers who deal with Stock.</em></p><p>To understand this concept more, we can imagine a scenario where you buy stock of Rs.10,000. We will assume that you invested the money at the start of month. However, due to some urgent reason you need Rs.8,000 at the end of the same month. For fulfilling your urgent financial requirements, you can also sell those shares to other Investors. For doing that, you will need a platform to find these buyers and that place is no other than the ‘Stock Market’. Now, it is reasonable to find other sources of finance but what if it is a huge amount? Selling stocks is one the bests choice for that.</p><p>This market is also sometimes called as <em>‘Share Market’</em>, <em>‘Stock Exchange’</em> or <em>‘Equity Market’.</em></p><h3>Types of Stocks</h3><p>To make it easier for Investors to play in the market, stocks are classified on six basis which are as follows-</p><p>1. Classification on the basis of Ownership.</p><p>2. Classification on the basis of Market Capitalization.</p><p>3. Classification on the basis of Dividend Payment.</p><p>4. Classification on the basis of Fundamentals.</p><p>5. Classification on the basis of Price Trends.</p><p>6. Classification on the basis of Risk.</p><p>These can be further explained as follows:</p><p><strong>A. Classification on the basis of Ownership.</strong></p><p>Here, Ownership refers to the criteria where the characteristics of the powers of the investors are highlighted. It is related with the amount of authority an Investor is supposed to get after buying the stock. It is further divided into three parts-</p><p><strong>1. Preferred Stock</strong><br> These are the shares which carry a yearly fixed dividend rate. The shares are not volatile at all. The risk is very less as the dividend is fixed. They neither have voting rights nor they have a share in the profits.</p><p><strong>2. Common Stock</strong><br> These are the shares which do not carry a yearly fixed dividend rate. These shares are highly volatile. The risk is high as no return is fixed. They get share in the profit as well as have voting rights when a decision for the company is made.</p><p><strong>3. Hybrid Stock</strong><br> These are the hybrid of both the above stocks. These are the Preferred shares which can be later converted into Common shares. Because of this, they are also known as ‘Convertible Preferred Shares’.</p><p><strong>B. Classification on the basis of Market Capitalization.</strong></p><p>Market Capitalization or Market Cap is the market value of a company’s outstanding shares. It is the value of company’s worth in the open market.</p><p><strong><em>Market Capitalization = Cost Per Share x Number of Shares Outstanding</em></strong></p><p>This category is further divided into three which are as follows-</p><p><strong>1. Large Cap</strong><br> It consists of the stock of the Blue Chip Companies. A Blue Chip is a recognized, experienced, well-established, and financially sound and reliable company. They have the Market Capitalization value of more than Rs.25,000 Crore. They offer high dividend to the Investors and are less volatile in nature.</p><p><strong>2. Mid Cap</strong><br> It consists of the companies which have the Market Capitalization value of more than Rs.5,000 Crore but less than Rs.25,000 Crore. They are constantly growing and are assumed to have good returns in future when seen on a long term basis.</p><p><strong>3. Small Cap</strong><br> It consists of the companies which have the Market Capitalization value of Rs.5,000 Crore. This generally covers the new businesses which may or may not grow in future. The investment is very risky as everything about these companies is very uncertain.</p><p><strong>C. Classification on the basis of Dividend Payment.</strong></p><p>Dividend is the amount that the shareholders receive out of the profits as the reward for the buying the company’s shares. On the basis of that, it is divided into two groups-</p><p><strong>1. Growth Stocks</strong><br> These are offered by the companies which are continuously focusing on the growth. They generally have a low profit margin since they invest all their profit that they earn again to record more growth. Because there is very less profit, so the dividend offered is less when compared to others. However, these companies are growing and hence, they yield higher returns in long term. <br> They carry high risks as they are still growing and the high return is just a probability.</p><p><strong>2. Income Stocks</strong><br> These are the companies which generally offer high rates of dividend out of its profit. The return is consistent and so, the risk involved is very less. However, these companies are not much focused on growing, so an increase in return is very rare. <br> One more interesting fact about these types of stock would be that there is no presence of tax payment on the dividend income of the investors which is one of the reasons that new investors prefer these stocks a lot.</p><p><strong>D. Classification on the basis of Fundamentals.</strong><br> On the basis of the fundamentals, the stocks are divided into two parts:</p><p><strong>1. Overvalued Stocks</strong><br> These are the stocks of which the prices are more than the Intrinsic value. Intrinsic value is the value of all the cash that can be taken out from a company and be given to the investors during the rest of its life. In case of Overvalued stocks, we can imagine a example where the company is selling shares at Rs.5,000 when it’s Intrinsic Value is only Rs.3,000. It is just like paying Rs.20 for a Rs.10 pen. We are paying extra and it isn’t even worth that much!<br>It is to be noted that these companies are generally Blue Chips. Hence, the dividend rate is constant and they have high profits which makes it attractive to invest in.</p><p><strong>2. Undervalued Stocks</strong><br> These are the stocks of which the prices are less than the Intrinsic value. <br>In case of Undervalued stocks, we can imagine an example where the company is selling shares at Rs.5,000 when it’s Intrinsic Value is Rs.8,000. It is just like paying Rs.10 for a Rs.20 pen. We are paying less and are in the light of benefit. <br>Investors are more attracted towards them because these companies are generally growing and can yield higher profits in future.</p><p><strong>E. Classification on the basis of Price Trends.</strong><br> Here, the word price refers to the price of the stock that we purchase. This classification is based on the price fluctuations of the stock. With this base, we can divide the stocks into two:</p><p><strong>1. Defensive Stocks</strong><br> These are the stocks which are not very much affected by the dynamic and everchanging environment. The prices of these stocks do not change much. These are preferred in the times where the economy is in poor condition. The companies related with Food and Beverages are one of best examples of this.</p><p><strong>2. Cyclical Stocks </strong><br> These are the stocks which are affected by the dynamic and everchanging environment. The prices of these stocks change as per the market. These are preferred in the times where the economy is in boom. The companies related with Automobiles are one of best examples of this.</p><p><strong>F. Classification on the basis of Risk.</strong></p><p>While entering the market, one must keep in mind that risks can never be avoided here. <br> <strong><em>More risks = More Profit</em></strong><br> On the basis of risks, there are two types of stocks:</p><p><strong>1. Blue Chip Stocks</strong><br> These are stocks of the Blue Chip Companies. The risk is very less when it comes to well established companies which have low liability and high profits. These are the safest investments in the market.</p><p><strong>2. Beta Stocks </strong><br> These are the stocks which are very volatile. They respond very quickly to the fluctuations of the market. For examples, If there is increase of 7% in the market, these stocks may increase or decrease by 7% as well. <br> The Beta value of ‘1’ is considered good. The companies which have this beta value respond to the market very quickly. It is very beneficial for the investors in case there is a good change in the market.</p><p>Investment in Stock Market is neither easy nor difficult. It carries a lot of risks along with lots of rewards which makes it even more exciting for the people who are willing to invest. To have a clear realization of how dynamic this market is, we can simply look at the example of <em>Ronald Wayne.</em> Ronald Wayne is the third co-founder of Apple. In 1976, he sold his 10% share of the company for Rs.57,600. Today, his 10% is equal to Rs.25,52,63,92,50,000.</p><p>Investment can yield high profits but only when it is done with a right mindset with the correct knowledge of the market and a lot of patience. Sometimes, these markets even lead to millions of losses which can’t be avoided but can be confined or decreased.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e98b6945bac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/what-is-stock-9e98b6945bac">What is Stock?</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Word Embeddings in NLP]]></title>
            <link>https://medium.com/guidona-softpedia/word-embeddings-in-nlp-c71b058bf094?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/c71b058bf094</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[guidona-softpedia]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Saurav Joshi]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 19:57:14 GMT</pubDate>
            <atom:updated>2021-02-04T19:57:14.579Z</atom:updated>
            <content:encoded><![CDATA[<p>In Natural Language Processing, we usually deal with textual data. We clean the data, apply various preprocessing techniques, and finally pass the processed data to the Machine learning or deep learning model for training purposes. The model doesn’t understand text data like a human rather it only understands numbers. When we read the word ‘cricket’, we relate that word with many other similar words such as game, bat, ball, etc instantly because our mind is trained with such data over the years. The machine or the model in this case starts from ground zero. Machines deal well with numerical data. The task of this numerical data at the end of the day is to capture the semantic meaning of the data provided. Word embeddings come into play here. Word Embeddings is a method of converting textual data into the numerical format. Word embeddings can either be downloaded if they are already trained on well-known data or they can also be created using various word embedding techniques if the data is quite domain-specific.</p><h3>Data and Model:</h3><p>For experimentation purposes, the data I have used is <strong><em>Twitter tweets</em></strong><em> data </em>taken from Kaggle. Let us take a look at the training data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*cT1YGAzgCgoVJwauqkT2BQ.png" /></figure><p>Training and testing shape:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*-0t9Ow18jq-PqifMATExnA.png" /></figure><p>For training purposes, I have used the first 1000 rows from the training data and hence the results below are certainly on that data itself.</p><p>As we know the tweets or rather any data has to be cleaned in order to perform modeling as it contains stopwords, punctuations, URLs, mentions, etc. Basically, data that will not help us in the classification task has to be removed. I have already performed text preprocessing on the data and I am sure you will do it as I am focusing more on the Word Embedding part. Now as the text is cleaned it has to be converted into a numerical format in order to be fed to the model.</p><p>The model used is XGBoost. XGBoost is a decision-tree-based ensemble Machine Learning algorithm that uses a gradient boosting framework. XGBoost is an implementation of gradient boosted decision trees designed for speed and performance.</p><h3>Word Embedding Techniques</h3><p>We will discuss three-word embedding techniques:</p><ul><li><strong>Count Vectorizer</strong></li><li><strong>TF-IDF Vectorizer</strong></li><li><strong>Word2Vec</strong></li></ul><p>Let’s discuss each word embedding techniques one by one.</p><h4>Count Vectorizer</h4><p>It is the most basic method of representation of words into vectors. It basically counts the occurrence of each word in a sentence. A 2-dimensional matrix is formed where the columns denote the unique words from all the sentences and the rows define the documents. Let us understand the concept in detail with a small example:</p><p>Consider a set of 2 sentences:</p><ul><li>Football is a very good game</li><li>Cricket is also good</li></ul><ol><li>First, it will form a bag of words that will contain all the unique words from the entire corpus of documents.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*OfIjY2f-WHtsNPKsQkzDsQ.png" /></figure><p>2. Then a vector of length 8 will be created consisting of zeros.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*4wPRC81s3l3v6Gj3LqMVUQ.png" /></figure><p>3. Next, we will iterate through all the documents, iterate through all the words in that document and count the frequency of each word and finally replace the zero in that vector of zeros by the frequency of that particular word in the position itself.</p><p>So for example: Considering document 1 — <em>Football is a very good game.</em></p><ul><li>Originally the vector associated with it is [0, 0, 0, 0, 0, 0, 0, 0]. We then iterate through the words in that document. When we consider the first word which is ‘Football’, we get:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*fK4x5rmfb7A1_5t90K8r3g.png" /></figure><ul><li>When we consider the next word which is ‘is’, we get:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*aGb9fFf_I2pDyNhCyxpRMg.png" /></figure><ul><li>So finally after all the iterations, for document 1 the vector we get is:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*WGT9MXDLRGDg0w4FFOMrmQ.png" /></figure><ul><li>Similarly, for document 2, the vector we get is:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*jVfEExlO4W4IK_LEW0mWyQ.png" /></figure><p>Now, let&#39;s see how the Count Vectorizer performs on the dataset. Before that let&#39;s understand the code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea012beb19ed491b37dfc7facd09d6dc/href">https://medium.com/media/ea012beb19ed491b37dfc7facd09d6dc/href</a></iframe><p>Here importantly, a Count Vectorizer object is created along with defining all the hyperparameters. After that, the parameters are fit on the model along with the data and the transformed result is returned. For calculating the f1 score, the data is split into training and validation data. Finally, the prediction is made and the f1 score is calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*CjiJI3iT8flnZzKse76qsA.png" /></figure><h4>TF-IDF Vectorizer</h4><p>TF-IDF stands for Term Frequency Inverse Document Frequency. It is similar to Count Vectorizer but the only difference being that it takes other documents into consideration when creating a word vector. Let us consider the same sample from above here as well. We see that the word <em>good </em>appears in both the sentences and has no significant topic in classifying the documents. Hence it should have a lower weight compared to words like <em>Cricket </em>and <em>Football</em>.</p><p>TF-IDF works by penalizing the common words by assigning them lower weights while giving importance to words that are rare in the entire corpus but appear in good numbers in few documents.</p><ul><li><strong>TF</strong> = (Number of times term t appears in a document)/(Number of terms in the document)</li><li><strong>IDF</strong> = log(N/n), where, N is the number of documents and n is the number of documents a term t has appeared in.</li><li><strong>TF-IDF</strong> = TF*IDF</li></ul><ol><li>Similar to Count Vectorizer a bag of words will be created.</li><li>For each document, an array of zeros will be created.</li><li>Then for each word in each document, the TF-IDF value will be calculated and the zero in the array will be replaced with the calculated value.</li></ol><p>So for example let&#39;s consider the word ‘Football’. The TF-IDF value for it will be —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*m57AarMkSE5BBcawkmiwmg.png" /></figure><p>Now, let&#39;s see how the TF-IDF Vectorizer performs on the dataset. Before that let&#39;s understand the code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8be3c91121f98e28838760536ad46ba/href">https://medium.com/media/e8be3c91121f98e28838760536ad46ba/href</a></iframe><p>Similar to the Count Vectorizer code, here TFIDF Vectorizer object is created and the rest is the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*TaMN_Nt5T0Z582-uS4uNEQ.png" /></figure><h4>Word2Vec</h4><p>These are very efficient in understanding the data provided to them. They help restore the semantic meaning of the sentences. It represents the words in a vector space and also similar words are located close to each other. Unlike other techniques, Word2Vec is highly appreciated in the community and is a very good area of research. As we know, it represents a word in a vector format in such a way that it is able to identify the relationships as well. It can understand as to what a <em>Woman </em>is to a <em>Man</em>, similarly what <em>Queen </em>is to a <em>King</em>.</p><p>CBOW and Skip-grams are the 2 categories of this class.</p><ol><li><strong>CBOW:</strong> It stands for Continuous bag of words.<strong> </strong>Here it takes a look at the surrounding words (say 1 to the left and 1 to the right) and predicts the word that comes in between.</li><li><strong>Skip-grams: </strong>Here it takes in a word and then tries to predict the surrounding words.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*Mb2irzAvNFTdSYlAnQE-yg.png" /><figcaption>Source: <a href="https://arxiv.org/pdf/1309.4168v1.pdf">Exploiting Similarities among Languages for Machine Translation</a></figcaption></figure><p><strong>CBOW:</strong></p><p>Considering the sample example from above, let us consider document 1 — ‘Football is a very […..] game’ here the task of CBOW is to predict the result for the missing word and it will tell us the most probable word suiting the context. It might predict good, bad, amazing, etc depending upon the data it is trained upon.</p><p>Now, let&#39;s see how the CBOW performs on the dataset. Before that let&#39;s understand the code.</p><p>Here, we are creating the word vector of all the words present in the documents in the corpus. While defining the parameters we are setting ‘sg’ to 0 as this enables the word2vec model to be used as a continuous bag of words model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/111df1f00af14755a32f7c0f29c556cb/href">https://medium.com/media/111df1f00af14755a32f7c0f29c556cb/href</a></iframe><p>Next, we need to convert word-level embeddings into sentence level embeddings so that the meaning of the sentence is not lost. This step is optional as it depends upon the type of dataset you are working on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/527eb3768108ebf0dd403bd783caa3f9/href">https://medium.com/media/527eb3768108ebf0dd403bd783caa3f9/href</a></iframe><p>Finally, we are training the model by passing the word embeddings produced at the sentence level by the previous step, and the f1- score is calculated.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b71ca1dff8d5a418efb8c07382d38337/href">https://medium.com/media/b71ca1dff8d5a418efb8c07382d38337/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*Ajqi8QdErB5cSg5zM78Ulw.png" /></figure><p><strong>Skip-grams:</strong></p><p>Considering the sample example from above, let us consider document 1 and word— ‘Football’ here the task of CBOW is to tell us that there is a huge probability of the context being — ‘[….] is a very good game’. It might predict other contexts as well like — ‘[….] is a very bad game’, etc depending upon the data it is trained upon.</p><p>Now, let&#39;s see how the Skip-grams perform on the dataset. Before that let&#39;s understand the code.</p><p>Here, we are creating the word vector of all the words present in the documents in the corpus. While defining the parameters we are setting ‘sg’ to 1 as this enables the word2vec model to be used as a skip-gram model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/430f63bc23a4881c72b4b105f18d42dc/href">https://medium.com/media/430f63bc23a4881c72b4b105f18d42dc/href</a></iframe><p>Next, we need to convert word-level embeddings into sentence level embeddings so that the meaning of the sentence is not lost. This step is optional as it depends upon the type of dataset you are working on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/132ee14fd92b293adc4e44c22dff6a5f/href">https://medium.com/media/132ee14fd92b293adc4e44c22dff6a5f/href</a></iframe><p>Finally, we are training the model by passing the word embeddings produced at the sentence level by the previous step, and the f1- score is calculated.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78013a50c0478adb548385a12365cf4b/href">https://medium.com/media/78013a50c0478adb548385a12365cf4b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*Fvt0nTh2K7wzkaFht69IeQ.png" /></figure><h3>Conclusion</h3><p>In a nutshell, word embeddings represent words as semantically meaningful real-valued vectors. It enables us to train the model efficiently without which the training of data would be a quite difficult task. It boosts the performance of any Natural Language Processing problem. Finally, as we saw the f1-score was the highest for the Word2Vec Skip-gram model followed by Count Vectorizer, TF-IDF Vectorizer, and then by Word2Vec CBOW model.</p><h3>References:</h3><p>Exploiting Similarities among Languages for Machine Translation — <a href="https://arxiv.org/pdf/1309.4168v1.pdf">https://arxiv.org/pdf/1309.4168v1.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c71b058bf094" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/word-embeddings-in-nlp-c71b058bf094">Word Embeddings in NLP</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Industry 4.0, where we will live in our dreams]]></title>
            <link>https://medium.com/guidona-softpedia/industry-4-0-where-we-will-live-in-our-dreams-692a44b6f4e7?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/692a44b6f4e7</guid>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[guidona-softpedia]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[indusrty-research]]></category>
            <dc:creator><![CDATA[Yashika Balani]]></dc:creator>
            <pubDate>Mon, 01 Feb 2021 13:53:44 GMT</pubDate>
            <atom:updated>2021-02-02T10:45:59.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wlqj5Ju28uRpfFocW9sHYA.jpeg" /></figure><p>With the current growth trends and technology advancements, it won’t be an exaggeration to write a diary entry of 2035 like this-</p><p><em>‘I woke up to my alarm clock annoyingly beeping only to stop itself once it senses that I have gotten out of my bed. The lights of my room switched on by themselves as my playlist started playing. I treaded to the table for my breakfast to see my toaster already prepared with my toasts. After my breakfast, I went to take a shower where as usual the water was already warm with my towel and clothes ready as ever. Later, while walking into the parking lot, my car was ready for a drive with the destination already loaded…’</em></p><p>Sounds like a dream, right? Well, that’s exactly how our diaries will look with the end of the Fourth Industrial Revolution. Our lives have taken a different turn since the Industrial Revolution began without us even realizing the changes that took place. The value of the era can be understood by keeping in mind that ‘what once was considered impossible is now possible with just a few clicks on our electronic devices.’</p><p>So, what exactly is this Fourth Industrial Revolution which sounds way more like a dream and so much less like a real revolution?</p><p>The Fourth Industrial Revolution or Industry 4.0 can be described as the automation of the traditional or old approaches of manufacturing, industrial and commercial techniques. The old will be transformed into new that will require minimal human assistance with the smart technology which is way more efficient and effective than the previous ones.</p><p><strong><em>“Engineering is the closest thing to magic that exists in the world.”</em></strong></p><p><strong><em>-Elon Musk</em></strong></p><p>This Revolution itself is very similar to magic. However, the magicians here will be the <em>engineers</em> with <em>Cyber-Physical Systems</em> as their incantations. The whole idea of the Fourth Industrial Revolution is to decrease the interference of humans. Machines will work on their own by solving their issues themselves. It can also be called the era of making machines intelligent.</p><p>To understand this concept more, we can take an example of a very famous chocolate <strong>‘Dairy Milk’</strong>. Let’s start with imagining the chocolate factory where there are different machines for each kind of chocolate that Cadbury produces under ‘Dairy Milk’. For the sake of better understanding, we will focus on two chocolates for now, ‘<strong>Fruit &amp; Nuts’ </strong>and<strong> ‘Pure Milk Chocolate’</strong>. In a general factory, it will be a human’s responsibility to ensure that the ingredients of the chocolate Fruit &amp; Nut are used to make the respective chocolate and are then, wrapped into the respective packet which says ‘Fruits &amp; Nuts’ on it. The same process goes on for pure milk chocolate.</p><p>With the above statements, we can conclude that it will be a human error if the ingredients of the pure milk chocolate and Fruits &amp; Nuts are interchanged with each other. However, this human error can be avoided if the machine itself detects if the ingredient is incorrect. Here, we are pointing towards the fact that we need to make our machines smart or intelligent enough to detect such mistakes and that’s exactly what our goal is in the Fourth Industrial Revolution.</p><p>The process of making such things possible will be carried out with the Cyber-Physical system as its base. The system is actually a computer system that operates on the basis of technical algorithms. It is the system that will integrate the physical and software elements which will help in increasing the automation. A digital twin of the physical objects will be formed that will be understood by the machine. Hence, they will be able to solve their problems themselves at times.</p><p>As seen in the above example, with the Cyber-Physical System, the processes of the machines will be transformed in such a manner that the machine will itself identify if the chocolate ingredients are right or not.</p><p>To understand and know more about the Fourth Industrial Revolution, it is important to first recognize the matter and worth of the previous Industrial Revolutions which are as follows-</p><p><strong>First Industrial Revolution</strong><br> <br> The First Industrial Revolution was previously known as Industrial Revolution as well. It was limited to two areas i.e. Britain and the United States. It started in 1760 and lasted till 1820–40. This is the era where machines were introduced and the traditional ways of producing with hands were swiped out of the minds of people. Textiles were the dominant industry during this time. The processes revolved around the increased use of Steam power and Water power.</p><p><strong>Second Industrial Revolution</strong></p><p>This Revolution is also known as Technological Revolution. It lasted from 1871 to 1914. This is the time when Railways, Telegraph, and electricity networks were set up. The increase in power and the decrease in the distance led to a lot of economic growth but it also caused a lot of people to face unemployment because of the machines that replaced them. The revolution is known for its idea of mass production as the production had boomed because of the machines.</p><p><strong>Third Industrial Revolution</strong></p><p>This Revolution is famously known as the Digital Revolution. The era is said to occur in the late 20th century when Konrad Zuse invented the Z1 computer. This revolution boosted more when the Supercomputer was introduced to mankind. With the introduction of important machines and more developments in the digital world, artificial labor started to gain even more importance.</p><h3>How is the Fourth Revolution different from the previous ones?</h3><p>When compared to all the other revolutions, the Fourth Industrial Revolution is the most complex one. While the other revolutions were based on the production and the introduction of new things, Industry 4.0 is focused on making the already existing technology smarter.</p><p>Also, we can notice that the First, Second and Third Industrial Revolutions were about Textiles, Mass productions, and Robots respectively whereas The Fourth Industrial Revolutions focuses more on the connectivity of the processes and objects. It is the era where we follow the idea of Mass Customized Production instead of Mass Production.</p><p>Mass Customized Production refers to the production done on the basis of the needs and demands of the customers. Here, the production will be customer-controlled and not producer controlled.</p><h3>Building Blocks of Industry 4.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*KK3L-qoO7b2C8y4teqRocw.png" /></figure><p><strong>1. Autonomous Robots</strong><br> <br> Autonomous Robots are intelligent machines that are able to do tasks by themselves without any human interference. They are one of the most important parts of the Fourth Industrial Revolution. This is where the machines will be able to connect with the object they are dealing with as they will be automated enough to solve their issues on their own if one arises.</p><p><strong>2. Simulation</strong><br> <br> Simulation can be described as the mocked or fake representation of the real-life processes and operations which are used to solve problems efficiently. The concept is being used and will continue being utilized by organizations all over the world as it is one of the most competent ways of saving investments. The computer model designed can be worked upon without any worries before the employees try their hands on the real machines.</p><p><strong>3. Horizontal and Vertical System Integration.</strong><br> <br> Both Horizontal and Vertical System Integration are the popular expansion strategies that companies undertake in order to grow and develop. In Horizontal System Integration, the companies try to look for companies that are similar to their own and join hands with them. For example- The Walt Disney Company and 21st Century Fox. However, in Vertical System Integration, the companies prefer to merge with such companies that are different from their lines of production. They tend to bend more towards the idea of having more ways of production and distribution rather than having to join hands with similar ones. For example- Netflix finding it profitable to produce its own content.</p><p><strong>4. Industrial Internet of Things</strong><br> <br> Internet of Things refers to the network of the physical objects (things), implanted with sensors and other technologies that will connect them with each other in one or another way over the Internet. Similarly, the Industrial Internet of Things (IIoT) refers to the use of the Internet of things in the Industrial sectors. This is the element related to adding intelligence to the machines. For example- since 2016, smarter water purifiers and electrical LEDs which themselves indicate when their parts have to change have come into use using the technology of the Industrial Internet of things.</p><p><strong>5. Cyber Security</strong><br> <br> It can be also termed as Information Technology Security. They are the guards of the artificial world. They can be made to protect the data from all kinds of damages such as theft of data or disruption in services and more.</p><p><strong>6. Additive Manufacturing</strong><br> <br> Additive Manufacturing or 3D Printing can be described as the construction of a three-dimensional object from the digital model of that object. The technology is used to produce complex parts in the inventory. Fields such as Space and Healthcare are the most benefitted ones as the complex processes such as Bio-printing and Replacement of things in the space have already been made much simpler with AM.</p><p><strong>7. Augmented Reality</strong><br> <br> Augmented Reality simply refers to an enhanced or digital version of the real-life world. It is an interactive experience where computerized models are created through the use of sound, visuals rudiments, and other sensory stimuli to create a real-life scenario on our screens. In Industry 4.0, companies are constantly searching for better ways to improve their processes to increase efficiency and the field of Augmented Reality is indeed a promising one.</p><p><strong>8. Big Data Analytics</strong><br> <br> Big Data Analytics is the field where we systematically analyze the big data present in front of us before we draw expertise conclusions from it. It can be used to study hidden patterns, trends, demand, and supply chains or extract useful information from big stacks of data. This field is helpful when it comes to decision making in big organizations.</p><p><strong>9. Cloud Computing</strong><br> <br> Cloud computing is the service offered by the internet which is mainly related to data storage and the creation of data centers where bulks of data can be easily stored and later accessed when needed. These provide flexibility to an organization by reducing the waiting time for them as they are readily available for use all the time.</p><h3>Advantages of the Fourth Industrial Revolution</h3><p>The ongoing revolution comes with a number of benefits for mankind which are not limited to making our daily lives easier. Some of the advantages are as follows-</p><p><strong>1. Mass Customized Production</strong><br> <br> When the Production will be done on the basis of what customer needs or demands, the scope for the wastage of resources will be deduced to nil as the companies will only produce what can be sold. It will be good for both, the companies as well as the customers living through the Fourth Industrial Revolution.</p><p><strong>2. Increase in Efficiency</strong> <br> <br> With the smarter technologies into action, it is easy to say that the upcoming industries will be way smarter and more efficient than the ones we have in the present. The automated machines will be able to produce more and there will be no area left open to the risk of Human errors which is one of the most important points of the Fourth Industrial Revolution.</p><p><strong>3. Reduction in Costs</strong></p><p>The technologies that are being supported in the era of Industry 4.0 can be undoubtedly termed as ‘one-time investments’ for all the industries. Whether it be the heavy intelligent machinery or the mocked real-time problems, everything will require way less investment in the long run which will help in reducing the cost of operations of the companies that will further lead to great profits.</p><p><strong>4. Improved Customer Experience</strong><br> <br> With the production being aligned towards what the customer wants, it is obvious that consumer satisfaction will reach its peak in this era of revolution. The processes will become way faster and comparatively cheaper for everyone with the upcoming new technologies. For example- the introduction of the FASTag has helped in avoiding the long lines on the tolls.</p><p><strong>5. Creation of Employment Opportunities</strong><br> <br> As said by Markus Lorenz, in countries like Germany, 600,000 people are bound to lose their jobs in the next decade when everything will become automated. However, this revolution will also create 1,000,000 vacancies for the people in the field of technology, leading to a net increase of 400,000 new jobs for the people of Germany. The same can be witnessed all around the globe.</p><p><strong>6. Increased Flexibility</strong><br> <br> The revolution will witness way more flexibility in the processes and operations of the machines than it ever has till now. This can be understood by keeping in mind that it is easier to work with smarter machines. The processes can be slowed and speeded up as per our requirements anytime we want.</p><p>There are many other advantages of Industry 4.0 such as an increase in production speed, data-driven simulations, decrease in errors, advanced analytics, and more. The list can be made endless if studied in detail.</p><p>The Fourth Industrial Revolution has already begun and we are a part of it. Many companies like KPMG and Microsoft are the prime leads of the revolution as of now. It is predicted that 50% of the work activities will be automated through this revolution with 15% of the workforce replaced by machines.</p><p>The fields such as Healthcare, Energy, and Technology will be the ones leading throughout the Fourth Industrial Revolution. These areas will be able to create enough employment opportunities to take care of the unemployed people. Only a person with complex problem solving, critical thinking, creativity, and cognitive flexibility will become an ideal in the world of smart machines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=692a44b6f4e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/industry-4-0-where-we-will-live-in-our-dreams-692a44b6f4e7">Industry 4.0, where we will live in our dreams</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Weight Initialization Methods in Neural Networks]]></title>
            <link>https://medium.com/guidona-softpedia/weight-initialization-methods-in-neural-networks-a3e7a793cee5?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/a3e7a793cee5</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[weight-initialization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Saurav Joshi]]></dc:creator>
            <pubDate>Fri, 29 Jan 2021 15:03:29 GMT</pubDate>
            <atom:updated>2021-01-29T15:03:29.113Z</atom:updated>
            <content:encoded><![CDATA[<p>Training a neural network completely depends upon the type of parameters used to initialize the network. If the initialization of parameters is done correctly, the optimization or the result will be achieved in minimal time and if not initialized properly will lead to problems. In simple words, the performance of the neural network depends on how its parameters are initialized when it is starting to train. If we train a neural network with random weights, then the output becomes non-reproducible. On the other hand, if we train the neural network with constantly valued weights, then it would consume a lot of time to converge.</p><p>In this blog, we will talk about the different initializers used to initialize weights in neural networks. Before that let&#39;s look at the dataset and the model I have used for experimental purposes.</p><h3>Data and Model</h3><p>To visualize and understand the performance level of the initializers, I have used the MNIST dataset. The MNIST database (Modified National Institute of Standards and Technology<em> </em>database) is a large database of handwritten digits that is commonly used for training various image processing systems. The database is also widely used for training and testing in the field of machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*EyHwsAJ8MelnglKYDDuzwQ.png" /></figure><p>The model architecture used to train is the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*j9wTuT7OLuxsJhmPaQ0eZA.png" /></figure><p>The final Dense layer has a shape of (10, ) and a softmax activation function as it would give us the probability of 10 different classes that is from 0–9. The model architecture will remain the same for all the initializers which will be used for experimental purposes. Adam and sparse_categorical_crossentropy will be used as optimizer and loss function respectively. The model was trained for a total of 20 epochs.</p><h3>Weight Initialization Methods</h3><p>Let us understand the initializers and how they perform on the MNIST dataset using the above architecture. The code is run on <em>jupyter notebook</em> and <em>wandb </em>is used to visualize models over the course of training. Validation/epoch_accuracy and validation/epoch_loss is displayed for every initializer on the MNIST dataset. Check out the code for the following work here: <a href="https://github.com/sauravjoshi23/Weight-Initialization-Keras">https://github.com/sauravjoshi23/Weight-Initialization-Keras</a></p><h4>Zero Initialization</h4><p>In this method, all the weights associated with the input are assigned to be zero. Hence, the derivative with respective to the loss function is the same for every weight in each iteration. It is then similar to a linear model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_ijmZ2vqlD9fdkE7FBd_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*I-LekGNLhhM4YXcNzUWoUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*BI3ZJJ8QAweulSV47H8u_Q.png" /></figure><h4>One Initialization</h4><p>In this method, all the weights associated with the input are assigned to one but it is still comparatively better than assigning weights to zero because the product of W<em>i</em>X<em>i</em> is not zero as W<em>i’s</em> are not zero in this method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVrs8_ZMVSLwIrzVquTuZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*vmDy7qPWBfbQIk35zowNcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*tWPx8o6PMiuc3modCcmMKA.png" /></figure><h4>Orthogonal Initialization</h4><p>Orthogonal initialization proves really beneficial in optimizing deep neural networks. It speeds up the convergence relative to the standard Gaussian initialization. For deep neural networks, the width needed for efficient convergence to a global minimum with orthogonal initialization is independent of the depth. It generates a random orthogonal matrix at the time of its execution. Orthogonal initializer returns a tensor that if multiplied by its transpose, gives an identity tensor.</p><p><strong>Arguments</strong>:</p><ul><li><strong>gain</strong>: Multiplicative factor to apply to the orthogonal matrix.</li><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8KcKgAK3XpQX3LPxJNX5qQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*IgLurFekIh-dvjbBTnXCZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*JZBIZAP7mDXSxg5CeiOJTg.png" /></figure><h4>Identity Initialization</h4><p>Identity initializer returns a tensor with 0’s everywhere except for 1’s at the diagonal. It is only used for 2D matrices.</p><p><strong>Arguments</strong>:</p><ul><li><strong>gain</strong>: Multiplicative factor to apply to the identity matrix.</li><li><strong>dtype</strong>: The type of the output.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzd39sNtBJ2rfVZFd18qYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*GezlDOlCtFkNBKBOAa9htQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*Sbcqc_6afru1016N2vcGyQ.png" /></figure><h4>Random Normal Initialization</h4><p>Assigning random weight values is better than assigning ones or zeros as weight values as we saw earlier the accuracy of one and zero initializers being reasonably low. On the other hand, if randomly initialized weight values are very high or very low then it may lead to problems known as exploding gradients and vanishing gradients respectively.</p><p>In this method, the initializer generates tensors with a normal distribution.</p><p><strong>Arguments:</strong></p><ul><li><strong>mean</strong> a python scalar or a scalar-tensor. Mean of the random values to generate.</li><li><strong>stddev</strong>: a python scalar or a scalar-tensor. The standard deviation of the random values to generate.</li><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYRKes9BxdFNR2woXePd1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*8by3f6kDdjNSb4eng_8EIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*LnhOlQdF9TuokGLhIyYzww.png" /></figure><h4>Random Uniform Initialization</h4><p>In this method, the initializer generates tensors with a uniform distribution.</p><p><strong>Arguments:</strong></p><ul><li><strong>minval</strong>: A python scalar or a scalar-tensor. Lower bound of the range of random values to generate.</li><li><strong>maxval</strong>: A python scalar or a scalar-tensor. Upper bound of the range of random values to generate. Defaults to 1 for float types.</li><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a-dU-4ksmwWKJ-UscQZirA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*chvKwI_OxBs94GXBwxDZxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*hUrNmR2uFhW8AnJHSvwEOg.png" /></figure><h4>Glorot Normal Initialization</h4><p>Glorot Normal Initializer is also known as Xavier Normal Initializer. It is similar to He initializer but it is used for tanh activation functions. It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / (fan_in + fan_out)) where fan_in is the number of input units in the weight tensor and fan_out is the number of output units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xgh_yal0e9j92NhajL1AsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*9TinNx72LtNSzIWRaJpdiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*oy5KKGUFv2j15epCQbZ_cw.png" /></figure><h4>Glorot Uniform Initialization</h4><p>Glorot Uniform Initializer is also known as Xavier Uniform Initializer. It is similar to He initializer but it is used for tanh activation functions. It draws samples from a uniform distribution within [-limit, limit] where limit is sqrt(6 / (fan_in + fan_out)) where fan_in is the number of input units in the weight tensor and fan_out is the number of output units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J1ApffiCte9YHYD7gwlMMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*_NY-GmNMUROjViL0yTCXDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*KejW5L8K6GepGsXVy_ZdNQ.png" /></figure><h4>He Normal Initialization</h4><p>In this method, we multiply the random initializations with stddev to get better results. It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / fan_in) where fan_in is the number of input units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7bo6kd64f19IJjapO10tA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*tKHepyCdG2KKdOtvAuHVCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*_VEYiVZGVMgnxXTo_HL-dQ.png" /></figure><h4>He Uniform Initialization</h4><p>In this method, it draws samples from a uniform distribution within [-limit, limit] where the limit is sqrt(6 / fan_in) where fan_in is the number of input units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aa6B65p4ki6_bXs5z3Q3ZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*XGyZeO8IIFB5AEZ3fdMnWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*LSadEUj5kVUNlLhwDqwTOg.png" /></figure><h4>LeCun Normal Initialization</h4><p>In this method, it draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(1 / fan_in) where fan_in is the number of input units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcE5yezuCjdlnWfugHpjSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*8BsSamO1uwmlMb5tAENRVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*7VECh3fwvFuEqbFVUI1JnA.png" /></figure><h4>LeCun Uniform Initialization</h4><p>In this method, it draws samples from a uniform distribution within [-limit, limit] where the limit is sqrt(3 / fan_in) where fan_in is the number of input units in the weight tensor.</p><p><strong>Arguments:</strong></p><ul><li><strong>seed</strong>: A Python integer. Used to seed the random generator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jB9zxpcHS8NIKyo8Uy3yWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*UKH8rqnl9F7dBzjrjpazag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*8z6048FjT7XAZIFsLM2Itg.png" /></figure><h3>Conclusion</h3><p>The weight initialization methods such as He, Glorot, LeCun and are much better than some of the weight initialization methods discussed at the start. Although, the random normal and random uniform initializers have good accuracy they are not reproducible and are the source of vanishing gradient and exploding gradient problems. Some of the new techniques discussed at the end set weights neither too much bigger than 1 nor too much less than 1. Adding to it, the time taken for convergence is also less. Hence, we can conclude that all the initializers have their own significance but the objective of avoiding slow convergence remains the same for all but only a few are able to achieve it.</p><h3>References</h3><p><a href="https://www.tensorflow.org/api_docs/python/tf/keras/initializers">https://www.tensorflow.org/api_docs/python/tf/keras/initializers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3e7a793cee5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/weight-initialization-methods-in-neural-networks-a3e7a793cee5">Weight Initialization Methods in Neural Networks</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Trie Data Structure]]></title>
            <link>https://medium.com/guidona-softpedia/understanding-trie-data-structure-39e7652114d5?source=rss----466176dbf1d2---4</link>
            <guid isPermaLink="false">https://medium.com/p/39e7652114d5</guid>
            <category><![CDATA[guidona-softpedia]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[trie]]></category>
            <dc:creator><![CDATA[Akanksha Parmar]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 17:59:34 GMT</pubDate>
            <atom:updated>2021-01-25T17:59:34.422Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>You must have used the dictionary to look up the meaning of a word. You may not know how to use a dictionary when you first saw it but then you realized its importance and you learnt how easy it is to search for a word among billions and trillions of words in this world in just minutes.</p><p>You must have played the game “word puzzle” in your childhood where you have to find meaningful words from a large set of alphabets that have been given to you. How you travelled all the way to board searching for the longest word to score more points.</p><p>So, to do this humans have set some of their strategies to make their life easy whether it is the case of finding a word from a dictionary or to win a word puzzle game.</p><p>To solve these types of real world problems there are many algorithms and data structures designed to make our computers more efficient and optimized in terms of space and time.</p><p>But different data structures serve different purposes.</p><p>As a programmer one of the most important topics is string handling and processing. Many real time applications are based on string processing for example: A keyboard, it uses data structure to show you word suggestions as you type along and to autocomplete the word you are typing thus saving time and spell-checking. This particular data structure is known as TRIE.</p><h3><strong>What is Trie?</strong></h3><p>There are data structures that are built on the basis of another data structure that we are already familiar with, so these types of data structures are known as Advanced Data Structure.</p><p>Trie is an advanced data structure. It is a tree-like data structure also known as digital tree or prefix tree. It is used to store a collection of strings. If we have thousands or hundreds of thousands of strings we can store it in trie data structure.</p><ol><li>It consists of nodes which store the letters of a word.</li><li>Each node consists of a maximum of 26 children and edges connect each parent node to its children.</li><li>Every trie has an empty root node.</li><li>Strings are stored in a top to bottom manner on the basis of their prefix in a trie.</li><li>All prefixes of length 1 are stored at until level 1.</li><li>All prefixes of length 2 are stored at until level 2 and so on.</li></ol><h3><strong>Working</strong></h3><p>We will see its implementation through an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1Wf9WeY8mXok6hBJ44TVg.png" /></figure><p>If we look at our trie we can see that- We have an empty root node. We have 6 different words that we are representing in this trie i.e. Stand, Stroke, Strong, Strike, String, Strings. There are 6 different branches to this trie one for each word. We can also see that the words are sharing parent nodes for example in the all the six words we have a common node “S” and “T”. Similarly, the path to word strong and stroke share the nodes “S”, “T”, “R”, “O”. So if we want to add a new word for example STROLL to this trie:</p><p>(A) We will first search for the word using these few simple steps -</p><ol><li>It will start with the root node and the prefix to search for.</li><li>It takes one character at a time from the prefix and searches through the children of the “current node” (at the beginning which points to the root node) to find a node containing that character.</li><li>If found, it reassigns that child node as the “current node” (which means in the next iteration step it will start from here)</li><li>If not found then it returns False to indicate that the prefix does not exist.</li><li>So in this example, it will start with the root node and the prefix to search for is “S”. It will search through the children of root node. So “S” is a child of root node so it is found, then “S” becomes the current node. This way “S”, “T”, “R”, “O” is found. Now our current node is “O” and we will search for the alphabet “L”. Since, “L” is not a child of “O” it will return string not found.</li></ol><p>(B) Inserting the string.</p><ol><li>Every character of input key is inserted as an individual Trie node.</li><li>If the input key is new or an extension of existing key, we need to construct non-existing nodes of the key, and mark end of word for last node. If the input key is prefix of existing key in Trie, we simply mark the last node of key as end of word.</li><li>The key length determines Trie depth.</li></ol><p>So in the above example we can see that the alphabets “S”, “T”, “R”, “O” already exists in the trie so we will start with inserting “L”, “O” will be our current node and we will construct a new child of node “O” i.e., “L” similarly now our current node will be “L” and we will create a child of node “L” i.e. “L”. Since this is the last node we will mark the node as end of the word. This way our new word i.e. “Stroll” is added in the trie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-zzg4JuN9LnQwXrXAhXzQ.png" /></figure><p>So, here we have discussed two operations on trie i.e., Searching for a word and insertion of new word in the trie. We can perform more operations on trie depending upon the need like deletion of a node.</p><h3><strong>Python Implementation of Trie</strong></h3><p>Let’s dig into the implementation part of the trie , after all what’s the importance of mugging the theory if we can’t implement it in real life.</p><blockquote><strong>Creating our TrieNode class</strong></blockquote><p>The first thing we need is a node, after all this is a tree implementation, to store each character that occurs in our word . So we will create our TrieNode class which will have 3 fields :</p><p>1. Character — to store corresponding characters of our word.</p><p>2. List of child nodes — pointer to store node of child characters.</p><p>3. Boolean — to mark that the current character marks the end of a searched word or not.</p><pre>class TrieNode:</pre><pre>#init function accepts one parameter, the character to insert<br>    def __init__(self, char):<br> <br>        self.char= char<br> <br>        self.is_end = False<br> <br>        self.children = {}</pre><p>Here, while initializing the TrieNode class we need to provide a char that we want to insert or have a search suggestion for. is_end is a Boolean variable to mark the end of the current word.</p><blockquote><strong>Initializing our Trie</strong></blockquote><p>Now the fun part of trie begins, here we implement the insert and search functions of trie.</p><p>Insert will add new nodes of characters of a fresh word and search will help to retrieve any word already inserted or show suggestions accordingly.</p><pre>class Trie(object):<br> <br>    def __init__(self):<br> <br>        self.root = TrieNode(&quot;&quot;)</pre><p>The above code will create a parent root node which will be empty containing no characters. This will be our starting point as it will start pointing to all 26 alphabets in English dictionary as soon as they occur.</p><blockquote><strong>Insertions in our Trie</strong></blockquote><p>To make an insertion we need to traverse the word to be inserted character by character.</p><p>Implementation goes like this, we traverse the word, and simultaneously we check that the children of current has that character or not, if present just move down to next node else we create a new TrieNode with the current character and add that to the list of child of the node we are currently present on.</p><p>We repeat the above procedure until we reach the end of the word we are inserting, then we make the <strong>is_end</strong> Boolean true marking the end of the word we were inserting.</p><p>Sounds simple, right? Below is the code implementation of the above.</p><pre>def insert(self, word):<br> <br>        node = self.root<br> <br>#traverse the word character by character</pre><pre>        for char in word:</pre><pre>#check if the character is there in the list of children<br></pre><pre>            if char in node.children:<br>                node = node.children[char]</pre><pre>            else:<br>                new_node = TrieNode(char)<br> <br># add the new node to the list of children<br> <br>                node.children[char] = new_node<br>                node = new_node</pre><pre>#after traversing the word set .is_end to true for the last #char<br>        node.is_end = True</pre><blockquote><strong>Search in Trie</strong></blockquote><p>By searching we generally look for the exact match of the word , but here we are looking for a list of matching words that start with the word we searched for.</p><p>Say we type a string in search bar , this string will be passed to the search function as a parameter and the search function will return the list of matching characters, simple.</p><p>We will take help of DFS in doing so, so we will write a DFS function which goes like ,</p><pre>def dfs(self, node, pre):<br> <br>       if node.is_end:<br>           self.output.append((pre + node.char))<br>        <br>       for child in node.children.values():<br>           self.dfs(child, pre + node.char)</pre><p>The function asks for 2 parameters, node prefix of the string searched so far. If the current node marks the end of a word, it will be appended to the output list, else the function will keep on traversing the corresponding children.</p><p>The search function goes like this,</p><pre>def search(self, x):<br>        <br>        node = self.root<br># traverse the search query and move down the trie     <br>        for char in x:<br>            if char in node.children:<br>                node = node.children[char]<br>            else:<br>              #if query doesn&#39;t match the nodes in trie<br>                return []<br>         <br>        self.output = []<br>#call DFS<br>        self.dfs(node, x[:-1])<br> <br>        return self.output</pre><p>First it will traverse down to the node if the last character of the searched string, if the string not present will simply return the empty list, else it will call the DFS function on the searched string to get all the words having prefix as the searched string.</p><blockquote><strong>Complete Code</strong></blockquote><p>The complete implementation of trie is given below:</p><pre>class TrieNode:<br> <br>    def __init__(self, char):<br> <br>        self.char = char<br> <br>        self.is_end = False<br> <br>        self.children = {}<br> <br>class Trie(object):<br> <br>    def __init__(self):<br> <br>        self.root = TrieNode(&quot;&quot;)<br>     <br>    def insert(self, word):<br> <br>        node = self.root<br> <br>        for char in word:<br>            if char in node.children:<br>                node = node.children[char]<br>            else:<br> <br>                new_node = TrieNode(char)<br>                node.children[char] = new_node<br>                node = new_node<br>         <br>        node.is_end = True<br>         <br>    def dfs(self, node, pre):<br> <br>        if node.is_end:<br>            self.output.append((pre + node.char))<br>         <br>        for child in node.children.values():<br>            self.dfs(child, pre + node.char)<br>         <br>    def search(self, x):<br>        <br>        node = self.root<br>         <br>        for char in x:<br>            if char in node.children:<br>                node = node.children[char]<br>            else:<br>                return []<br>         <br>        self.output = []<br>        self.dfs(node, x[:-1])<br> <br>        return self.output</pre><p>Let’s try inserting words in our tree and make a search query:</p><pre>obj1 = Trie()<br>obj1.insert(&quot;strong&quot;)<br>obj1.insert(&quot;string&quot;)<br>obj1.insert(&quot;strike&quot;)<br>obj1.insert(&quot;stroke&quot;)<br>obj1.insert(&quot;strings&quot;)<br>obj1.insert(&quot;stand&quot;)</pre><p>The above code will create a trie “obj1” and insert the words to it.</p><p>We can now make a search query using following code:</p><pre>obj1.search(&quot;string&quot;)</pre><p>OUTPUT :</p><pre>[&#39;string&#39;, &#39;strings&#39;]</pre><p>The trie for the above code will look like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oy-1OaT5VJ9GFYSoRsIHYg.gif" /></figure><h3>Time Complexity</h3><p>The complexity to make a trie structure is O(n*m), where <em>m</em> is the length of the longest word (worst case complexity), and <em>n</em> is the number of words in the trie. This is how: Every time you traverse a string and add it to the existing structure, you perform a few operations like initializing. This is however, a constant time operation. It takes O(1) to create a new node. It is not necessarily O(1) but O(C) where C is a constant.<br>This is repeated in the worst case for all the strings with length m and hence the complexity of the trie is O(n*m).</p><h3>Applications of trie</h3><p>We’ve all used autocomplete on our cellphones. Well, that’s maybe the most common application of the trie. Once you’ve typed in a letter, the tree of potential words is greatly reduced, allowing the program to easily enumerate what kinds of strings are possible.</p><p>Google search uses the power of trie to give search suggestions to the user, you type in a letter or a word it will give suggestions of words or sentence respectively in accordance to the searched string. Now in real life , the search suggestions algorithm is much more complicated , uses external factors, more enhancements , suggestions based on recent searches, popularity, similar fields and much more, but the basic foundation used is trie.</p><h3>Conclusion</h3><p>This documentation on trie would help you understand the basics of trie data structure with proper illustrations for better understanding and it’s python implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39e7652114d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidona-softpedia/understanding-trie-data-structure-39e7652114d5">Understanding Trie Data Structure</a> was originally published in <a href="https://medium.com/guidona-softpedia">Guidona</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>