인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

옥준호's profile image
옥준호

asked

[After-work activities] Big Data Analysis Engineer Practical (Work-type 1,2,3)

섹션 11 작업형2 구버전 문의

Resolved

Written on

·

166

0

피처엔지니어링 부분에서

from sklearn.preprocessing import LabelEncoder
cols = ['주구매상품', '주구매지점']

for col in cols:
    le = LabelEncoder()
    X_train[col] = le.fit_transform(X_train[col])
    X_test[col] = le.transform(X_test[col])

X_train.head()

이 코드 실행했을때 ValueError: invalid literal for int() with base 10: '골프' 이런 에러가 뜨는데 이유가 무엇인가요..?

python머신러닝빅데이터pandas빅데이터분석기사

Answer 1

0

roadmap님의 프로필 이미지
roadmap
Instructor

train에는 없는 카테고리가 test에 있는 것이 아닐까 의심이 드네요! LabelEncoder는 학습 데이터에 기반하여 레이블을 생성하므로, 테스트 데이터에 학습 데이터에 없는 새로운 범주가 있다면 문제가 발생할 수 있습니다.

train과 test 합쳐서 인코딩이 필요할 것 같습니다. 🙌

옥준호's profile image
옥준호

asked

Ask a question