<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Boula Akladyous</title>
    <description>The latest articles on DEV Community by Boula Akladyous (@akladyous).</description>
    <link>https://dev.to/akladyous</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1144255%2Fbfa89545-ccac-4197-8e3b-7f81b038e698.png</url>
      <title>DEV Community: Boula Akladyous</title>
      <link>https://dev.to/akladyous</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akladyous"/>
    <language>en</language>
    <item>
      <title>EDR in Block Mode — Microsoft Defender for Endpoint Explained</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 20:20:15 +0000</pubDate>
      <link>https://dev.to/akladyous/why-cloud-security-matters-2p0k</link>
      <guid>https://dev.to/akladyous/why-cloud-security-matters-2p0k</guid>
      <description>&lt;p&gt;If you're studying for the SC-200 or just trying to wrap your head around Microsoft Defender for Endpoint, EDR in Block Mode is one of those features that&lt;br&gt;
sounds more complex than it actually is. Let's break it down — but before we get into what Block Mode does, we need to understand how EDR behaves in its normal&lt;br&gt;
state.&lt;/p&gt;
&lt;h4&gt;
  
  
  Normal EDR Mode
&lt;/h4&gt;

&lt;p&gt;In a typical setup, a device has Microsoft Defender Antivirus as its primary antivirus. Whenever MDE detects a threat, it communicates directly with Defender&lt;br&gt;
Antivirus, which then blocks and remediates it immediately. Simple, seamless, done — both products are Microsoft, so they speak the same language perfectly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Threat detected by MDE
        ↓
MDE signals Defender Antivirus
        ↓
Defender blocks and remediates
        ↓
Resolved ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Problem — When a 3rd Party AV is in Charge
&lt;/h4&gt;

&lt;p&gt;The problem arises in enterprise environments where organizations run a third-party antivirus like CrowdStrike, Symantec, or McAfee as their primary solution&lt;br&gt;
alongside MDE. In this scenario, when MDE detects something suspicious, it can't act on its own — it has to essentially "ask" the third-party AV to handle it.&lt;br&gt;
And if that AV misses the threat or handles it differently? It slips right through, even though MDE already saw it coming.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3rd party AV is primary (e.g. CrowdStrike)
        ↓
MDE detects a suspicious threat
        ↓
MDE has to rely on CrowdStrike to remediate
        ↓
CrowdStrike misses it or handles it differently
        ↓
Threat slips through ❌
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What EDR in Block Mode Does
&lt;/h4&gt;

&lt;p&gt;That's exactly the gap EDR in Block Mode was designed to close. It gives MDE a backstop role — even when it's not the primary antivirus, it can independently&lt;br&gt;
block and remediate anything the primary AV missed, without waiting for permission. Think of it as a silent safety net running in the background, catching&lt;br&gt;
whatever falls through the cracks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3rd party AV misses a threat
        ↓
MDE detects it running in the background
        ↓
EDR Block Mode kicks in — MDE acts independently
        ↓
MDE blocks and remediates on its own
        ↓
Resolved ✅ — no dependency on the 3rd party AV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bouncer analogy: Imagine a nightclub with two bouncers. Bouncer 1 (CrowdStrike) is the primary — checks everyone at the door. Bouncer 2 (MDE) watches inside&lt;br&gt;
the club. In normal mode, Bouncer 2 has to radio Bouncer 1 to act. In Block Mode, Bouncer 2 can step in immediately without waiting.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Enable EDR in Block Mode
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Go to the Microsoft Defender Portal&lt;/li&gt;
&lt;li&gt;Navigate to System → Settings → Endpoints → Advanced Features&lt;/li&gt;
&lt;li&gt;Scroll down to EDR in block mode and toggle it On&lt;/li&gt;
&lt;li&gt;Click Save preferences&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  Key Facts to Remember
&lt;/h4&gt;

&lt;p&gt;Detail Works whenMicrosoft Defender Antivirus is in passive mode (3rd party AV is primary)What it doesMDE independently blocks and remediates threats the&lt;br&gt;
primary AV missedRequiresMicrosoft Defender Antivirus must still be installed, even in passive modeLicenseMicrosoft Defender for Endpoint Plan 2Where to&lt;br&gt;
enableDefender Portal → Settings → Endpoints → Advanced Features → EDR in block mode&lt;/p&gt;

&lt;h4&gt;
  
  
  The One-Liner
&lt;/h4&gt;

&lt;p&gt;EDR in Block Mode = MDE acts as a backstop when a 3rd party antivirus is primary, catching and remediating anything it misses.&lt;/p&gt;

&lt;p&gt;Key References for this article:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/defender-endpoint/edr-in-block-mode" rel="noopener noreferrer"&gt;Endpoint detection and response in block mode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this article and that it helped make EDR in Block Mode a little clearer. Thanks for reading! 🙏❤️&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>defenderxdr</category>
      <category>mde</category>
    </item>
    <item>
      <title>Why Cloud Security Matters</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 20:11:50 +0000</pubDate>
      <link>https://dev.to/akladyous/why-cloud-security-matters-3d84</link>
      <guid>https://dev.to/akladyous/why-cloud-security-matters-3d84</guid>
      <description>&lt;h3&gt;
  
  
  Discover how MDC unifies security and cloud posture to identify vulnerabilities and protect workloads.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Here's What Microsoft Defender for Cloud Does About It
&lt;/h4&gt;

&lt;p&gt;If we ever wanted to connect the dots and have a comprehensive, unified platform to secure cloud environments while maintaining a healthy security posture for&lt;br&gt;
an organization, the challenge has always been fragmentation. The big cloud providers each came with their own recipe: their own tools, their own dashboards,&lt;br&gt;
their own definitions of what "secure" even means. Each one competing, each one claiming dominance.&lt;/p&gt;

&lt;p&gt;Microsoft did not just want to add another voice to that noise. They wanted to land with impact. So they built something that goes beyond a single cloud. A&lt;br&gt;
comprehensive platform that unifies the major security capabilities across clouds, giving organizations a single place to see, assess, and act.&lt;/p&gt;

&lt;p&gt;That platform is &lt;strong&gt;Microsoft Defender for Cloud&lt;/strong&gt;. At its core, it operates through three major security pillars, continuously discovering, evaluating, and&lt;br&gt;
prioritizing risk by comparing the actual state of your cloud resources against security best practices, compliance frameworks, and real-world attack logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three pillars
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cloud Security Posture Management (CSPM)&lt;/strong&gt; Think of CSPM as your cloud's health check — running continuously in the background. It scores your environment,&lt;br&gt;
maps out how an attacker could move through your infrastructure, and tells you exactly where you stand against compliance standards like NIST or ISO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development Security Operations (DevSecOps)&lt;/strong&gt; Security doesn't start when code hits production — it starts when a developer writes the first line. DevSecOps&lt;br&gt;
brings security into the pipeline early, catching misconfigurations in infrastructure templates, scanning container images for vulnerabilities, and flagging&lt;br&gt;
hardcoded secrets before they become a breach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud Workload Protection Platform (CWPP)&lt;/strong&gt; Once your workloads are live, CWPP is the watchdog. It monitors your virtual machines, Kubernetes clusters,&lt;br&gt;
databases, and serverless functions in real time — detecting threats, suspicious behavior, and active attacks the moment they happen, not after the damage is&lt;br&gt;
done.&lt;/p&gt;

&lt;p&gt;Together, these three pillars are not independent tools bolted together, they are a continuous loop. You assess your posture, secure your pipeline, and protect&lt;br&gt;
your live workloads. Each pillar feeds into the next, and that is what makes Defender for Cloud more than just a product. it is a security strategy.&lt;/p&gt;

&lt;p&gt;Hopefully this gave you a clear and honest picture of what the platform is, what it does, and why it matters. Cloud security is not a destination, it is an&lt;br&gt;
ongoing practice, and tools like this one make that practice a whole lot more manageable. If you found this useful, feel free to share it with someone who could&lt;br&gt;
benefit from it. And as always, questions, corrections, and discussions are very welcome in the comments.&lt;/p&gt;

&lt;p&gt;Key References for this article:&lt;/p&gt;

&lt;p&gt;Microsoft Defender for Cloud What is Cloud Security Posture Management (CSPM)&lt;/p&gt;

&lt;p&gt;Thanks for reading 🙏❤️&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>defenderxdr</category>
      <category>sentinel</category>
    </item>
    <item>
      <title>Mastering Incident Correlation in Microsoft Defender XDR</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 20:05:03 +0000</pubDate>
      <link>https://dev.to/akladyous/mastering-incident-correlation-in-microsoft-defender-xdr-48nl</link>
      <guid>https://dev.to/akladyous/mastering-incident-correlation-in-microsoft-defender-xdr-48nl</guid>
      <description>&lt;p&gt;In modern Security Operations Centers (SOCs), the sheer volume of telemetry can lead to alert fatigue, where critical security signals are lost in the noise.&lt;br&gt;
Microsoft Defender XDR is designed to combat this by transforming isolated alerts into cohesive, actionable incidents. It ships with advanced features that&lt;br&gt;
provide a full set of customizations, allowing you to control how you handle alerts and how the system correlates them based on shared entities, artifacts, and&lt;br&gt;
attack behaviors.&lt;/p&gt;

&lt;p&gt;How the Engine Decides What Belongs Together At its core, the Defender correlation engine is designed to minimize manual triage. When alerts hit your&lt;br&gt;
environment, the system doesn’t just log them; it analyzes them for relationships.&lt;/p&gt;

&lt;p&gt;Whether it is shared entities like compromised user accounts, specific devices, or artifacts like identical malicious file hashes, the engine groups these&lt;br&gt;
alerts into a single incident context. This transition from "isolated alerts" to "actionable incidents" is what allows us to see the bigger picture of an attack&lt;br&gt;
progression rather than chasing individual alerts.&lt;/p&gt;

&lt;p&gt;The Defender XDR correlation engine works by continuously analyzing alerts from various workloads—including endpoints, identities, email, and cloud apps—to&lt;br&gt;
identify relationships.&lt;/p&gt;

&lt;p&gt;Entity Mapping: The system maps alerts to shared entities such as users, devices, mailboxes, and IP addresses. If multiple alerts share these entities, they are&lt;br&gt;
logically grouped together.&lt;/p&gt;

&lt;p&gt;Artifact Correlation: Beyond just entities, the engine identifies links via shared artifacts like malicious file hashes, process names, or URL patterns.&lt;/p&gt;

&lt;p&gt;Dynamic Grouping: As new alerts arrive, the engine checks them against existing incidents. If a high degree of similarity is found, the new alert is&lt;br&gt;
automatically appended to an existing incident rather than creating a duplicate, ensuring the attack story remains centralized.&lt;/p&gt;

&lt;p&gt;Conditions for Incident Correlation While the process is highly automated, there are specific conditions that govern when the engine will (or will not) merge&lt;br&gt;
incidents:&lt;/p&gt;

&lt;p&gt;Incident Status: The engine will not merge incidents if the target incident is already marked as "Closed." It will not reopen closed cases for merging purposes.&lt;/p&gt;

&lt;p&gt;Analyst Assignment: To avoid confusion or conflicting actions, the system does not automatically merge two incidents if they are currently assigned to different&lt;br&gt;
people.&lt;/p&gt;

&lt;p&gt;Classification Integrity: The engine avoids merging incidents with conflicting classifications (e.g., trying to merge a "Benign Positive" with a "True&lt;br&gt;
Positive"). This ensures that your reporting and data analytics remain accurate.&lt;/p&gt;

&lt;p&gt;Entity &amp;amp; Complexity Limits: To maintain performance and manageability, the system has safety limits on the number of entities allowed per incident. It will not&lt;br&gt;
merge if doing so would exceed these thresholds.&lt;/p&gt;

&lt;p&gt;Device Group Boundaries: The engine respects your infrastructure hierarchy; incidents containing devices from different device groups are not merged.&lt;/p&gt;

&lt;p&gt;Use Cases Understanding these capabilities allows you to use Defender XDR more effectively in real-world scenarios:&lt;/p&gt;

&lt;p&gt;Multi-Stage Campaign Detection: Defender can correlate an initial phishing email alert (Defender for Office 365) with a subsequent credential access attempt&lt;br&gt;
(Defender for Identity) and a later process injection (Defender for Endpoint). By grouping these, the analyst sees the full attack progression in one place.&lt;/p&gt;

&lt;p&gt;Unified Insider Risk: You can view alerts from Microsoft Purview Insider Risk Management alongside Defender workload alerts. If a user exhibits risky behavior&lt;br&gt;
that matches suspicious technical activity, the correlation provides a holistic view of the users threat level.&lt;/p&gt;

&lt;p&gt;Blast Radius Analysis: By investigating the correlated incident, you can use the blast radius graph to instantly see the compromised components and the&lt;br&gt;
potential path an attacker took across your hybrid or cloud infrastructure.&lt;/p&gt;

&lt;p&gt;By mastering these correlation features, you move from reactive alert chasing to proactive incident investigation, allowing your team to respond with speed and&lt;br&gt;
precision.&lt;/p&gt;

&lt;p&gt;A Note for SC-200 Candidates&lt;/p&gt;

&lt;p&gt;If you are currently on the path to the Microsoft SC-200 (Security Operations Analyst) certification, keep in mind that understanding incident correlation is&lt;br&gt;
only half the battle. To master the Manage a security operations environment domain (40–45% of the exam), you must have hands-on experience configuring&lt;br&gt;
Microsoft Defender for Endpoint Advanced Features.&lt;/p&gt;

&lt;p&gt;Under “Manage a security operations environment (40–45%)”, candidates are expected to have hands-on skills to:&lt;/p&gt;

&lt;p&gt;Configure Microsoft Defender for Endpoint advanced features, including the ability to investigate and respond to security incidents using the Microsoft Defender&lt;br&gt;
portal.&lt;/p&gt;

&lt;p&gt;Key References for this article:&lt;/p&gt;

&lt;p&gt;Investigate incidents in the Microsoft Defender portal&lt;/p&gt;

&lt;p&gt;Alert correlation and incident merging in the Microsoft Defender portal&lt;/p&gt;

&lt;p&gt;Thanks for reading 🙏❤️&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>defenderxdr</category>
      <category>sentinel</category>
    </item>
    <item>
      <title>Web scraping — News Articles using NewsAPI.org</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:32:30 +0000</pubDate>
      <link>https://dev.to/akladyous/web-scraping-news-articles-using-newsapiorg-2435</link>
      <guid>https://dev.to/akladyous/web-scraping-news-articles-using-newsapiorg-2435</guid>
      <description>&lt;h2&gt;
  
  
  Unlocking the Power of Web Scraping for Data Collection and Analysis
&lt;/h2&gt;

&lt;p&gt;Web Scraping is a technique employed to gather large amounts of data from websites whereby the data is extracted and stored into a structured format. such&lt;br&gt;
technique is widely used for a range of purposes, including market analysis, machine learning, news tracking and financial data aggregation. The ability of web&lt;br&gt;
scraping is an important skill for any data scientist to have in their set.&lt;/p&gt;

&lt;p&gt;There are many different approaches for getting data from the web such as writing a custom crawler from scratch, or by using one of the many existing libraries&lt;br&gt;
that make it absolutely easy to create a web scraping tool in Python.&lt;/p&gt;

&lt;p&gt;In this Python tutorial we will go through a simple example of how to scrap a website to gather news articles and create simple applications using NEWSAPI&lt;br&gt;
library.&lt;/p&gt;

&lt;p&gt;Most of the libraries for gathering information are Python standard, with the exception of the Pandas and NewsApi libraries accessible via installation and free&lt;br&gt;
registration on the official websites.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Get API key&lt;/p&gt;

&lt;p&gt;Firstly, get the API key by registering on the News API web page. Be sure to register as an individual. This will grant the free usage of the API. Click Here&lt;br&gt;
and fill out the form. The API key should be in your inbox shorty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;API Key Note that in order to interact with the API, it is mandatory to provide the API key.&lt;/p&gt;

&lt;p&gt;There are two ways to do that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using API key in the request URL&lt;/strong&gt;: Include the API key as a query parameter in the URL when making requests.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://newsapi.org/v2/everything?q=bitcoin&amp;amp;apiKey=YOUR_API_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using the NewsApiClient library&lt;/strong&gt;: Initialize the client with your API key (requires installing the &lt;code&gt;newsapi-python&lt;/code&gt; package).&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;newsapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;NewsApiClient&lt;/span&gt;
&lt;span class="n"&gt;newsapi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NewsApiClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;YOUR_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Headers
&lt;/h2&gt;

&lt;p&gt;we create a dictionary to store our API key, we include it in the header of the “requests”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Create a variable to hold the API key
&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cd23a40b7a0d44cb99af86eeb31869eb&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API Endpoint
&lt;/h2&gt;

&lt;p&gt;News API has 2 main endpoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Everything&lt;/strong&gt; /v2/everything – search every article published by over 75,000 different sources large and small in the last 3 years. This endpoint is ideal
for news analysis and article discovery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Top headlines&lt;/strong&gt; /v2/top-headlines – returns breaking news headlines for countries, categories, and singular publishers. This is perfect for use with news
tickers or anywhere you want to display live up-to-date news headlines.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# create 2 variables to hold the API endpoints.
&lt;/span&gt;&lt;span class="n"&gt;everything&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://newsapi.org/v2/everything?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;top_headlines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://newsapi.org/v2/top-headlines?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API Keywords
&lt;/h2&gt;

&lt;p&gt;Keywords or a phrase to search for.&lt;/p&gt;

&lt;p&gt;the parameter ‘q’ stands for the keyword search value. The news articles matching the keyword search are returned as a response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# in our tutorial we look for news related to Apple
&lt;/span&gt;&lt;span class="n"&gt;symbols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;apple&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API Sources
&lt;/h2&gt;

&lt;p&gt;A comma-seperated string of identifiers for the news sources or blogs you want headlines from.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;abc-news&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;business-insider&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;financial-post&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;google-news&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;reuters&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;nbc-news&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;techcrunch&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;the-wall-street-journal&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API sortBy
&lt;/h2&gt;

&lt;p&gt;The ‘sortBy’ parameter contains the option that applies to the returned articles. Based on this value, the articles are sorted in the response&lt;/p&gt;

&lt;p&gt;Possible options: [relevancy, popularity, publishedAt].&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sorby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;popularity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Payloads
&lt;/h2&gt;

&lt;p&gt;Next step is to create different payloads that need to be sent to the API. The payload is nothing more than some information that needs to be sent to the API.&lt;br&gt;
The payload can include information such as news category, country, language, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;q&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;keywords&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;apiKey&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sortBy&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sorby&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;language&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;en&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;page&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Requests API
&lt;/h2&gt;

&lt;p&gt;Make the request using the get() method of the requests library.&lt;/p&gt;

&lt;p&gt;Make the request using the get() method of the requests library. we’re going to pass ony 2 parameters, first the ‘url’ parameter, specify the NewsAPI endpoint,&lt;br&gt;
and lastly pass the payloads dictionary to the ‘params’ parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;top_headlines&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The structure of the “requests” remains the same throughout, we can update the parameters “url” and “params” parameter in order to gather diffrent type of news.&lt;/p&gt;

&lt;h2&gt;
  
  
  Response
&lt;/h2&gt;

&lt;p&gt;Create a viariable to hold the the “response” in dictionary format&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Print out the response on the console by accessing the method “json”, since it already data formated by NewsAPI library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ok&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;totalResults&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;articles&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rappler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;author&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rappler.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Jollibee introduces new sweet chili chicken - Rappler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Jollibee&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s fried chicken is coated in a sweet-spicy chili glaze&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.rappler.com/life-and-style/food-drinks/jollibee-sweet-chili-chicken&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;urlToImage&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://assets2.rappler.com/2021/06/1-1623468746894.jpg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;publishedAt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2021-06-12T03:39:00Z&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Jollibee&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s new limited edition item can be ordered for dine-in, take-out, drive-thru, or delivery via the Jollibee Delivery app, website, hotline number, GrabFood, and foodpanda. Rappler.com&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rappler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;author&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Reuters&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;title&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hong Kong democracy activist Agnes Chow released from prison - Rappler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;(1st UPDATE) Agnes Chow serves nearly seven months in prison for her role in an unauthorized assembly during Hong Kong&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s 2019 anti-government protests&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.rappler.com/world/asia-pacific/hong-kong-democracy-activist-agnes-chow-released&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;urlToImage&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://assets2.rappler.com/2021/06/Agnes-Chow-Wikimedia-June-12-2021-1623465814534.jpeg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;publishedAt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2021-06-12T02:45:00Z&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hong Kong pro-democracy activist Agnes Chow was released from prison on Saturday, June 12, after serving nearly seven months for her role in an unauthorized assembly during anti-government protests i&lt;/span&gt;&lt;span class="se"&gt;\u2026&lt;/span&gt;&lt;span class="s"&gt; [+18 chars]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Save Resonse to CSV
&lt;/h2&gt;

&lt;p&gt;In order to create a dataframe with the result obtained, we must access the dictionary values using the “articles” key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="nf"&gt;dict_keys&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;totalResults&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;articles&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a variable to hold the articles information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;articles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;articles&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using “pandas” we create a dataframe using the method “DataFrame” passing parameter “data” with the articles variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5in5ms8xfihw766i7f6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5in5ms8xfihw766i7f6.png" alt="blog image" width="720" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find my Jupyter Notebook for this on my Github.&lt;/p&gt;

&lt;p&gt;Thanks for reading and happy web scraping everyone! ❤️&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>Understanding Scopes in Rails</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:23:02 +0000</pubDate>
      <link>https://dev.to/akladyous/understanding-scopes-in-rails-5g32</link>
      <guid>https://dev.to/akladyous/understanding-scopes-in-rails-5g32</guid>
      <description>&lt;h2&gt;
  
  
  Understanding Rails Scopes and Class Methods for Efficient Database Queries
&lt;/h2&gt;

&lt;p&gt;Scopes in Rails are special methods to run SQL queries that you can build in any rails model. A scope will always return an ActiveRecord::Relation object, even&lt;br&gt;
if the conditional evaluates to false , whereas a class method, will return nil. we frequently run similar queries in our rails console to query our database&lt;br&gt;
and also understand the structure of the result we are receiving before going further with the development of our applications.&lt;/p&gt;

&lt;p&gt;Why use Scopes? &amp;amp; why is it useful&lt;/p&gt;

&lt;p&gt;A use case for scopes is often for filtering by status, date, date ranges, ordering, groupings, and more. Compared to class methods, scope methods are&lt;br&gt;
incredibly fast and quite easy to return the desired result in fraction of time.&lt;/p&gt;

&lt;p&gt;Scopes help you D.R.Y out your active record calls and also keep your codes organized. Scopes make it easy to find the records you need at a particular time.&lt;/p&gt;

&lt;p&gt;Lets start with the basic, We’ll use a sample model named Book to illustrate what scopes allow you to do.&lt;/p&gt;

&lt;p&gt;On your homepage, you only want to show published books of course. So in your action, you would use the following code to ensure that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Class&lt;/span&gt; &lt;span class="nx"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;ActiveRecord&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&gt;Base&lt;/span&gt;
  &lt;span class="nx"&gt;scope&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;published&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(:&lt;/span&gt;&lt;span class="nx"&gt;published&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  This retuns ActiveRecord::Relation object
&lt;/h1&gt;

&lt;p&gt;Then in our controller or views, we can return the newly scoped objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BooksController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationContrpller&lt;/span&gt;
 &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;
   &lt;span class="vi"&gt;@books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;
 &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Taking arguments.&lt;/p&gt;

&lt;p&gt;scopes can also receive parameters, let’s see how we can create a scope to get all books written by a specific author.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
 &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="ss"&gt;:author_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:authorName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using conditional with scopes.&lt;/p&gt;

&lt;p&gt;The scope named available, in the code block is a typical example of how to use conditional with scopes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
 &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="ss"&gt;:available&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"available = ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;present?&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Chaining&lt;/p&gt;

&lt;p&gt;Scopes are extremely powerful due to their ability to be chained together. Think of them as a chain links&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BooksController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationContrpller&lt;/span&gt;
 &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;
   &lt;span class="c1"&gt;# return all available &amp;amp; published books.&lt;/span&gt;
   &lt;span class="vi"&gt;@books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;available&lt;/span&gt;
 &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Summary&lt;/p&gt;

&lt;p&gt;It’s always a good idea to use scopes for selecting, sorting, joining or filtering data through your database, and then you can use class methods to chain those&lt;br&gt;
scopes, or even write more complex logic.&lt;/p&gt;

&lt;p&gt;This is very important to note that the scope is intended to return an ActiveRecord::Relation object which is composable with other scopes. In short scopes&lt;br&gt;
should be chainable.&lt;/p&gt;

&lt;p&gt;Hope this article helped you understand the ActiveRecord Scoping method and its uses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@akladyous/ruby-on-rails-scopes-35e3565d8d79" rel="noopener noreferrer"&gt;Explore in Depth by Sharing this Post 📤&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>rails</category>
      <category>activemodel</category>
      <category>backend</category>
    </item>
    <item>
      <title>Understanding Coefficient of Variation</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:16:57 +0000</pubDate>
      <link>https://dev.to/akladyous/understanding-coefficient-of-variation-3pe6</link>
      <guid>https://dev.to/akladyous/understanding-coefficient-of-variation-3pe6</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Coefficient of Variation (CV): A Comprehensive Guide
&lt;/h1&gt;

&lt;p&gt;In the realm of data analysis, various statistical measures assist in unraveling the nature of datasets. Variability, denoting the extent to which data points&lt;br&gt;
in a dataset differ, holds a paramount role in data analysis. Measuring variability aids in comprehending the dispersion or clustering of data, facilitating&lt;br&gt;
informed decision-making, prediction, and pattern identification.&lt;/p&gt;

&lt;p&gt;Several measures of variability exist, each with distinct strengths and weaknesses. Commonly used ones include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Range:&lt;/strong&gt; The simplest measure, calculated by subtracting the smallest from the largest value in the dataset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interquartile Range (IQR):&lt;/strong&gt; A more robust measure less sensitive to outliers, obtained by subtracting the first quartile from the third quartile.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Variance:&lt;/strong&gt; Indicates how much data deviates from the mean, calculated by summing squared differences between each data point and the mean.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Standard Deviation:&lt;/strong&gt; The square root of variance, a widely used measure conveying average deviation from the mean.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding variability is pivotal for making sense of data, enabling insights into dataset characteristics for more informed decision-making.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Coefficient of Variation (CV)?
&lt;/h2&gt;

&lt;p&gt;Variability assessment is crucial in statistics, referring to the degree of dispersion or spread in a dataset. The Coefficient of Variation (CV) emerges as one&lt;br&gt;
such measure, representing the ratio of standard deviation to the mean. Often expressed as a percentage, CV facilitates comparing variation between different&lt;br&gt;
datasets. Widely applied in finance, biology, and engineering, CV aids in gauging risk or uncertainty within datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points about Coefficient of Variation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Formula:&lt;/strong&gt; CV = (Standard Deviation / Mean) x 100%. It gauges the relative variability of a dataset, expressed as a percentage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comparative Analysis:&lt;/strong&gt; Used to compare variability across datasets with different units, aiding decisions in various fields.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Risk Assessment:&lt;/strong&gt; Valuable in finance for evaluating investment risk. Higher CV suggests higher risk and volatility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reliability Assessment:&lt;/strong&gt; Applied to assess the reliability of measurement tools, such as blood glucose monitors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interpretation:&lt;/strong&gt; A lower CV signifies a more consistent dataset, while a higher CV implies greater variability. Interpretation context varies with the&lt;br&gt;
dataset and field of study.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Calculating Coefficient of Variation
&lt;/h2&gt;

&lt;p&gt;In measuring variability, the Coefficient of Variation (CV) stands out as a versatile statistical tool widely employed in finance, biology, and engineering. As&lt;br&gt;
a relative measure, CV represents standard deviation as a percentage of the mean, offering a robust means to compare datasets with different units or means.&lt;br&gt;
Let's delve into how to calculate CV, providing insights into its interpretation and application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Formula for Calculating CV:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CV = (Standard Deviation / Mean) x 100%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Consider daily stock returns over ten days: 1.2%, -0.5%, 0.8%, -1.1%, 2.3%, 0.9%, -2.0%, -0.7%, 1.5%, 0.3%. Mean return = 0.34%, Standard&lt;br&gt;
Deviation = 1.48%, CV = (1.48 / 0.34) x 100% = 435.29%.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interpretation of CV:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low CV (&amp;lt; 15%): Low variability.&lt;/li&gt;
&lt;li&gt;Moderate CV (15% - 30%): Moderate variability.&lt;/li&gt;
&lt;li&gt;High CV (&amp;gt; 30%): High variability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interpretation varies by field; e.g., in finance, CV &amp;lt; 30% may be considered low.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Application of CV:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finance: Measures risk and volatility.&lt;/li&gt;
&lt;li&gt;Biology: Gauges variability in biological traits.&lt;/li&gt;
&lt;li&gt;Engineering: Assesses manufacturing process variability.&lt;/li&gt;
&lt;li&gt;Medicine: Evaluates variability in medical test results.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  4. Interpreting Coefficient of Variation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Coefficient of Variation
&lt;/h3&gt;

&lt;p&gt;The Coefficient of Variation (CV) serves as a dimensionless metric to measure the relative variability of data. Its interpretation is pivotal, offering insights&lt;br&gt;
into data consistency and reliability. Widely used in finance, engineering, and biology, understanding how to interpret CV is crucial for informed&lt;br&gt;
decision-making.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ways to Interpret CV:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low CV:&lt;/strong&gt; Indicates tightly clustered data points around the mean, suggesting consistency and reliability. Useful in contexts like test score reliability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;High CV:&lt;/strong&gt; Signifies widely dispersed data points, indicating lower consistency and reliability. Relevant in scenarios such as salary distribution&lt;br&gt;
analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comparing CVs:&lt;/strong&gt; Facilitates insights into relative variability between datasets. Useful in identifying higher variability in one group over another.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Interpreting CV is essential for understanding&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>statistics</category>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>Single Page Application (SPA) WorkFlow</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:11:47 +0000</pubDate>
      <link>https://dev.to/akladyous/single-page-application-spa-workflow-jk5</link>
      <guid>https://dev.to/akladyous/single-page-application-spa-workflow-jk5</guid>
      <description>&lt;p&gt;Let’s explain how we'd build the same todo application as a Single Page Application (SPA) using React.js, focusing on data and state management. Let's start&lt;br&gt;
with a high-level overview and then dive into the details.&lt;/p&gt;

&lt;p&gt;First, let's visualize the structure of our React SPA todo app:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;graph TD
    A[App Component] --&amp;gt; B[TodoList Component]
    A --&amp;gt; C[AddTodo Component]
    B --&amp;gt; D[TodoItem Component]
    D --&amp;gt; E[Edit Todo]
    D --&amp;gt; F[Delete Todo]
    D --&amp;gt; G[Toggle Complete]

    H[State Management] --&amp;gt; A
    H --&amp;gt; B
    H --&amp;gt; C
    H --&amp;gt; D&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In this React SPA structure, we have a main App component that contains child components for different parts of our application. The key difference from the MPA&lt;br&gt;
version is that all of these components exist within a single page, and React manages the rendering and updating of these components based on user interactions&lt;br&gt;
and state changes.&lt;/p&gt;

&lt;p&gt;Now, let's talk about data flow and state management in this React SPA:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State Management&lt;/strong&gt;: In React, we typically keep the state at the highest necessary level and pass it down to child components as props. For a simple app,
we might keep all state in the App component. For more complex apps, we might use a state management library like Redux or Recoil.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Storage&lt;/strong&gt;: Unlike the MPA where data was primarily stored on the server, in an SPA we keep a copy of the data in the client-side state. We still
persist data to a server via API calls, but the immediate source of truth for the UI is the client-side state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CRUD Operations&lt;/strong&gt;: These are typically handled by updating the client-side state and making asynchronous API calls to sync with the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's walk through a typical workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initial Load:

&lt;ul&gt;
&lt;li&gt;React app loads and mounts the App component&lt;/li&gt;
&lt;li&gt;App component fetches todos from the server (e.g., via a REST API)&lt;/li&gt;
&lt;li&gt;State is updated with the fetched todos, causing a re-render&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add Todo:

&lt;ul&gt;
&lt;li&gt;User inputs new todo in AddTodo component&lt;/li&gt;
&lt;li&gt;On submit, state is updated with new todo&lt;/li&gt;
&lt;li&gt;An API call is made to add the todo on the server&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Edit Todo:

&lt;ul&gt;
&lt;li&gt;User clicks edit on a TodoItem&lt;/li&gt;
&lt;li&gt;TodoItem switches to edit mode (managed by local state)&lt;/li&gt;
&lt;li&gt;On save, parent state is updated and an API call is made&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Delete Todo:

&lt;ul&gt;
&lt;li&gt;User clicks delete on a TodoItem&lt;/li&gt;
&lt;li&gt;Todo is removed from state, causing an immediate UI update&lt;/li&gt;
&lt;li&gt;An API call is made to delete the todo on the server&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Toggle Complete:

&lt;ul&gt;
&lt;li&gt;User clicks to toggle todo status&lt;/li&gt;
&lt;li&gt;State is immediately updated, reflecting the change in the UI&lt;/li&gt;
&lt;li&gt;An API call is made to update the status on the server&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let's look at a simplified code example for our main App component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;TodoList&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./TodoList&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;AddTodo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./AddTodo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;addTodo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateTodo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;deleteTodo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;

    &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleAddTodo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newTodo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="nf"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;([...&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="nf"&gt;addTodo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleToggle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;todoToUpdate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nf"&gt;updateTodo&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;todoToUpdate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;todoToUpdate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleDelete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;setTodos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="nf"&gt;deleteTodo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;My Todos&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AddTodo&lt;/span&gt; &lt;span class="na"&gt;onAdd&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleAddTodo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;TodoList&lt;/span&gt; &lt;span class="na"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onToggle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleToggle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onDelete&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleDelete&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this React example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We use the &lt;code&gt;useState&lt;/code&gt; hook to manage our todos state.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useEffect&lt;/code&gt; is used to fetch todos when the component mounts.&lt;/li&gt;
&lt;li&gt;CRUD operations are handled by functions that update the state and make API calls.&lt;/li&gt;
&lt;li&gt;The UI automatically updates when the state changes, thanks to React's reactivity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The key differences from the MPA approach are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Single Page&lt;/strong&gt;: Everything happens within a single page load. React handles updating the UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client-Side State&lt;/strong&gt;: The immediate source of truth is the client-side state, not the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous Updates&lt;/strong&gt;: API calls happen asynchronously, allowing for immediate UI updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component Structure&lt;/strong&gt;: The UI is broken down into reusable components.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach provides a more fluid user experience, as most interactions don't require a full page reload. However, it also means we need to carefully manage&lt;br&gt;
state and keep it in sync with the server.&lt;/p&gt;

&lt;p&gt;Is this helpful in understanding the SPA approach? Would you like me to elaborate on any specific part of this workflow or dive deeper into how React manages&lt;br&gt;
updates?&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Sentiment Analysis using VADER</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:08:43 +0000</pubDate>
      <link>https://dev.to/akladyous/sentiment-analysis-using-vader-2la1</link>
      <guid>https://dev.to/akladyous/sentiment-analysis-using-vader-2la1</guid>
      <description>&lt;h2&gt;
  
  
  Understanding Sentiment Analysis in Natural Language Processing
&lt;/h2&gt;

&lt;p&gt;Sentiment Analysis is a supervised Machine Learning technique used to determine if a chunk of text is positive, negative or neutral. In text analytics, natural&lt;br&gt;
language processing (NLP) and machine learning (ML) techniques are combined to assign sentiment scores to topics, categories or entities within a phrase.&lt;/p&gt;

&lt;p&gt;Sentiment analysis is a powerful tool that businesses can leverage to better understand the overall opinions of their customer, gain insights and make&lt;br&gt;
data-driven decisions.&lt;/p&gt;

&lt;p&gt;In this tutorial we will classify text articles using VADER on a dataset from CrowdFlower&lt;/p&gt;
&lt;h2&gt;
  
  
  Import Libraries
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;nltk&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;nltk.corpus&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stopwords&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;nltk.probability&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FreqDist&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;nltk.tokenize&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sent_tokenize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;RegexpTokenizer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;nltk.sentiment.vader&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SentimentIntensityAnalyzer&lt;/span&gt;
&lt;span class="n"&gt;nltk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;stopwords&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;nltk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;vader_lexicon&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;nltk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;punkt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Data Collection
&lt;/h2&gt;

&lt;p&gt;For the sake of this tutorial we’re going to use a simple dataset from CrowdFlower via data.world (IMDB Sentiment Sampled).&lt;/p&gt;

&lt;p&gt;For more info visit the link: | &lt;a href="https://data.world/robbertb/imdb-sentiment-sampled" rel="noopener noreferrer"&gt;https://data.world/robbertb/imdb-sentiment-sampled&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Preprocessing
&lt;/h2&gt;

&lt;p&gt;The NLTK module is a massive tool kit, aimed to help you with the entire Natural Language Processing (NLP) methodology.&lt;/p&gt;

&lt;p&gt;NLTK will aid you with everything from splitting sentences from paragraphs, splitting up words, recognizing the part of speech of those words.&lt;/p&gt;

&lt;p&gt;In order to apply polarity score we need to prepare your data, we start by the converting our data to lowercase using the built-in function “lower”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing stop word using NLTK by downloading the english stopwords.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;stop_words&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;stopwords&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;english&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stop_words&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sentences Tokenization&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;sent_tokenize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Join the tokenized data into text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Vader
&lt;/h2&gt;

&lt;p&gt;VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed&lt;br&gt;
in social media.&lt;/p&gt;

&lt;p&gt;It is used for sentiment analysis of text which has both the polarities i.e. positive/negative. VADER is also used to quantify how much positive or negative&lt;br&gt;
emotion the text has and also the intensity of emotion.&lt;/p&gt;
&lt;h2&gt;
  
  
  Polarity classification
&lt;/h2&gt;

&lt;p&gt;The VADER library returns 4 values such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pos: The probability of the sentiment to be positive&lt;/li&gt;
&lt;li&gt;neu: The probability of the sentiment to be neutral&lt;/li&gt;
&lt;li&gt;neg: The probability of the sentiment to be negative&lt;/li&gt;
&lt;li&gt;compound: The normalized compound score which calculates the sum of all lexicon ratings and takes values from -1 to 1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice that the pos, neu and neg probabilities add up to 1. Also, the compound score is a very useful metric in case we want a single measure of sentiment.&lt;br&gt;
Typical threshold values are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;positive: compound score ≥ 0.05&lt;/li&gt;
&lt;li&gt;neutral: compound score between -0.05 and 0.05&lt;/li&gt;
&lt;li&gt;negative: compound score ≤ -0.05&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instantiate a new object with NLTK SentimentIntensityAnalyzer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SentimentIntensityAnalyzer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can create a new column to the original DataFrame to store the polarity_scores dictionary, the scores extracted will have the keys “neg”, “neu”, “pos”,&lt;br&gt;
“compound” derived from the composite score.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;review&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;polarity_scores&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fye3vs6k4hm0u4htr6xw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fye3vs6k4hm0u4htr6xw6.png" alt="data frame" width="720" height="198"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;negative&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;neg&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;neutral&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;neu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;positive&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pos&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;compound&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;compound&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsenfdzl01n12h3piuurg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsenfdzl01n12h3piuurg.png" alt="data frame" width="720" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will follow by creating a function called “polarity_score” to calculate the accuracy test for each review in our dataframe. We can finally apply the function&lt;br&gt;
by creating a new column called “sentiment”.&lt;/p&gt;

&lt;p&gt;The reviews in this column will be classified into positive, negative and neutral.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;polarity_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compound&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;compound&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;positive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;compound&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;negative&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;compound&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.05&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;compound&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;neutral&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sentiment&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;compound&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;polarity_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;head&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk42sd34vknjochi0y4h8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk42sd34vknjochi0y4h8.png" alt="data frame" width="720" height="123"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sentiment&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;value_counts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;VADER classifies the sentiments very well. It is easy to use, the ready-made model which can be used across multiple domains, social-media texts.&lt;/p&gt;

&lt;p&gt;Thanks for reading and happy web scraping everyone!&lt;/p&gt;

&lt;p&gt;You can find my Jupyter Notebook for this on my Github.&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>nlp</category>
      <category>ai</category>
    </item>
    <item>
      <title>React Fiber</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:04:05 +0000</pubDate>
      <link>https://dev.to/akladyous/react-fiber-59nb</link>
      <guid>https://dev.to/akladyous/react-fiber-59nb</guid>
      <description>&lt;h1&gt;
  
  
  An Overview of Fiber Trees and Reconciliation
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Unlocking the Power of Web Scraping for Data Collection and Analysis
&lt;/h2&gt;

&lt;p&gt;React Fiber is a revolutionary feature in the React library that aims to significantly enhance the performance and rendering efficiency of React applications.&lt;br&gt;
At the heart of Fiber lies the reconciliation process, a powerful mechanism that efficiently updates the user interface based on changes in application state.&lt;br&gt;
In this blog, we will delve into the concept of Fiber trees and explore how the reconciliation process works.&lt;/p&gt;
&lt;h2&gt;
  
  
  Reconciliation Stack
&lt;/h2&gt;

&lt;p&gt;Before the release of React 16, React employed a stack-based reconciliation algorithm known as the "stack reconciler" to compare the old and new virtual trees&lt;br&gt;
and update the DOM accordingly. While suitable for simpler scenarios, the stack reconciler faced challenges as applications grew in complexity.&lt;/p&gt;

&lt;p&gt;The synchronous nature of the stack reconciler caused updates to block the main thread, leading to janky and unresponsive user interfaces, especially with large&lt;br&gt;
virtual trees or slower devices. Additionally, changes to the virtual tree were delayed until the reconciler completed its work, affecting overall performance&lt;br&gt;
and responsiveness.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Fiber Reconciler
&lt;/h2&gt;

&lt;p&gt;To address these challenges and improve React's performance, React 16 introduced the Fiber reconciler, a complete rewrite of the previous stack-based algorithm&lt;br&gt;
with several significant benefits.&lt;/p&gt;
&lt;h2&gt;
  
  
  How React Fiber Works
&lt;/h2&gt;

&lt;p&gt;When a React application undergoes an update triggered by user interactions or events, the reconciliation process is initiated. Its goal is to efficiently&lt;br&gt;
determine the parts of the user interface that require updating and apply these changes to the real DOM.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;Fiber Trees - Current and Work in Progress&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;The reconciliation process involves two sets of virtual DOM trees: the "current" tree and the "work in progress" tree, also known as the Fiber tree. The&lt;br&gt;
"current" tree represents the existing state of the virtual DOM, while the "work in progress" tree is a replica that incorporates the updates to be performed.&lt;/p&gt;
&lt;h2&gt;
  
  
  Render Phase
&lt;/h2&gt;

&lt;p&gt;The reconciliation process begins with the render phase, where React traverses the component tree and creates fiber nodes, special data structures representing&lt;br&gt;
different portions of the virtual DOM.&lt;/p&gt;

&lt;p&gt;During the render phase, React compares the fiber nodes in the "current" and "work in progress" trees to identify parts of the virtual DOM requiring updates.&lt;br&gt;
Leveraging a work loop, React breaks rendering work into smaller units that can be interrupted and resumed, prioritizing important updates to maintain a&lt;br&gt;
responsive user interface.&lt;/p&gt;
&lt;h2&gt;
  
  
  Commit Phase
&lt;/h2&gt;

&lt;p&gt;After completing the render phase and applying the necessary updates to the "work in progress" tree, React enters the commit phase. Here, React takes the&lt;br&gt;
updates from the "work in progress" tree and applies them to the real DOM, making the changes visible to users.&lt;/p&gt;

&lt;p&gt;React optimizes the performance by batching updates during the commit phase, reducing unnecessary reflows and repaints for a smoother user experience.&lt;/p&gt;
&lt;h2&gt;
  
  
  A New Horizon for Concurrency and&amp;nbsp;Batching
&lt;/h2&gt;

&lt;p&gt;React Fiber, the new reconciliation architecture introduced in React 16, not only improves rendering efficiency but also unlocks powerful features for&lt;br&gt;
concurrency and batching. This allows React to break free from the limitations of synchronous updates and enables the library to handle complex user&lt;br&gt;
interactions more intelligently.&lt;/p&gt;

&lt;p&gt;| Concurrency and Batching&lt;/p&gt;

&lt;p&gt;In traditional synchronous rendering, React updates the entire component tree before reflecting changes in the real DOM. This approach can lead to unnecessary&lt;br&gt;
processing, causing performance bottlenecks and affecting user experience. React Fiber introduces the concept of concurrency, which enables asynchronous&lt;br&gt;
rendering and prioritization of tasks.&lt;/p&gt;

&lt;p&gt;With concurrency, React can pause, resume, or abort rendering work as needed, and even divide the rendering process into smaller, more manageable chunks. This&lt;br&gt;
fine-grained control empowers React to prioritize essential updates and respond faster to user interactions, making the user interface feel more responsive and&lt;br&gt;
fluid&lt;/p&gt;
&lt;h2&gt;
  
  
  New Functionality in React&amp;nbsp;Fiber
&lt;/h2&gt;

&lt;p&gt;To leverage the benefits of concurrency and batching, React introduces several new functionalities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;useDeferredValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The useDeferredValue hook allows developers to defer the processing of non-essential updates, optimizing performance by prioritizing high-priority work. For&lt;br&gt;
example, in a search input, we may want to defer the rendering of search results until the user pauses typing. This way, React can focus on more critical tasks&lt;br&gt;
like handling user input, ensuring a smoother experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useDeferredValue&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Defer the processing of non-essential updates&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deferredQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useDeferredValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="c1"&gt;// Rest of the component logic&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;useTransition&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The useTransition hook allows developers to create smoother transitions during rendering updates. It helps to manage complex interactions by defining specific&lt;br&gt;
points in the rendering process where React should wait for a transition to complete before displaying the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useTransition&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExpensiveComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;startTransition&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTransition&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Simulate a time-consuming rendering process&lt;/span&gt;
    &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;startTransition&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Code to render the expensive component&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isPending&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Return the fully rendered component&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Expensive&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="nx"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Suspense Component
&lt;/h2&gt;

&lt;p&gt;The Suspense component is a powerful tool that allows developers to handle loading states and fallback UIs in an elegant and straightforward manner. It is&lt;br&gt;
especially useful when dealing with asynchronous data fetching or code-splitting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;}&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Asynchronously load and render the lazy component */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;LazyComponent&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Suspense&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;React Fiber's reconciliation process, powered by the concept of Fiber trees, plays a pivotal role in driving React's remarkable performance. By intelligently&lt;br&gt;
managing virtual DOM updates and efficiently applying them to the real DOM, React ensures that user interfaces remain snappy and responsive, making React a&lt;br&gt;
popular and powerful choice for building modern web applications. The introduction of React Fiber marks a significant milestone in React's evolution, paving the&lt;br&gt;
way for even more efficient and responsive applications.&lt;/p&gt;

&lt;p&gt;Thanks for reading ❤️&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>React Controlled vs Uncontrolled Components</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 19:01:41 +0000</pubDate>
      <link>https://dev.to/akladyous/react-controlled-vs-uncontrolled-components-2fg5</link>
      <guid>https://dev.to/akladyous/react-controlled-vs-uncontrolled-components-2fg5</guid>
      <description>&lt;h2&gt;
  
  
  React makes it easy to manipulate data using forms.
&lt;/h2&gt;

&lt;p&gt;One of the most common patterns you’ll see in React when dealing with forms is that we need to make React aware of changes to the form inputs when the user&lt;br&gt;
types. This means that the component containing those input elements typically needs to keep track of the text in the input elements using state.&lt;/p&gt;

&lt;p&gt;React supports two types of components: controlled components and uncontrolled components. Let’s uncover the main differences between controlled and&lt;br&gt;
uncontrolled components.&lt;/p&gt;
&lt;h2&gt;
  
  
  Controlled Component
&lt;/h2&gt;

&lt;p&gt;Unlike the uncontrolled component, the input form element in the controlled component is handled by the component rather than the DOM. It takes its current&lt;br&gt;
value through props. The changes are notified through useState Hook. Let’s consider an example to understand it in a better way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ControlledComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAge&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;hairColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setHairColor&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nx"&gt;Name&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nx"&gt;Age&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setAge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;haircolor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nx"&gt;Hair&lt;/span&gt; &lt;span class="nx"&gt;Color&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;haircolor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hair Color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;hairColor&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setHairColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Submit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The input field is Controlled because React sets its value from the state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever we type into the input field, the onChange handler updates the state with the input’s value accessed from the event object. The value state variable is&lt;br&gt;
the source of truth. When we need to access the value entered by the user into the input field, we have to read the value from the state variable. The&lt;br&gt;
Controlled components can help access the value of any input field.&lt;/p&gt;
&lt;h2&gt;
  
  
  Uncontrolled component
&lt;/h2&gt;

&lt;p&gt;Similar to the traditional HTML form inputs, the uncontrolled component can be written using a ref to get form values from the DOM. Thus there is no need to&lt;br&gt;
write an event handler for every state update and the HTML elements maintain their own state that will be updated when the input value changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createRef&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UncontrolledComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nameInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createRef&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ageInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createRef&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hairColorInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createRef&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nameInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ageInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hairColorInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nx"&gt;Name&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;nameInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nx"&gt;Age&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ageInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;haircolor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nx"&gt;Hair&lt;/span&gt; &lt;span class="nx"&gt;Color&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;haircolor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hair Color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;hairColorInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Submit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Both the controlled and uncontrolled form fields have their merit. Evaluate your specific situation and pick the approach — what works for you is good enough.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@akladyous/react-controlled-vs-uncontrolled-components-c803e197f7d3" rel="noopener noreferrer"&gt;For a Deeper Dive, Check the Original Post 🔗&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always, thanks for reading!&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Rails Action Mailer Configuration</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 18:47:12 +0000</pubDate>
      <link>https://dev.to/akladyous/rails-action-mailer-configuration-4mbh</link>
      <guid>https://dev.to/akladyous/rails-action-mailer-configuration-4mbh</guid>
      <description>&lt;h3&gt;
  
  
  Action Mailer overview
&lt;/h3&gt;

&lt;p&gt;Rails has a wonderful built-in mailing system called Action Mailer, which allows us to send email from our application as long as we have a mailer model.&lt;br&gt;
Mailers are actually a lot like controllers: they have their own app/mailers directory, and each mailer has its own associated view as well. Each mailer also&lt;br&gt;
inherits from ActionMailer::Base, and just like controllers, can be generated really easily.&lt;/p&gt;

&lt;p&gt;This tutorial explains how to configure Ruby on Rails in the development environment toward sending emails via Ruby on Rails Action Mailer integrated with the&lt;br&gt;
most popular email providers Gmail &amp;amp; SendGrid.&lt;/p&gt;

&lt;p&gt;Let’s take it step by step, first we need to do a bit of configuration, we are going to send emails from the developement enviroment.&lt;/p&gt;
&lt;h2&gt;
  
  
  ActionMailer Gmail Confiruation
&lt;/h2&gt;

&lt;p&gt;In order to use Action Mail with Gmail, the best solution that does not violate your other security such as 2-step certification is using&lt;br&gt;
&lt;a href="https://support.google.com/accounts/answer/185833" rel="noopener noreferrer"&gt;app Password&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;** Open your &lt;a href="https://myaccount.google.com/security" rel="noopener noreferrer"&gt;Account Security Settings&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdzg289k45w9eij7id45y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdzg289k45w9eij7id45y.png" alt="Alt google-app-passwords" width="669" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Navigate to App Password&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1fk6nth5z3quz5ra4ij8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1fk6nth5z3quz5ra4ij8.png" alt="Alt google-app-passwords" width="670" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the App Password page, select “Mail” app, and “Other” device, now we provide the name of ruby on Rail application. Then click “Generate”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flkme8plg423kyrn61yrj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flkme8plg423kyrn61yrj.png" alt="blog image" width="648" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy your App password from the yellow Box.&lt;/p&gt;
&lt;h1&gt;
  
  
  ActionMailer Rails Confiruation
&lt;/h1&gt;

&lt;p&gt;Ruby doesn’t require any additional gems to be installed, as it’s just a simple smtp setting, we just need to configure the setup by adding the following code&lt;br&gt;
into our file development.rb so that the Action Mailer and mailcatcher will be setup properly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="s"&gt;config.action_mailer.delivery_method = :smtp&lt;/span&gt;
  &lt;span class="s"&gt;config.action_mailer.smtp_settings = {&lt;/span&gt;
    &lt;span class="s"&gt;address&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;              &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;smtp.gmail.com'&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;                 &lt;span class="s"&gt;587,&lt;/span&gt;
    &lt;span class="na"&gt;domain&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;               &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;example.com'&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;user_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;            &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;youremail@gmail.com'&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;             &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;xxxunxtbxyvmzxxx'&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;authentication&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;       &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;plain'&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;enable_starttls_auto&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="s"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;open_timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;         &lt;span class="s"&gt;5,&lt;/span&gt;
    &lt;span class="na"&gt;read_timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;         &lt;span class="m"&gt;5&lt;/span&gt;
&lt;span class="err"&gt;  }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for mote informaition refer to&lt;br&gt;
&lt;a href="https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmail" rel="noopener noreferrer"&gt;Action Mail Confiruation for Gmail.&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  To start, we’ll use Rails to generate a mailer:
&lt;/h3&gt;
&lt;h2&gt;
  
  
  Creating a Mailer
&lt;/h2&gt;

&lt;p&gt;So the first thing we need to do is to create a new Mailer. To do this we can use the Rails generator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;  rails generate mailer UserMailer welcome_message
     create  app/mailers/user_mailer.rb
     invoke  erb
     create    app/views/user_mailer
     create    app/views/user_mailer/welcome_message.text.erb
     create    app/views/user_mailer/welcome_message.html.erb
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this command in the terminal generates a few different files for us. We now have an app/mailers directory, with an user_mailer.rb and&lt;br&gt;
application_mailer.rb file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApplicationMailer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActionMailer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
    &lt;span class="n"&gt;default&lt;/span&gt; &lt;span class="ss"&gt;from: &lt;/span&gt;&lt;span class="s2"&gt;"from@example.com"&lt;/span&gt;
    &lt;span class="n"&gt;layout&lt;/span&gt; &lt;span class="s2"&gt;"mailer"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Theapplication_mailer.rb is the base class that all other mailers are going to inhert from, we notice it inherts from ActionMailer::Base and the first thing it&lt;br&gt;
does it cause the default method default from: "&lt;a href="mailto:from@example.com"&gt;from@example.com&lt;/a&gt;" and passes some options, these option will be applied to all of our email by default because&lt;br&gt;
it's defined up here in the base class. The from option is the email address you want to use as the sender of the email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserMailer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationMailer&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;welcome_message&lt;/span&gt;
        &lt;span class="vi"&gt;@greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hi"&lt;/span&gt;
        &lt;span class="n"&gt;mail&lt;/span&gt; &lt;span class="ss"&gt;to: &lt;/span&gt;&lt;span class="s2"&gt;"to@example.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;subject: &lt;/span&gt;&lt;span class="s1"&gt;'Account registration'&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also generated this UserMailer, notice that the user_mailer.rb inherts from the ApplicationMailer.&lt;/p&gt;

&lt;p&gt;Now this mailer classes works similarlly to rails controllers, they inherts from the common base class, in this case “ApplicationMailer”. Thet also has a method&lt;br&gt;
inside of him, notice that this method correspond to the name we gave in the command line “welcome_message” , and those methods are similiar to controller&lt;br&gt;
actions, but instead of generating an HTML response, “mailer” method generate an “email”.&lt;/p&gt;

&lt;p&gt;So this welcome_message is goning to generate the email we want. we also see that step down method includes this “@greeting” instance variable, an instance&lt;br&gt;
variables define inside of welcome_message method are accessabile in view templates just like we would expect with the controller action.&lt;/p&gt;

&lt;p&gt;And the last line of these mailer methods must call this mail method to accualty create a mail message a return it. now you notice we can also pass option to&lt;br&gt;
this method, in this case we have the option to:, this the person we want to send the email to.&lt;/p&gt;

&lt;p&gt;To create that email, the mail method is goning to render some email template, now the generator went ahead and created 2 email templates for us to render that&lt;br&gt;
new message. and those templates are over in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  App
  |- Views
  |- user_mail
  |- welcome_message.html.erb
  |- welcome_message.text.erb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;notice that the name of the file includes the name of the mailer method, welcome_message.html.erb that generates an HTML email and welcome_message.text.erb that&lt;br&gt;
generates a plain text email.&lt;/p&gt;

&lt;p&gt;If we take look at the HTML template, what we see it looks just like any other view template.&lt;/p&gt;

&lt;p&gt;It’s a good practice to send both plain text and HTML email and let the email client decide which one to display, and the action mailer does all the heavy&lt;br&gt;
lifting for us because we have 2 views templates with the same name but different content types ebedded in their file names, both templates will get rendered&lt;br&gt;
and sent out in one multi-part email.&lt;/p&gt;

&lt;p&gt;Let’s go ahead and setup a user login with our welcome_message method, so our users_controller.rb looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;
 &lt;span class="vi"&gt;@user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signup_params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save!&lt;/span&gt;
   &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:user_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;
   &lt;span class="no"&gt;UserMailer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;user: &lt;/span&gt;&lt;span class="n"&gt;current_user&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;welcome_msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deliver_now&lt;/span&gt;
   &lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;json: &lt;/span&gt;&lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;status: :created&lt;/span&gt;
 &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It would be handy to change our template so that it generates an email content we want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="no"&gt;Welcome&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;com&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= @user.name %&amp;gt;&amp;lt;/h1&amp;gt;
   &amp;lt;p&amp;gt;You have successfully signed up to www.example.com&amp;lt;/p&amp;gt;
   &amp;lt;p&amp;gt;Your email address is : &amp;lt;%=&lt;/span&gt; &lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;email&lt;/span&gt;&lt;span class="o"&gt;%&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;
   &amp;lt;p&amp;gt;Your user name is : &amp;lt;%= @user.user_name%&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="no"&gt;Thanks&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;joining&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;great&lt;/span&gt; &lt;span class="n"&gt;day!&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://medium.com/@akladyous/ruby-on-rails-action-mailer-configuration-6d0cfc00b871" rel="noopener noreferrer"&gt;link on medium&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Conclusion
&lt;/h5&gt;

&lt;p&gt;It doesn’t really matter if you are building a consumer or business application, you’re going to need to send emails to your users as some point.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@akladyous/ruby-on-rails-action-mailer-configuration-6d0cfc00b871" rel="noopener noreferrer"&gt;Unlock Further Insights by Sharing 🔗&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>rails</category>
      <category>actionmailer</category>
    </item>
    <item>
      <title>Exploring Logistic Regression for Classification</title>
      <dc:creator>Boula Akladyous</dc:creator>
      <pubDate>Sun, 01 Nov 2026 18:44:45 +0000</pubDate>
      <link>https://dev.to/akladyous/exploring-logistic-regression-for-classification-4ch4</link>
      <guid>https://dev.to/akladyous/exploring-logistic-regression-for-classification-4ch4</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Logistic regression is a classification algorithm used to assign observations to a discrete set of classes. Unlike linear regression which outputs continuous&lt;br&gt;
number values, logistic regression transforms its output using the logistic sigmoid function to return a probability value which can then be mapped to two or&lt;br&gt;
more discrete classes.&lt;/p&gt;

&lt;p&gt;Logistic regression is used to calculate the probability of a binary event occurring and to deal with issues of classification. For example, predicting if an&lt;br&gt;
incoming email is spam or not spam, or predicting if a credit card transaction is fraudulent or not fraudulent. In a medical context, logistic regression may be&lt;br&gt;
used to predict whether a tumor is benign or malignant. In marketing, it may be used to predict if a given user (or group of users) will buy a certain product&lt;br&gt;
or not. An online education company might use logistic regression to predict whether a student will complete their course on time or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the different types of logistic regression?
&lt;/h2&gt;

&lt;p&gt;The three types of logistic regression are:&lt;/p&gt;

&lt;p&gt;-- Binary logistic regression is the statistical technique used to predict the relationship between the dependent variable (Y) and the independent variable (X),&lt;br&gt;
where the dependent variable is binary in nature. For example, the output can be Success/Failure, 0/1 , True/False, or Yes/No. This is the type of logistic&lt;br&gt;
regression that we’ve been focusing on in this post.&lt;/p&gt;

&lt;p&gt;-- Multinomial logistic regression is used when you have one categorical dependent variable with two or more unordered levels (i.e two or more discrete&lt;br&gt;
outcomes). It is very similar to logistic regression except that here you can have more than two possible outcomes. For example, let’s imagine that you want to&lt;br&gt;
predict what will be the most-used transportation type in the year 2030. The transport type will be the dependent variable, with possible&lt;/p&gt;

&lt;p&gt;-- outputs of train, bus, tram, and bike (for example). Ordinal logistic regression is used when the dependent variable (Y) is ordered (i.e., ordinal). The&lt;br&gt;
dependent variable has a meaningful order and more than two categories or levels. Examples of such variables might be t-shirt size (XS/S/M/L/XL), answers on an&lt;br&gt;
opinion poll (Agree/Disagree/Neutral), or scores on a test (Poor/Average/Good).&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of logistic regression
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Advantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Logistic regression is easier to implement, interpret, and very efficient to train.&lt;/li&gt;
&lt;li&gt;It makes no assumptions about distributions of classes in feature space.&lt;/li&gt;
&lt;li&gt;It can easily extend to multiple classes(multinomial regression) and a natural probabilistic view of class predictions.&lt;/li&gt;
&lt;li&gt;Logistic regression works well for cases where the dataset is linearly separable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Logistic regression fails to predict a continuous outcome.&lt;/li&gt;
&lt;li&gt;If the number of observations is lesser than the number of features, Logistic Regression should not be used, otherwise it may lead to overfitting.&lt;/li&gt;
&lt;li&gt;Logistic Regression requires average or no multicollinearity between independent variables.&lt;/li&gt;
&lt;li&gt;Logistic regression may not be accurate if the sample size is too small.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Sigmoid Function
&lt;/h2&gt;

&lt;p&gt;In order to map predicted values to probabilities, we use the sigmoid function. The function map any real input &lt;strong&gt;&lt;em&gt;t&lt;/em&gt;&lt;/strong&gt; and outputs a value between &lt;strong&gt;&lt;em&gt;zero&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
and &lt;strong&gt;&lt;em&gt;one&lt;/em&gt;&lt;/strong&gt;. For the logit, this is interpreted as taking input log-odds and having output probability. the logistic “sigmoid” function is defined as follow:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8eatlebqgwr7nu7n4haz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8eatlebqgwr7nu7n4haz.png" alt="Sigmoid Function" width="267" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To understand how sigmoid function squashes the values within the range, let’s visualize the graph of the sigmoid function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffj4cpc9ci5wx7gxyeo0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffj4cpc9ci5wx7gxyeo0e.png" alt="Sigmoid Function" width="320" height="213"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;As you can see from the graph, the sigmoid function becomes asymptote to y=1 for positive values of x and becomes&lt;br&gt;
asymptote to y=0 for negative values of x.&lt;/p&gt;

&lt;h2&gt;
  
  
  Regularization in Logistic Regression
&lt;/h2&gt;

&lt;p&gt;Regularization is extremely important in logistic regression modeling. Without regularization, the asymptotic nature of logistic regression would keep driving&lt;br&gt;
loss towards 0 in high dimensions.&lt;/p&gt;

&lt;p&gt;Regularization is the most used technique to penalize complex models in machine learning, it is deployed for reducing overfitting (or, contracting&lt;br&gt;
generalization errors) by putting network weights small. It also enhances the performance of models for new inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Penalty Term
&lt;/h2&gt;

&lt;p&gt;Through biasing data points towards specific values such as very small values to zero, regularization achieves this biasing by adding a tuning parameter to&lt;br&gt;
strengthen those data points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;L1 regularization: It adds an L1 penalty that is equal to the absolute value of the magnitude of coefficient, or simply restricting the size of coefficients.
For example, Lasso regression implements this method.&lt;/li&gt;
&lt;li&gt;L2 Regularization: It adds an L2 penalty which is equal to the square of the magnitude of coefficients. For example, Ridge regression and SVM implement this
method.&lt;/li&gt;
&lt;li&gt;Elastic Net: When L1 and L2 regularization combine together, it becomes the elastic net method, it adds a hyperparameter.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If both L1 and L2 regularization work well, you might be wondering why we need both. It turns out they have different but equally useful properties, from a&lt;br&gt;
practical standpoint, L1 tends to shrink coefficients to zero whereas L2 tends to shrink coefficients evenly.&lt;/p&gt;

&lt;p&gt;L1 is therefore useful for feature selection, as we can drop any variables associated with coefficients that go to zero.&lt;/p&gt;

&lt;p&gt;L2 on the other hand, is useful when you have collinear/codependent features.&lt;/p&gt;

&lt;p&gt;(An example pair of codependent features is gender and ispregnant since, at the current level of medical technology, only females can be ispregnant.)&lt;br&gt;
Codependence tends to increase coefficient variance, making coefficients unreliable/unstable, which hurts model generality. L2 reduces the variance of these&lt;br&gt;
estimates, which counteracts the effect of codependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this blog I presented the basic concept of logistic regression. I hope this blog was helpful and motivated you enough to get interested in the topic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://akladyous.medium.com/logistic-regression-7885cebd3699" rel="noopener noreferrer"&gt;For a Deeper Dive, Check the Original Post 🔗&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading! ❤️&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>classification</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
