범주형 데이터 (1) 썸네일형 리스트형 범주형 데이터 다루기 순서가 없는 범주형 특성 인코딩하기 import numpy as np from sklearn.preprocessing import LabelBinarizer, MultiLabelBinarizer # 특성 생성 feature = np.array([["Texas"], ["California"], ["Texas"], ["Delaware"], ["Texas"]]) # 원-핫 인코더 생성 one_hot = LabelBinarizer() # 특성을 원-핫 인코딩 print(one_hot.fit_transform(feature)) # 결과 [[0 0 1] [1 0 0] [0 0 1] [0 1 0] [0 0 1]] # 특성의 클래스 확인 print(one_hot.classes_) # 결과 ['California' 'D.. 이전 1 다음