I am working on Python’s jupiter notebook platform.I have a dataset whose output consists of 4 different labels and whose output data is a categorical variable. I coded this output data with Label encoder as 1st class-0, 2nd class-1, 3rd class-2 and 4th class-3. But since I dont want there to be a sorting between these classifications based on bigness and smallness, I performed the onehotencoder operation.Does the code I wrote work correctly or or is there any shortcomings in this code? Or this output class how else can I classify them as 0,1,2,3 without any sorting relationship between them?
fd["labelnum"]=fd["label"]
le=preprocessing.LabelEncoder()
fd['labelnum']=le.fit_transform(fd['labelnum'])#1.Class=0 2.Class=1 3.Class=2 4.Class=3
ohe=ColumnTransformer([("ohe",OneHotEncoder(dtype=int),fd['labelnum'])],remainder="passthrough")here
MZNG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.