레이블 인코딩이 안되는 이유가 궁금합니다
import pandas as pd
train = pd.read_csv("5_train.csv")
test = pd.read_csv("5_test.csv")
#EDA
train.head()
train.shape, test.shape
# train.info()
# train['price'].value_counts()
train.isnull().sum()
test.isnull().sum()
cols = train.select_dtypes(include='O').columns
print(train.shape, test.shape)
# #Label Encoding
from sklearn.preprocessing import LabelEncoder
for col in cols:
le = LabelEncoder()
train[col] = le.fit_transform(train[col])
test[col] = le.transform(test[col])
print(train.shape, test.shape)안녕하세요 선생님!
에러는 안 나는데 레이블인코딩이 안되는데 뭐가 문제인지 모르겠습니다..!
답변 1
0
에러도 복사-붙여넣기 부탁드려요!
코드상에 큰 문제 없는 것으로 보아. 다시 한번 실행해주시고
train과 test 데이터셋의 범주형 컬럼의 고유값을 출력해서 비교해 보시죠!
차이가 있을 수 있습니다.
0
올려주신 기출문제(다중분류) 4회를 푸는데 에러는 전혀 안 뜨는데 레이블 인코딩만 안되어서요!ㅠㅠ
# 1. 문제정의
# 평가: f1 macro
# target: Segmentation
# 최종파일: result.csv(컬럼 1개 pred)
#테스트 데이터 2154개 로우 확인
# 2. 라이브러리 및 데이터 불러오기
import pandas as pd
train = pd.read_csv("4_train.csv")
test = pd.read_csv("4_test.csv")
train.head()
test.head()
train['Segmentation'].value_counts()
train.shape, test.shape
# train.info()
train.isnull().sum()
test.isnull().sum()
print(train.describe(include='O'))
print(test.describe(include='O'))
cols = train.select_dtypes(include='object').columns
print(train.shape, test.shape)
#Label Encoding
from sklearn.preprocessing import LabelEncoder
for col in cols:
le = LabelEncoder()
train[col] = le.fit_transform(train[col])
test[col] = le.transform(test[col])
print(train.shape, test.shape)
# train.head()
어쨌든 신택스 문제는 아니라는 말씀이시죠?ㅠㅠ
기출 7회 작업형2 평가지표 문의드립니다.
0
3
1
수강연장 문의 드립니다!
0
5
1
수강연장 문의드립니다
0
7
1
작업형2모의문제3_updated2026.10
0
21
2
작업형2 모의문제3_updated2026.10
0
23
2
38강에서 불균형 데이터 처리하는 stratify를 꼭 해줘야하는건지 질문합니다.
0
20
2
수강강의 연장 관련 문의
0
28
2
작업형1_연습문제1 section2
0
28
2
수강기간 연장 문의드립니다
0
33
2
작업형2 모의문제2_updated2026.10
0
35
2
수강기간 연장문의
0
36
2
작업형 2 질문
0
39
2
강의 연장 관련하여 문의드립니다.
0
50
2
섹션7 자료 다운로드
0
45
2
작업형 1 연습문제 Section12
0
45
2
수강기간 연장 문의
0
57
2
안녕하세요, 혹시 수강기간 연장이 가능할까요?
0
50
2
판다스 강의자료는 어디서 받을 수 있나요?
0
56
2
작업형2 모의고사3 자료 업데이트 요청
0
64
4
수강 연장가능여부 문의드립니다!
0
51
2
수강기간 연장 문의드립니다!
0
45
2
최빈값
0
48
2
수강 가이드라인
0
43
2
수강 연장 가능 여부 문의
0
66
2





