Label Encoder and One Hot Encoder are classes of the SciKit Learn library in Python.
It converts categorical text data into model-understandable numerical data, we use the Label Encoder class. For label encoding, import the LabelEncoder class from the sklearn library, then fit and transform your data.
from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
x[:, 0] = labelencoder.fit_transform(x[:, 0])
One Hot Encoder
It takes a column which has categorical data, which has been label encoded and then splits the column into multiple columns. The numbers are replaced by 1s and 0s, depending on which column has what value.
from sklearn.preprocessing import OneHotEncoder
onehotencoder = OneHotEncoder(categorical_features = )
x = onehotencoder.fit_transform(x).toarray()
For your problem, you can use OneHotEncoder to encode features of your dataset.
Hope this answer helps.
Study Natural Language Processing comprehensively with the help of this video tutorial:
If you wish to learn more about Python, visit Python tutorial and Python course by Intellipaat.