I`m using sklearn library to encode one column with categorical data to One Hot Encoder values.
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [3])], remainder='passthrough')
X = np.array(ct.fit_transform(X))
Is there a method in sklearn library to print a list of categorical values with assigned One Hot Encoder code?
For example, if I have categorical data "A", "B", "C", I want it to print something like "A" 0 0 1, "B" 0 1 0,"C" 1 0 0, so I can track back which code to which value was assigned.
I tried to use .get_feature_names() method, but it gives me error.
source https://stackoverflow.com/questions/76095583/print-a-list-of-one-hot-encoder-values
Comments
Post a Comment