<?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: Lucky Jha</title>
    <description>The latest articles on DEV Community by Lucky Jha (@theluckyjha).</description>
    <link>https://dev.to/theluckyjha</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%2F4057412%2Fb1db4c59-eecf-4c8a-93a9-3bbc8e45f5cc.png</url>
      <title>DEV Community: Lucky Jha</title>
      <link>https://dev.to/theluckyjha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/theluckyjha"/>
    <language>en</language>
    <item>
      <title>Encoding in Machine Learning: One-Hot Encoding vs. Label Encoding</title>
      <dc:creator>Lucky Jha</dc:creator>
      <pubDate>Tue, 04 Aug 2026 09:07:08 +0000</pubDate>
      <link>https://dev.to/theluckyjha/encoding-in-machine-learning-one-hot-encoding-vs-label-encoding-3a5p</link>
      <guid>https://dev.to/theluckyjha/encoding-in-machine-learning-one-hot-encoding-vs-label-encoding-3a5p</guid>
      <description>&lt;p&gt;When working with machine learning, one of the very first challenges everyone encounters and will encounter is dealing with categorical data. Machine learning algorithms work with numbers, not text, so values like "Red", "Apple", or "xyz" must be converted into a numerical format. This process is called encoding.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Encoding?
&lt;/h3&gt;

&lt;p&gt;Encoding is the process of converting text-based categorical data into numerical format, which is important for machine learning algorithms/models to process it.&lt;/p&gt;

&lt;p&gt;For example, consider the following datasets:&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%2Fxhj86yyeeltna1xf0hlk.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%2Fxhj86yyeeltna1xf0hlk.png" alt=" " width="204" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A machine learning model cannot directly understand these text values. Encoding transforms them into numbers while preserving useful information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Do we need Encoding?
&lt;/h3&gt;

&lt;p&gt;Most machine learning algorithms perform mathematical operations such as calculating values, probabilities, distances, or gradients. Since these operations require numerical input, categorical input values must first be represented as numbers.&lt;/p&gt;

&lt;p&gt;Without encoding, many models will produce an error or fail to learn meaningful patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Categorical Data
&lt;/h2&gt;

&lt;p&gt;Before choosing an encoding technique, it's important to identify the type of categorical features.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Nominal Data
&lt;/h3&gt;

&lt;p&gt;Nominal categories have no natural orders. They don't follow any orders in and out.&lt;/p&gt;

&lt;p&gt;Examples: Colours, Countries, Animal species, Car brands&lt;/p&gt;

&lt;p&gt;There is no logical ordering among these values.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Ordinal Data
&lt;/h3&gt;

&lt;p&gt;Ordinal categories do follow a order. These categories have a meaningful and logical order.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Small -&amp;gt; Medium -&amp;gt; Large&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Low -&amp;gt; Medium -&amp;gt; High&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Poor -&amp;gt; Fair -&amp;gt; Good -&amp;gt; Excellent &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The order matters, even if the differences between categories are not equal. &lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Encoding
&lt;/h2&gt;

&lt;p&gt;Type of Encoding matters for different types of categorical data. Here the two types of encoding come in use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Label Encoding
&lt;/h3&gt;

&lt;p&gt;Label Encoding is a type of encoding which assigns a unique integer to each category.&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%2Fdmnei7fprac9nuwma4td.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%2Fdmnei7fprac9nuwma4td.png" alt=" " width="169" height="73"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above encoded dataset you can clearly see each fruit has a different integer assigned. &lt;/p&gt;

&lt;p&gt;How to do it using Python?&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%2F2u9vau2jjttfufyq3ilt.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%2F2u9vau2jjttfufyq3ilt.png" alt=" " width="459" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of Label Encoding
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Simple to implement.&lt;/li&gt;
&lt;li&gt;Memory efficient.&lt;/li&gt;
&lt;li&gt;Suitable for ordinal data.&lt;/li&gt;
&lt;li&gt;Fast preprocessing.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Disadvantages of Label Encoding
&lt;/h3&gt;

&lt;p&gt;Things which have advantages, they have disadvantages too.&lt;br&gt;
The encoded values introduces an artificial order. &lt;br&gt;
For example:&lt;br&gt;
Apple = 0&lt;br&gt;
Banana = 1&lt;br&gt;
Orange = 2&lt;/p&gt;

&lt;p&gt;A model might assume that Orange &amp;gt; Banana &amp;gt; Apple. For nominal data, this assumption is incorrect and may reduce model performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  One-Hot Encoding
&lt;/h3&gt;

&lt;p&gt;One-Hot Encoding creates a new binary column for each category.&lt;/p&gt;

&lt;p&gt;Original Data:&lt;br&gt;
&lt;strong&gt;Color&lt;/strong&gt;&lt;br&gt;
Red&lt;br&gt;
Blue &lt;br&gt;
Green&lt;/p&gt;

&lt;p&gt;After One-Hot Encoding:&lt;/p&gt;

&lt;p&gt;Red  Blue  Green&lt;br&gt;
1    0     0&lt;br&gt;
0    1     0&lt;br&gt;
0    0     1&lt;/p&gt;

&lt;p&gt;Each category gets its own feature, eliminating any implied ordering. &lt;/p&gt;

&lt;p&gt;How to do this using Python?&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%2Figddj7eqbxdsemrzzzm2.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%2Figddj7eqbxdsemrzzzm2.png" alt=" " width="536" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of One-Hot Encoding
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Prevents false ordering between categories.&lt;/li&gt;
&lt;li&gt;Works well for nominal features.&lt;/li&gt;
&lt;li&gt;Widely supported by machine learning libraries.&lt;/li&gt;
&lt;li&gt;Often improves model performance for linear models and distance         based algorithms.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Disadvantages of One-Hot Encoding
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Increases the number of features.&lt;/li&gt;
&lt;li&gt;Can create sparse datasets.&lt;/li&gt;
&lt;li&gt;Becomes inefficient for columns with hundreds or thousands of unique values.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When should We Use Each Encoding?
&lt;/h2&gt;

&lt;p&gt;We use Label Encoding when the categories have a natural order and want a compact representation.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Education Level&lt;/li&gt;
&lt;li&gt;Product Size&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We use One-Hot Encoding when categories are unordered and want to avoid introducing artificial relationships.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Country&lt;/li&gt;
&lt;li&gt;Colour&lt;/li&gt;
&lt;li&gt;Gender&lt;/li&gt;
&lt;li&gt;Department&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Practical Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always understand the meaning of the categorical features and datasets before applying encoding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid Label Encoding for nominal features unless your model can handle categorical variables appropriately.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Encoding is a major and essential preprocessing step in machine learning. Choosing the appropriate encoding technique can significantly impact model performance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Label Encoding&lt;/strong&gt; is simple and effective for ordinal data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One-Hot Encoding&lt;/strong&gt; is generally the preferred choice for nominal data because it avoids introducing false relationships between categories.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a rule of thumb:&lt;br&gt;
If the categories have an order, use Label Encoding. If they don't, use One-Hot Encoding.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>encoding</category>
    </item>
    <item>
      <title>Every Missing Data is not Bad.</title>
      <dc:creator>Lucky Jha</dc:creator>
      <pubDate>Sun, 02 Aug 2026 06:31:22 +0000</pubDate>
      <link>https://dev.to/theluckyjha/every-missing-data-is-not-bad-4jl7</link>
      <guid>https://dev.to/theluckyjha/every-missing-data-is-not-bad-4jl7</guid>
      <description>&lt;p&gt;Hey Everyone! This side your favourite guy, Lucky Jha. So today I came up with something more interesting which came out of my knowledge related to machine learning. &lt;/p&gt;

&lt;p&gt;You guys already know my curiosity regarding and about Machine Learning. It's like whenever I open up anything related to machine learning I give my 110% to it. Even today I was starting up with my machine learning project. I started web scraping and all to gather data. &lt;/p&gt;

&lt;p&gt;And soon I found the CSV dataset on kaggle. And the data was about the customers who churned and not churned after making a contract with IBM, I don't know whether it was official or unofficial dataset  released by IBM. But what it taught me today is way more important than anything.&lt;/p&gt;

&lt;p&gt;So I was basically validating my data using my data validation library developed by me called &lt;a href="https://github.com/jhalucky/veris" rel="noopener noreferrer"&gt;Veris&lt;/a&gt;. I was doing validation, soon I ran a command to check whether for the null column to check whether how many rows are null?? There was a column "TotalCharge" which was null for 11 rows. &lt;/p&gt;

&lt;p&gt;So a minute after watching the data, I decided to drop those rows with null column but soon realised after 10 minutes of data investigation, I hovered over all the columns and found out some patterns between tenure, contract, and churn.&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%2Ff9rhtguwa3vil2sqk0v2.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%2Ff9rhtguwa3vil2sqk0v2.png" alt=" " width="799" height="376"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I realised a pattern which was showing that person with tenure "0", has totalCharge = 0, So I realised that the person hasn't even charged even once. He hasn't paid his first month bill that's why his or her totalCharge is null not even 0. &lt;/p&gt;

&lt;p&gt;So Data Investigation is a very important step in the process of data validation, you should be able to answer all the questions related to your data. You should know which column is responsible for model training, which column effects model training, which doesn't. Data Investigation is important in every term. &lt;/p&gt;

&lt;p&gt;Its more important before data preprocessing, Exploratory Data Analysis. For data validation, data investigation is very important. You should be able to answer every question about the data like you own the business. &lt;/p&gt;

&lt;p&gt;So to conclude the entire blog in one line summary, I'd say one thing only, investigate the data before you drop the null rows it might help you to train the model for missing values. &lt;/p&gt;

&lt;p&gt;Will Keep sharing my day-to-day journey and learnings. I love writing in public. Hope you love it like your own son, brother, friend, boyfriend. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>First Commit of Machine Learning</title>
      <dc:creator>Lucky Jha</dc:creator>
      <pubDate>Sat, 01 Aug 2026 07:13:58 +0000</pubDate>
      <link>https://dev.to/theluckyjha/first-commit-of-machine-learning-3de7</link>
      <guid>https://dev.to/theluckyjha/first-commit-of-machine-learning-3de7</guid>
      <description>&lt;p&gt;Hey everyone! This side Lucky Jha, a final year engineering student, so like everyone does I also started writing blogs for some reason and almost everyone of you must be knowing the exact reason behind it, yeah that is. Not learn in public, but build in public. So building products using lines of code is my ulimate passion for my life. I love building. I really love it. &lt;/p&gt;

&lt;p&gt;Now you guys must be wondering why &lt;strong&gt;Machine Learning&lt;/strong&gt;? &lt;/p&gt;

&lt;p&gt;But its not like that, this is not the very first thing I'm starting out with. I have tried so many things before this. I've done full-stack development, Data Engineering, and Machine Learning also. &lt;/p&gt;

&lt;p&gt;I did Machine learning back in 2024 when I was in second year of my engineering, I really enjoyed it, I really enjoyed learning and coding it. I did it for around 4-5 months made one project called "Disease Prediction System", but I had to step back out of it not because I was not enjoying but some guy demotivated me that I won't be able to do that. There are so many prerequisites, you should do that first otherwise results will not be impactful. &lt;/p&gt;

&lt;p&gt;Then I got in my third year, found out there's a space for full stack development, then I started practicing and building products in/using development. But in just few months I realised that full-stack developer job market has also been captured by AI. And it was the crowdest job market, because every second guy is learning FULL STACK development. I've written a famous tweet/post/quote/phrase for developer job market, it goes like, If you close your eyes, and throw a stone it would hit a Full Stack Developer. Market was/is/will be that tough. &lt;/p&gt;

&lt;p&gt;Then After realisation I took a break of 1-2 months from everything, especifically from my techstack, I took a deep break from my tech skills and decided to upgrade it to something unique and else, which will come in demand in coming years. Then suddenly I saw somewhere about Data Engineering, I read something about data engineers, I skilled myself for that role. I gave 2-3 months to it. And after completing all prerequisites, crash course, I called up my most valuable mentor "Mr. Gaurav Surana", He's my go to person for everything. I call him up whenever I get stuck in anything. So after doing all this I called him up regarding an internship referral in his company. And then I faced the reality of it, he directly said me it's getting over, data pipelines are getting converted into AI pipelines. Learn AI engineerng, Machine Learning, and things like them which can be used to integrate with AI. &lt;/p&gt;

&lt;p&gt;From then on I decided I turned back that page and started doing machine learning again from the very next day onwards. And I have decided, will do it till the end of the end. So this was my learning journey till now. Will keep sharing more about it (Machine Learning)!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
