roc_auc에서 DataConversionWarning 발생
체험환경 2유형 학습중에 DataConversionWarning가 발생해서 문의드립니다. 아래와 같이 코드 작성 후에 roc_auc로 성능평가하는 과정에서 워닝이 발생했는데 이유가 무엇인가요??
# print(train.shape, test.shape) # (3500, 11) (2482, 10)
# print(train.isnull().sum())
# print(test.isnull().sum())
train = train.fillna({'환불금액' : train['환불금액'].median()})
test = test.fillna({'환불금액' : test['환불금액'].median()})
# print(train.isnull().sum().sum())
# print(test.isnull().sum().sum())
# print(train.info())
# print(test.info())
# print(train.describe(include='O'))
# print(test.describe(include='O'))
# print(train.head())
target = train.pop('성별')
train = train.drop(['회원ID'], axis=1)
test_id = test.pop('회원ID')
# print(train.shape, test.shape)
c_train = train.select_dtypes(exclude='number')
n_train = train.select_dtypes(include='number')
c_test = test.select_dtypes(exclude='number')
n_test = test.select_dtypes(include='number')
from sklearn.preprocessing import LabelEncoder
for i in c_train.columns:
le = LabelEncoder()
c_train[i] = le.fit_transform(c_train[[i]])
c_test[i] = le.transform(c_test[[i]])
train = pd.concat([c_train, n_train], axis=1)
test = pd.concat([c_test, n_test], axis=1)
# print(train.head())
# print(train.shape, test.shape)
from sklearn.model_selection import train_test_split
x_tr, x_val, y_tr, y_val = train_test_split(train, target, random_state=2024, test_size=0.2, stratify=target)
print(x_tr.shape, x_val.shape, y_tr.shape, y_val.shape)
from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(random_state=2024)
rfc.fit(x_tr, y_tr)
pred1 = rfc.predict_proba(x_val)
print(pred1[:,1].shape)
print(y_val.shape)
from sklearn.metrics import roc_auc_score
print(roc_auc_score(y_val, pred1[:,1]))
>>
프로세스가 시작되었습니다.(입력값을 직접 입력해 주세요)
> (2800, 9) (700, 9) (2800,) (700,)
(700,)
(700,)
0.6341283030687979
/usr/local/lib/python3.9/dist-packages/sklearn/utils/validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
return f(*args, **kwargs)
/usr/local/lib/python3.9/dist-packages/sklearn/utils/validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
return f(*args, **kwargs)
/usr/local/lib/python3.9/dist-packages/sklearn/utils/validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
return f(*args, **kwargs)
/usr/local/lib/python3.9/dist-packages/sklearn/utils/validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
return f(*args, **kwargs)
프로세스가 종료되었습니다.
답변 1
질문 드립니다.
0
36
2
강의 내용 관련 질문드립니다~
0
34
2
수강 연장 문의
0
31
1
강의자료 일괄 다운로드
0
40
2
수강기간 연장 문의드립니다
0
27
1
list 문제 질문드립니다~
0
28
2
빅분기 실기 12회 재도전
0
39
1
강의 기간 연장 가능여부 검토 요청건
0
30
1
수강기간 연장 문의 드립니다
0
36
2
수강기간 연장 문의드립니다
0
46
2
질문이요
0
50
2
수강기간 연장 문의드립니다.
0
48
2
문제 3-2 질문드립니다
0
43
2
수강기간 연장 문의 드립니다.
0
57
2
변수, 칼럼 , df 구분
0
47
2
수강기간 연장 문의드립니다.
0
49
2
수강기간 연장 문의
0
46
2
수강기간 연장 문의드립니다.
0
40
2
수강기한 연장 문의
0
75
2
수강기간 연장 문의드립니다
0
57
2
결정트리에서 적절한 깊이 선택 후 시각화 과정에서 학습 데이터만 사용하는 이유
0
44
2
수강기간 연장 문의드립니다.
0
69
2
수강연장 문의
0
76
2
수강연장문의
0
53
2





