데이터 전처리 - Label Encoding, One Hot Encoding
머신 러닝 알고리즘은 단어나 글자 데이터를 가지고 학습을 할 수 없다. 숫자로 바꿔줘야 학습이 가능하다. 즉, 글자나 단어를 숫자로 바꿔주는 전처리 작업이 없이는 학습을 시킬 수 없다는 뜻이다. Label Encoding from sklearn.preprocessing import LabelEncoder ds=['태조','세종','성종','영조','정조','태조'] # 객체 생성 encoder = LabelEncoder() # fit과 transform 으로 label 인코딩 수행. encoder.fit(ds) labels = encoder.transform(ds) print('인코딩 :', labels) 결과값은 인코딩 : [4 1 0 2 3 4] 이다. 태조 -> 4, 세종 -> 1, 성종 -> 0와..