One hot encoding

What is One-Hot Encoding?

One-Hot Encoding is a technique used to convert categorical data (like labels or categories) into a numerical format that machine learning algorithms can understand. Here's how it works:

For example:

One-Hot Encoding for the "Location_Category" Column:

Let's apply one-hot encoding to the "Location_Category" column in your provided data:

Original Data:

Number_of_Riders Number_of_Drivers Location_Category Customer_Loyalty_Status Number_of_Past_Rides Average_Ratings Time_of_Booking Vehicle_Type Expected_Ride_Duration Historical_Cost_of_Ride
90 45 Urban Silver 13 4.47 Night Premium 90 284.26
58 39 Suburban Silver 72 4.06 Evening Economy 43 173.87
42 31 Rural Silver 0 3.99 Afternoon Premium 76 329.80
89 28 Rural Regular 67 4.31 Afternoon Premium 134 470.20
78 22 Rural Regular 74 3.77 Afternoon Economy 149 579.68

One-Hot Encoded Data:

Number_of_Riders Number_of_Drivers Urban Suburban Rural Customer_Loyalty_Status Number_of_Past_Rides Average_Ratings Time_of_Booking Vehicle_Type Expected_Ride_Duration Historical_Cost_of_Ride
90 45 1 0 0 Silver 13 4.47 Night Premium 90 284.26
58 39 0 1 0 Silver 72 4.06 Evening Economy 43 173.87
42 31 0 0 1 Silver 0 3.99 Afternoon Premium 76 329.80
89 28 0 0 1 Regular 67 4.31 Afternoon Premium 134 470.20
78 22 0 0 1 Regular 74 3.77 Afternoon Economy 149 579.68

Explanation:

For example: