Handling categorical data with sklearn.

I’ve used sklearn(scikit-learn) package in python. In sklearn, I cannot directly put categorical data like ‘Sex’ which has string date, ‘male’ and ‘female’. So, I have to convert string to int or something.  import pandas as pd train = pd.read_csv(‘train.csv’) for i, sex in enumerate(train.Sex):     if sex==’male’:         train.Sex[i]=1     else:         train.Sex[i]=0 This is so tiring. What is more, how can I do with more complex data which has over three. I’d like to know useful methods to handle categorial data. Thanks.


Link to Full Article: Handling categorical data with sklearn.

Pin It on Pinterest

Share This

Join Our Newsletter

Sign up to our mailing list to receive the latest news and updates about homeAI.info and the Informed.AI Network of AI related websites which includes Events.AI, Neurons.AI, Awards.AI, and Vocation.AI

You have Successfully Subscribed!