Linked Questions

37 votes
16 answers
57k views

I am using the label encoder to convert categorical data into numeric values. How does LabelEncoder handle missing values? from sklearn.preprocessing import LabelEncoder import pandas as pd import ...
saurabh agarwal's user avatar
30 votes
3 answers
11k views

Suppose I have a data frame data with strings that I want converted to indicators. I use pandas.get_dummies(data) to convert this to a dataset that I can now use for building a model. Now I have a ...
Ellis Valentiner's user avatar
15 votes
10 answers
68k views

I have a series like: df['ID'] = ['ABC123', 'IDF345', ...] I'm using scikit's LabelEncoder to convert it to numerical values to be fed into the RandomForestClassifier. During the training, I'm doing ...
Xavier's user avatar
  • 257
18 votes
1 answer
27k views

How can I handle unknown values for label encoding in sk-learn? The label encoder will only blow up with an exception that new labels were detected. What I want is the encoding of categorical ...
Georg Heiler's user avatar
  • 17.9k
8 votes
2 answers
9k views

My data consists of 50 columns and most of them are strings. I have a single multi-class variable which I have to predict. I tried using LabelEncoder in scikit-learn to convert the features (not ...
Huga's user avatar
  • 571
0 votes
3 answers
7k views

So my code like is: >>> le = preprocessing.LabelEncoder() >>> le.fit(train["capital city"]) LabelEncoder() >>> list(le.classes_) ['amsterdam', 'paris', 'tokyo'] >>>...
Flair's user avatar
  • 2,957
0 votes
0 answers
3k views

I've been using LabelEncoder to transform my data into floats. The problem is that I can an Date value that I also want to transform. This is the code that I am using: from sklearn.preprocessing ...
Anna Noukou's user avatar
1 vote
3 answers
2k views

I'm currently working on a model to predict a probability of fatality once a person is infected with the Corona virus. I'm using a Dutch dataset with categorical variables: date of infection, fatality ...
Sef's user avatar
  • 81
0 votes
0 answers
744 views

I'm performing the Decision Tree with the help of below sample data. So I've converted the above data to LabelEncoder to perform Decision Tree and successfully created a DT model. So now my ...
Vikas's user avatar
  • 199
1 vote
1 answer
679 views

Summary: Sklearn's LabelEncoder encodes different values into same value. encoder.fit(data) and data_encoded = encoder.transform(data) can be done properly, but when I do encoder.inverse_transform(...
emremrah's user avatar
  • 1,775
1 vote
0 answers
362 views

I have a dataset for which when i try using the label encoder. fit_transform to the train data, i can't use transform() the validation data and i get an error because the test data has some labels ...
Mohamed_Fergany's user avatar
0 votes
0 answers
262 views

I am facing the issue with ValueError: y contains new labels: xxxx. And I found the solution here: sklearn.LabelEncoder with never seen before values. But I am not sure how to convert the sklearn to ...
user3736228's user avatar
0 votes
1 answer
278 views

I was trying to convert string data into numerical data in a CSV excel sheet. It kept giving me an error about previously unseen labels, so I searched it up and found that we can use Label Encoder to ...
Kevin Phillips's user avatar