<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ravi Dahiya on Medium]]></title>
        <description><![CDATA[Stories by Ravi Dahiya on Medium]]></description>
        <link>https://medium.com/@ravidahiya74?source=rss-807bc166bd5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*uEu6sSuSoPN_dTps</url>
            <title>Stories by Ravi Dahiya on Medium</title>
            <link>https://medium.com/@ravidahiya74?source=rss-807bc166bd5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:42:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravidahiya74/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why do people fail Data Science interviews. (Hiring Manager’s perspective)]]></title>
            <link>https://medium.com/@ravidahiya74/why-do-people-fail-data-science-interviews-hiring-managers-perspective-307a4b069fa6?source=rss-807bc166bd5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/307a4b069fa6</guid>
            <category><![CDATA[data-science-interview]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Ravi Dahiya]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 10:40:42 GMT</pubDate>
            <atom:updated>2022-12-23T10:40:42.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why do people fail Data Science interviews? (Hiring Manager’s perspective)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5HvAQ8aMKKBBuHLMkBScsA.jpeg" /></figure><p>As a hiring manager or interviewer, it can be frustrating to come across candidates who have worked with a range of sophisticated tools and technologies but struggle to answer basic questions about data science concepts and techniques. While having experience with state-of-the-art tools and technologies is certainly important in the field of data science, it is equally important for candidates to have a strong foundation in the underlying concepts and principles.</p><p>There could be several reasons why the majority of candidates lack a strong foundation in statistics, SQL, and machine learning. Some possible explanations include:</p><ol><li><strong>Lack of emphasis on fundamentals:</strong> With the rapid pace of technological advancement, it can be tempting for individuals to focus on learning the latest tools and technologies rather than taking the time to build a strong foundation in the underlying concepts and principles.</li><li><strong>Insufficient training or education:</strong> In some cases, candidates may not have received sufficient training or education in these areas during their academic studies or professional development. This could be due to a lack of emphasis on these topics in their coursework, or a lack of access to resources and opportunities to learn and practice.</li><li><strong>Limited real-world experience: </strong>While it’s important to have a strong theoretical understanding of data science concepts and techniques, it’s also important to have practical experience applying these concepts to real-world problems. Some candidates have limited exposure to real-world data science projects.</li></ol><p>Building a strong foundation in statistics, SQL, and machine learning is critical for success as a data scientist. Here are a few reasons why these topics are so important:</p><p><strong>Statistics:</strong></p><ul><li>Statistics is the foundation of data science, and it’s essential for understanding and interpreting data.</li><li>Statistics helps you understand the concepts of probability, which is important for understanding how to measure the likelihood of different outcomes and make predictions.</li><li>Statistical analysis allows you to test hypotheses and make informed decisions based on data.</li></ul><p><strong>SQL:</strong></p><ul><li>SQL is a widely used programming language for managing and manipulating data stored in relational databases.</li><li>As a data scientist, you will often be working with large amounts of data that are stored in a database, and being able to efficiently retrieve and manipulate this data using SQL is critical for success in the role.</li><li>SQL is also useful for creating reports and visualizations, as well as for performing data cleaning and preprocessing tasks.</li></ul><p><strong>Machine learning:</strong></p><ul><li>Machine learning is a key aspect of data science, and a strong understanding of machine learning concepts and techniques is essential for success in the field.</li><li>Many machine learning algorithms are based on statistical concepts and techniques, such as probability and statistical inference. A strong foundation in these concepts is essential for understanding how machine learning algorithms work and how to apply them effectively.</li><li>Machine learning often requires coding in languages such as Python or R, so a strong foundation in programming is important for implementing machine learning algorithms and working with data.</li></ul><p>So, what can candidates do to become better prepared for data science interviews and demonstrate their knowledge and expertise to potential employers? Here are a few tips:</p><ol><li><strong>Brush up on your foundational skills:</strong> Before diving into the latest and greatest tools and technologies, make sure you have a strong foundation in basic data science concepts and techniques. This includes understanding topics such as statistical analysis, machine learning algorithms, data visualization, and data cleaning and preprocessing.</li><li><strong>Practice, practice, practice:</strong> The best way to prepare for an interview is to practice answering questions and working through problems. Find sample interview questions online and try to answer them on your own. If you struggle with a particular question, try to understand why and learn from it. You can also try working through practice problems and case studies to get a feel for the types of challenges you may encounter in an interview.</li><li><strong>Know your tools and technologies:</strong> It’s important to be familiar with the tools and technologies commonly used in data science, such as programming languages like Python and R, data visualization tools like Tableau and matplotlib, and machine learning libraries like scikit-learn and TensorFlow. However, it’s not enough just to be familiar with these tools — you should also be able to demonstrate how you’ve used them effectively in real-world projects.</li><li><strong>Communicate effectively:</strong> In a data science interview, it’s not just about what you know — it’s also about how you communicate your knowledge and ideas. Make sure you can clearly and concisely explain your thought process and the steps you took to solve a problem.</li><li><strong>Stay up-to-date: </strong>The field of data science is constantly evolving, and it’s important to stay current with the latest trends and technologies. Make sure to keep your skills and knowledge up-to-date by staying involved in the data science community, reading industry blogs and articles, and learning about new tools and techniques.</li></ol><p>From my personal experience, I have seen that less than 25% of the candidates put in the effort to understand the basics and I hope that this article helps to improve that number.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=307a4b069fa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hierarchical Agglomerative Clustering: Algorithm and when to use it.]]></title>
            <link>https://medium.com/analytics-vidhya/hierarchical-agglomerative-clustering-algorithm-and-when-to-use-it-58a3cdd6ffd2?source=rss-807bc166bd5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/58a3cdd6ffd2</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[hierarchical-clustering]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[agglomerative-clustering]]></category>
            <dc:creator><![CDATA[Ravi Dahiya]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 13:29:54 GMT</pubDate>
            <atom:updated>2020-02-09T14:23:29.680Z</atom:updated>
            <content:encoded><![CDATA[<p>As a Data Scientist or a marketeer, you should have come across clustering. Clustering of the data is done with the aim to segregate groups with similar traits and assign them into different clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1Pt4rnHEjwwwT8kpP2RCw.png" /><figcaption>Image Source — Wikipedia</figcaption></figure><p>Data Scientists are mostly aware of Kmeans Clustering as an unsupervised form of Machine Learning and it is indeed very useful when we know the underlying classes in the Data. But the things get little complicated when we do not know the number of clusters that exist in the data.</p><p>K-means works by taking a set parameter that tells it how many clusters we think exist in the data, and then uses the Expectation-Maximization (EM) algorithm to iteratively shift each cluster centroid to the best possible position by constantly calculating and recalculating the centroid’s position by assigning each point to the cluster centroid they are closest to with each new step, and then moving the centroid to the center of all the points currently assigned to that centroid. With non-hierarchical algorithms, there can be no subgroups — that is, no clusters within clusters.</p><p>Agglomerative clustering is a bottom up clustering technique that is very useful when the number of clusters are unknown. The algorithm starts with 𝑛 clusters (where 𝑛 is the number of data points) and proceeds by merging the most similar clusters, until some stopping criterion.</p><h3>Algorithm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ET8kCcPpr893vNZFs8j4xg.gif" /></figure><ol><li>Begin with all the observations and a measuring criteria (usually euclidean distance) and calculate the pairwise euclidean distances</li><li>Consider the pair with the lowest euclidean distance as our first cluster.</li><li>Now again calculate the pairwise distances but this time consider the previous pair as one point. We have the option to calculate three different distances for the cluster (nearest point, farthest point or the middle point in the cluster, we will discuss them later).</li><li>Previous step will give us another cluster and we will repeat step-3 till we get one giant cluster.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3V4kp3tIZhbzegzeSBe5hg.png" /></figure><h3>Linkages</h3><p>As mentioned in the algorithm, we have three different way to measure the distance from a point to the cluster. They are called linkages and Scikit-learn provides three linkage criteria:</p><ul><li><strong>Ward</strong> (default): picks the two clusters to merge in a way that the variance within all clusters increases the least. Generally, this leads to clusters that are fairly equally sized.</li><li><strong>Average</strong>: merges the two clusters that have the smallest <strong><em>average</em></strong> distance between all the points.</li><li><strong>Complete</strong> (or maximum linkage): merges the two clusters that have the smallest <strong><em>maximum</em></strong> distance between their points.</li></ul><p>These linkage criteria can definitely have an effect on how the clustering algorithm performs. But no one of these is “best” — which one you should use often depends on the structure of your data, and/or your own goals.</p><p>So, Hierarchical Agglomerative Clustering can be really helpful in the cases when you do not know the number of clusters in the data and the cases when you are looking for latent or interesting clusters in the data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58a3cdd6ffd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/hierarchical-agglomerative-clustering-algorithm-and-when-to-use-it-58a3cdd6ffd2">Hierarchical Agglomerative Clustering: Algorithm and when to use it.</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are we living in a Sustainable World? Using Deep Learning (SOM)to find answers.]]></title>
            <link>https://medium.com/analytics-vidhya/are-we-living-in-a-sustainable-world-using-deep-learning-som-to-find-answers-d97ac5445ac9?source=rss-807bc166bd5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d97ac5445ac9</guid>
            <category><![CDATA[sustainability]]></category>
            <dc:creator><![CDATA[Ravi Dahiya]]></dc:creator>
            <pubDate>Tue, 24 Dec 2019 15:47:35 GMT</pubDate>
            <atom:updated>2019-12-26T08:28:07.406Z</atom:updated>
            <content:encoded><![CDATA[<h3>Are we living in a sustainable world? Let’s use Deep Learning (SOM)to find answers.</h3><p>Sustainable world is the outcome of the sustainable development strategies and implementation. Major factors, such as human population size, biosphere robustness, resource stock, food supply, and environmental quality must remain in balance, on a global scale. This state of balance must last long enough so that it will not be merely a blip on the curve of unsustainable growth . Even though we might not really attain that balance, we must move in that direction if humanity and the ecosystem are to survive.</p><p>Because the Earth is a closed system, a sustainable world is not compatible with “sustainable growth” . A closed system might conceivably accommodate “sustainable development,” a term popularized by the World Commission on Environment and Development (1987; the “Brundtland Commission”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJl3y0F401gX35nzOHGq0w.jpeg" /></figure><h3>Why Environmental Sustainability?</h3><p>Environmental sustainability is concerned with whether environmental resources will be protected and maintained for future generations.Environmental sustainability is concerned with issues such as:</p><ul><li>Long-term health of ecosystems. Protecting the long-term productivity and health of resources to meet future economic and social needs, e.g. protecting food supplies, farmland and fishing stocks.</li><li>Intergenerational decision making. When making economic decisions, we should focus on implications for future generations, and not just the present moment. For example, burning coal gives a short-term benefit of cheaper energy, but the extra pollution imposes costs on future generations.</li><li>Renewable resources: Diversifying into energy sources that do not rely on non-renewable resources. For example, solar and wind power.</li><li>Prevent the consequences of man-made global warming. Policies to ensure the environment of the planet does not deteriorate to a point where future generations face water shortages, extreme weather events, excess temperature. — All factors that could make living in parts of the world very difficult if not possible.</li><li>Protection of species diversity and ecological structure. Sometimes medicines require elements within specific plant species. If some species go extinct, it limits future technological innovation.</li><li>Treating environmental resources as if they have intrinsic rights and value. In other words, we shouldn’t just rely on a monetary value, i.e. we should protect rainforests because they deserve to be protected rather than using a cost-benefit analysis of whether we gain financially from protecting rainforests.</li><li>Targetting social welfare, happiness and environmental sustainability above crude measures of progress such as GDP.</li></ul><h3>Human Development Report Data</h3><p>United Nations Development Program publishes Human Development Report that collects data from various sources pertaining to Human Development. It captures various parameters such as ‘quality of human development’, ‘gender gap’, ‘women empowerment’, ‘environment sustainability’ and many more. Please check out the latest report <a href="http://report.hdr.undp.org/?utm_source=web&amp;utm_medium=homepage&amp;utm_campaign=hdr19">here</a>.</p><h3>Enviormental Performance Index</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpyDQOVc2J_CM1KZsCgUFA.png" /><figcaption>Source — Environmental Performance Index (EPI) designed to supplement the environmental targets set forth in the United Nations Millennium Development Goals.</figcaption></figure><p>The map depicts the environmental performance of the countries on a scale of 0 to 100. We will try to use Unsupervised Deep Learning technique to organise the countries using Human Development Report Data and try to compare the results.</p><h3>Unsupervised Deep Learning (Self Organising Maps)</h3><p>A self-organizing map (SOM) is a type of artificial neural network (ANN) that is trained using unsupervised learning to produce a low-dimensional (typically two-dimensional), discretized representation of the input space of the training samples, called a map, and is therefore a method to do dimensionality reduction. Self-organizing maps differ from other artificial neural networks as they apply competitive learning as opposed to error-correction learning (such as backpropagation with gradient descent), and in the sense that they use a neighborhood function to preserve the topological properties of the input space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*NavCyksLxoGPlVM-tUFcOA.png" /></figure><p>The example shows a complex data set consisting of a massive amount of columns and dimensions and demonstrates how that data set’s dimensionality can be reduced.</p><p>So, instead of having to deal with hundreds of rows and columns (because who would want that!), the data is processed into a simplified map; that’s what we call a self-organizing map. The map provides you with a two-dimensional representation of the exact same data set; one that is easier to read.</p><h3>Building our dataset</h3><p>Most of the data used in the project was from Human Development Report-2018. The dataset was obtained by following method:</p><ul><li>1: Slicing the relevant data from the ‘Human Development Report-2018’ and converting it to csv file</li><li>2: Adding the pollution index from <a href="https://www.numbeo.com/pollution/rankings_by_country.jsp">here</a> to the csv file using webscrapping tools in pandas.</li><li>3: Adding country code to the csv file that will be used to plot choropleth map using plotly</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFDerF0wrZKRXZzeiT2PXQ.png" /></figure><h3>Describing the Columns</h3><ul><li>Fossil_fuel_usage: Percentage of total energy consumption that comes from fossil fuels, which consist of coal, oil, petroleum and natural gas products.</li><li>Renewable_energy_usage: Share of renewable energy in total final energy consumption. Renewable sources include hydroelectric, geothermal, solar, tides, wind, biomass and biofuels.</li><li>Per_capita_CO2: Human-originated carbon dioxide emissions stemming from the burning of fossil fuels, gas flaring and the production of cement. Carbon dioxide emitted by forest biomass through depletion of forest areas is included. Data are expressed in tonnes per capita (based on midyear population)</li><li>Forest_area: Land spanning more than 0.5 hectare with trees taller than 5 metres and a canopy cover of more than 10 percent or trees able to reach these thresholds in situ. It excludes land predominantly under agricultural or urban land use, tree stands in agricultural production systems (for example, in fruit plantations and agroforestry systems) and trees in urban parks and gardens. Areas under reforestation that have not yet reached but are expected to reach a canopy cover of 10 percent and a tree height of 5 metres are included, as are temporarily unstocked areas resulting from human intervention or natural causes that are expected to regenerate.</li><li>fresh_water_withdrawl: Total fresh water withdrawn, expressed as a percentage of total renewable water resources.</li><li>natural_resource_reduction: Monetary valuation of energy, mineral and forest depletion, expressed as a percentage of gross national income (GNI).</li><li>air_pollution_deaths_per_100000: Age-standardized mortality rate resulting from exposure to ambient (outdoor) air pollution and household (indoor) air pollution from solid fuel use for cooking, expressed per 100,000 population. Ambient air pollution results from emissions from industrial activity, households, cars and trucks.”</li><li>water_related_deaths_per_100000: Mortality rate attributed to unsafe water, sanitation and hygiene services: Deaths attributable to unsafe water, sanitation and hygiene focusing on inadequate wash services, expressed per 100,000 population.</li><li>land_degradation: Rain fed cropland, irrigated cropland, or range, pasture, forest and woodlands that have experienced the reduction or loss of biological or economic productivity and complexity resulting from a combination of pressures, including land use and management practices.</li><li>red_list_index: Measure of the aggregate extinction risk across groups of species. It is based on genuine changes in the number of species in each category of extinction risk on the International Union for Conservation of Nature Red List of Threatened Species. It ranges from 0, all species categorized as extinct, to 1, all species categorized as least concern.</li><li>Pollution Index: Air quality score. Higher the score, worse is the air quality</li></ul><h3>Building the Self Organising maps model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhKpLibtEsqXywKxNSPUHg.png" /><figcaption>We will be using the minisom library developed by ‘JustGlowing’</figcaption></figure><h3>Visualising 2-D matrix</h3><p>‘SOM’ assigns each row to a node seperated by another node by a certain Euclidean Distance. So, we will plot heatmap of the Euclidean Distances to identify similar and dissimilar nodes. Higher the Euclidean Distance, larger is the dissimilarity between two nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*XlCSum8GX96sJkSgcnUYvw.png" /></figure><p>As we can see that the countries are classified and allocated a node on the basis of how similar they are.</p><h3>Results</h3><p>1. From Environmental Performance Index:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZxJ9d99T3BKsAHo_7BQvw.png" /></figure><p>2. From the model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tA8660zBLgXJTTg8e_qhlw.png" /></figure><p>As we can see that environmental performance is lowest among countries like India, Pakistan, Nigeria, Yemen, Saudi Arabia, Congo and other African countries. Countries like Canada, US, Brazil, Australia and West Europian countries are perfoming well on the sustainability index. We can compare the results wit the Environmental Performance Index we see that our model produces similar results.</p><h3>Conclusion</h3><p>India and neighbouring countries such as Pakistan, Bangladesh have huge populations that put pressure on the environment. Also, central and western African countries are know to have largest portion of the natural resources on the planet.</p><p>Sustainability is not a choice but a necessity. Governments across the world need to take drastic actions to reverse the environmental damage. If we are living in the countries low on the environmental performance index, we should take measures to lower our carbon footprint at individual level.</p><p>If you liked this article, please press clap. You can also find the source code on my <a href="https://github.com/ravidahiya74/Environmental-Sustainability">github</a> page.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d97ac5445ac9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/are-we-living-in-a-sustainable-world-using-deep-learning-som-to-find-answers-d97ac5445ac9">Are we living in a Sustainable World? Using Deep Learning (SOM)to find answers.</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Fake News Classifier & Deploying it Using Flask]]></title>
            <link>https://medium.com/analytics-vidhya/building-a-fake-news-classifier-deploying-it-using-flask-6aac31dfe31d?source=rss-807bc166bd5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aac31dfe31d</guid>
            <category><![CDATA[fake-news]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Ravi Dahiya]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 17:01:48 GMT</pubDate>
            <atom:updated>2019-12-16T08:55:56.409Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we begin, why not give the <a href="https://ravi-finds-fake-news.herokuapp.com/">fake news classification app</a> a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*bDH1Umntcfdlq5KD80kkCg.jpeg" /></figure><p>As a budding Data Scientists, we feel very proud to have worked on a problem and developed a model to solve it. We work through the tiring process of cleaning the data, visualising it, preparing it for the model and then going through the iterative process of developing &amp; improving the model.</p><p>It seems that most of the “Data Sciency Stuff” seems to have ended at this stage. So, what is beyond that?</p><p>That’s why you are here. We are going to learn to deploy our model and make it interactive. But before going forward, I want you to get familiar with the following:</p><ol><li><strong>Pickle:</strong> <em>“Pickling”</em> is the process whereby a Python object hierarchy is converted into a byte stream, and <em>“unpickling”</em> is the inverse operation, whereby a byte stream is converted back into an object hierarchy. For detailed information please go to official documentation <a href="https://docs.python.org/3/library/pickle.html">here</a>.</li><li><strong>Flask App: </strong>It is a Web Server Gateway Interface (WSGI) web application framework designed to create web apps. It is super convenient and the code is simple. Official Documents <a href="https://flask.palletsprojects.com/en/1.0.x/api/#flask.Flask">here</a>.</li><li><strong>Newspaper3k Library: </strong>Newspaper is an amazing python library for extracting &amp; curating articles. <a href="https://newspaper.readthedocs.io/en/latest/">Official documentation</a> explain it well.</li><li><strong>TF-IDF: </strong>Term Frequency-Inverse Document Frequency is a numerical statistic that is intended to reflect how important a word is to a document in a collection or corpus. Read about it <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf">here</a>.</li><li><strong>Multinomial Naive Bayes: </strong>It relies on Relies on very simple representation of document as a ‘Bag of words’. It estimates the conditional probability of a particular word given a class as the relative frequency of term t in documents belonging to class(c), in our case Fake or Real. A simple explanation on this <a href="https://web.stanford.edu/~jurafsky/slp3/slides/7_NB.pdf">link</a>.</li></ol><h3>Building the model</h3><p>Time to roll and target those fake news articles. First thing first, let’s build the model using the usual stuff. I am putting up the screenshot of the python file that will be used to deploy the model. I will not be able to explain the what’s going on in detail as our main focus is model deployment. Comments should be self-explainatory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PwqHhgQCHhMiPE70SD-OUQ.png" /><figcaption>Developing the News Classification Model</figcaption></figure><p>The model performs pretty well in detecting the fake news with 96% precision for Fake news and 78% for real news</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bh-JlahEryieQ-DH4LhYiw.png" /><figcaption>Classification report and confusion matrix</figcaption></figure><h3>Sweet !! Let’s make our web page using HTML</h3><p>For this, we have to make a new folder called ‘templates’ in our working directory and then creating new HTML file called ‘main.html’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNhN2Fx8mrgSKgz5RvJrOQ.png" /><figcaption>It takes url from the user and outputs the result on the page</figcaption></figure><h3>Time to make our Flask App</h3><p>Let’s make our flask app in a new python file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MXKV7yRDXYUgOaxainlKig.png" /></figure><p>Interesting thing to know is that we used ‘Newspaper3k’ library to extract the news article from the news url. It then feeds the article to the model and model returns whether the article is fake or real.</p><h3>The Magic</h3><p>Now we can simply run the file containing the flask app and it will give you a url on command prompt. Just copy and paste it in the browser. It will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4iABHatv4nZhFpovIEobA.png" /><figcaption>Just put in the url and click predict</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bfqlfr1MkKmoFg5XljUiZw.png" /><figcaption>‘Voila’ it works</figcaption></figure><h3>Let’s take this on the internet</h3><p>Well taking it online is pretty simple with heroku. We just need to add couple of extra files in our working directory. They mostly correspond to the libraries that heroku needs to import while building and deploying the app. Those are available on the <a href="https://www.heroku.com/">heroku website</a>. So, you just need to sign in, choose name of your app, connect your github repository and deploy. The steps and terminal commands are available on the website. At the end of the process the repository looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9RUChPJRl7mMxgOFlsJ1Q.png" /></figure><p>As soon as the model is deployed, heroku will give the name of the website on which the app is hosted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SsadEkoUj8vfQzyQc1pNNA.png" /><figcaption>Live app</figcaption></figure><p>That’s it !! We are done. So, in your next project, why not go beyond and create an app for the model that you have made.</p><p>All the files are available on my <a href="https://github.com/ravidahiya74/Fake-news-detection">github</a> repository. Please hit a clap if you learnt something new and let me know if you need any help in recreating this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aac31dfe31d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/building-a-fake-news-classifier-deploying-it-using-flask-6aac31dfe31d">Building a Fake News Classifier &amp; Deploying it Using Flask</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>