?? Day13 of #100DaysOfPython ??

?? Day13 of #100DaysOfPython ??

Today, we're diving into another feature engineering technique for handling ordinal categories known as Ordinal Number/ Label Encoding!

What is Ordinal data?

Ordinal data is a categorical data type where the labels have natural, ordered categories and the distance between the labels are unknown.

Ordinal data is found across grades of students, level of education, survey responses, days of the week etc.

Let's dive into an example through implementing Ordinal Number Encoding on days of the week:

1. Extracting timestamp information from datetime library and creating a list of last 20 days from today


2. Extracting weekday from the timestamp for 20 days


3. Creating a dictionary that with respective day number for each day of the week and mapping it to the original day in the data

In Step 3, we encode the 7 days of the week from Mon-Sun with numerical values starting from 1-10.

The Ordinal Number Encoding retains semantic information of the variable and is easy to implement.

However, it does not contribute valuable information to the ML model and can only be carried out for Ordinal features with limited labels.






要查看或添加评论,请登录

Surya Singh的更多文章

  • ?? Day100 of #100DaysOfPython ??

    ?? Day100 of #100DaysOfPython ??

    Today, we're diving into map(), filter(), & reduce() in python! map() The map() function in Python is used to apply a…

    2 条评论
  • ?? Day99 of #100DaysOfPython ??

    ?? Day99 of #100DaysOfPython ??

    Today, we're diving into 'is' & '==' in python! The 'is' and '==' operators might seem similar at first glance, but…

  • ?? Day98 of #100DaysOfPython ??

    ?? Day98 of #100DaysOfPython ??

    Today, we're diving into the use of .join() function for string concatenation in python! The .

  • ?? Day97 of #100DaysOfPython ??

    ?? Day97 of #100DaysOfPython ??

    Today, we're continuing to dive into Object Oriented Programming in python! How do we initialise a class and create…

  • ?? Day96 of #100DaysOfPython ??

    ?? Day96 of #100DaysOfPython ??

    Today, we're diving into Object Oriented Programming in python! What is a class? A class is a blueprint for creating…

  • ?? Day95 of #100DaysOfPython ??

    ?? Day95 of #100DaysOfPython ??

    Today, we're diving into regex in python! Regex allows you to define search patterns for strings, making it easier to…

  • ?? Day94 of #100DaysOfPython ??

    ?? Day94 of #100DaysOfPython ??

    Today, we're diving into another technique for handling missing values known as Random Sample Imputation! Random sample…

  • ?? Day93 of #100DaysOfPython ??

    ?? Day93 of #100DaysOfPython ??

    Today, we're diving into Local & Global variables in python! Local variables are defined within a function or block and…

  • ?? Day92 of #100DaysOfPython ??

    ?? Day92 of #100DaysOfPython ??

    Today, we're diving into the use of .join() function for string concatenation in python! The .

  • ?? Day91 of #100DaysOfPython ??

    ?? Day91 of #100DaysOfPython ??

    Today, we're diving into Count/Frequency Encoding for handling categorical feature! Count or frequency encoding is a…

社区洞察

其他会员也浏览了