레이블 인코딩이 안되는 이유가 궁금합니다
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()
어쨌든 신택스 문제는 아니라는 말씀이시죠?ㅠㅠ
로지스틱회귀, 회귀
0
25
2
회귀 문제를 풀때 질문입니다.
0
31
1
불균형 처리 후 성능이 더 낮아졌다면,
0
44
2
실기 체험 제2유형 에러 문의
0
34
1
LIGHTGBM 으로 하면 pred값이 소수점 6자리까지 나오는게 맞나요
0
33
2
3번문제 등분산 가정
0
34
2
작업형3 target 형 변환 질문
0
29
2
[작업형1] 연습문제 섹션1 ~ 10 의 section4
0
23
3
원핫인코딩과 레이블 인코딩에서 concat
0
42
2
제2유형 질문입니다.
0
39
2
C()
0
36
2
작업형 2에서 strafity 적용 유무
0
43
2
수강 기간 연장 가능 여부 문의드립니다.
0
45
1
ols
0
36
2
2유형 작성관련 질문(일반 심화)
0
29
2
2유형 작성관련 질문
0
26
2
2유형 object컬럼 개수 다르면
0
36
2
코딩팡질문이요ㅠㅠ
0
36
2
관찰값과 기대값의 개념이 헷갈립니다.
0
19
2
작업형2 ID 컬럼 삭제 질문
0
38
2
2유형 작성관련 질문
0
27
2
memoryerror 질문
0
20
2
작업형 유형2 이렇게 고정 템플릿으로 가져가도 될까요?
0
37
1
ID 삭제 필수 인가요?
0
33
3





