예시문제 작업형2 test 데이터 예측시 발생하는 오류
해결된 질문
728
작성자 없음
0
안녕하세요! 복습하는 도중에 이런 에러가 발생되어 질문드립니다 ㅠㅠ
import pandas as pd
X_train = pd.read_csv('X_train.csv',encoding="euc-kr")
y_train = pd.read_csv('y_train.csv')
X_test = pd.read_csv('X_test.csv',encoding="euc-kr")
print(X_train.shape,y_train.shape)
# X_train.head()
# y_train.head()
# X_train.info() #X_train 환불금액 결측치, 오브젝트 두개
# y_train.info()
X_train = X_train.fillna(0)
X_train.isnull().sum()
X_train = X_train.drop(['cust_id'],axis=1)
cust_id = X_test.pop('cust_id')
#라벨인코딩
from sklearn.preprocessing import LabelEncoder
cols = X_train.select_dtypes( include = 'object').columns
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()
#검증데이터 분리
from sklearn.model_selection import train_test_split
X_tr, X_val, y_tr, y_val = train_test_split(X_train,
y_train['gender'],
test_size = 0.2,
random_state = 2022)
X_tr.shape, X_val.shape, y_tr.shape, y_val.shape
#모델링 - 랜덤포레스트
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score
model = RandomForestClassifier(random_state=2022)
model.fit(X_tr,y_tr)
pred = model.predict_proba(X_val)
roc_auc_score(y_val,pred[:,1])
pred = model.predict_proba(X_test) <------------------이 과정에서 발생되는 오류입니다
pred
ValueError: Input X contains NaN. RandomForestClassifier does not accept missing values encoded as NaN natively.
라는 에러가 발생합니다 ㅠㅠ
코드를 검토해봐도 이상은 없는거같은데.. 뭐가문제일까요? ㅠㅠ
뒤로가기 버튼 같은 것이 있나요?
0
19
1
강의 연장 문의
0
17
1
출력값 질문
0
26
2
수업노트가 어디에 있나요?
0
27
1
실기시험 제출관련
0
158
2
6.20 작업형 2 과적합
0
164
3
코딩팡 장업형2 베이스 라인 인코딩 종류 질문
0
51
2
로지스틱회귀, 회귀
0
51
2
회귀 문제를 풀때 질문입니다.
0
58
1
불균형 처리 후 성능이 더 낮아졌다면,
0
64
2
실기 체험 제2유형 에러 문의
0
64
1
LIGHTGBM 으로 하면 pred값이 소수점 6자리까지 나오는게 맞나요
0
51
2
3번문제 등분산 가정
0
49
2
작업형3 target 형 변환 질문
0
36
2
[작업형1] 연습문제 섹션1 ~ 10 의 section4
0
39
3
원핫인코딩과 레이블 인코딩에서 concat
0
60
2
제2유형 질문입니다.
0
48
2
C()
0
44
2
작업형 2에서 strafity 적용 유무
0
52
2
수강 기간 연장 가능 여부 문의드립니다.
0
61
1
ols
0
44
2
2유형 작성관련 질문(일반 심화)
0
40
2
2유형 작성관련 질문
0
41
2
2유형 object컬럼 개수 다르면
0
48
2





