What is One-Hot Encoding?

Advertisements

In this simple tutorial, we’ll explain One-Hot encoding with Python and R.

This model recognizes numeric values ​​only as inputs. In order for our model to work with data sets, we must encode them, as we will explain later.

What is the concept of One-hot encoding:

This encoding converts groups of data represented by words, letters or symbols into correct numeric values ​​with specific places of ones and zeros that are determined by the number of groups so that each part of these places represents one group or category.

Thus, any category is denoted by the number one, otherwise the symbol will take zero.

Advertisements

We will illustrate with a practical example the process of One-hot coding using R and Python:

Using Python

Using R

So what is the significance of this encoding ?

In the case of important data sets consisting of certain categories, we need to use them in the model, which of course only accepts numeric codes, as is the case in some algorithms, in these cases one-hot encoding is the best option.

Advertisements

ما هو مفهوم

One-Hot Encoding

Advertisements

سنتناول في هذا الدرس التوضيحي المبسط شرح

Python و R باستخدام One-Hot الترميز

يتعرف هذا النموذج على القيم الرقمية فقط على شكل مدخلات ولكي يتمكن نموذجنا من العمل مع مجموعات البيانات يتوجب علينا ترميزها كما سنوضح لاحقاً

؟ One-hot ما هو مفهوم ترميز

يقوم هذا الترميز بتحويل مجموعات من البيانات التي تمثل بكلمات أو حروف أو رموز إلى قيم رقمية صحيحة بمنازل محددة من الآحاد والأصفار يتم تحديدها من خلال عدد المجموعات بحيث يمثل كل جزء من هذه المنازل مجموعة أو فئة واحدة وبالتالي يرمز إلى أي فئة بالرقم واحد وعدا ذلك سيأخذ الرمز صفر

Advertisements

One-hot وسنوضح بمثال عملي عملية  ترميز

: وبايثون R باستخدام لغتي

: باستخدام بايثون

: R باستخدام

إذاً من أين تأتي أهمية هذا الترميز ؟ 

في حال وجود مجموعات بيانات مهمة مؤلفة من فئات معينة فنحن بحاجة إلى استخدامها في النموذج الذي هو بطبيعة الحال لا يقبل التعامل إلا مع الرموز الرقمية كما هو الحال في بعض الخوارزميات

هو الخيار الأفضل one-hot ففي هذه الحالات الترميز

Advertisements

Leave a comment