Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

labelencoder update

# train and test are pandas.DataFrame's and c is whatever column
le = LabelEncoder()
le.fit(train[c])
test[c] = test[c].map(lambda s: '<unknown>' if s not in le.classes_ else s)
le.classes_ = np.append(le.classes_, '<unknown>')
train[c] = le.transform(train[c])
test[c] = le.transform(test[c])
Comment

PREVIOUS NEXT
Code Example
Python :: wav file to array python 
Python :: python flask api 
Python :: example of ternary operator in python 
Python :: rust vs python 
Python :: windows how to store filepath as variabley python 
Python :: pip matplotlib 
Python :: python for loop with index 
Python :: Python Tkinter RadioButton Widget 
Python :: how to add captcha in django forms 
Python :: run a python script from another python script on a raspberry pi 
Python :: python line break inside string 
Python :: python string in list 
Python :: python if condition 
Python :: len python 
Python :: how to set numerecal index in pandas 
Python :: how to use for loop to take n number of input in python 
Python :: raspi setup gpio 
Python :: remove file os python 
Python :: how to revert a list python 
Python :: enumerate in range python 
Python :: restrict ticks to integers matplotlib 
Python :: convert .py to exe 
Python :: python for in for in 
Python :: NumPy resize Example 
Python :: how to make software in python 
Python :: serializer phonenumber field json 
Python :: IQR to remove outlier 
Python :: python add 1 to 100 
Python :: tkinter filedialog how to show more than one filetype 
Python :: django choicefield empty label 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =