inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

예시문제 작업형2(ver. 2023)

roc_auc에서 DataConversionWarning 발생

해결된 질문

149

nahye1137

작성한 질문수 10

0

체험환경 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)

프로세스가 종료되었습니다.

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

답변 1

0

퇴근후딴짓

c_train[i] = le.fit_transform(c_train[i])

c_test[i] = le.transform(c_test[i])

인코딩시 컬럼 1개씩 시리즈 형태로 입력합니다. 따라서 대괄호 1개만 사용하면 됩니다.

작업형 1번문제... 환경관련

0

9

1

12회 기출은 언제 업데이트 될까요??

0

9

1

8/6 작성한 연장문의 질문글에 대한 재요청

0

24

1

수강기간 연장 문의

0

25

1

수강기간 연장문의

0

26

1

수강기간 연장 요청 문의드립니다

0

30

1

수강 기간 연장 문의

0

35

1

수강연장 가능 문의 (기간 약 한달반)

0

54

2

수강기간 연장 가능할까요 선생님

0

70

2

Section15. 수업에 사용하는 데이터 주소가 다 보이지 않아서 실습을 위한 데이터를 다운 받지 못하고 있습니다.

0

47

3

수강연장요청 문의

0

83

2

아무래도 다음 시험 연장은 어렵겠죠?

0

103

2

빅분기 12회 결과 관련 문의

0

107

1

책이랑 강의랑 순서나 예제가 다른것 같네요

0

78

2

수강연장 문의

0

102

2

재검토 요청 방법 좀 알려주셔요...-.-;;

0

101

2

12회 실기 질문(작업형 2)

0

88

2

뒤로가기 버튼 같은 것이 있나요?

0

61

1

강의 연장 문의

0

97

2

출력값 질문

0

69

2

수업노트가 어디에 있나요?

0

59

1

실기시험 제출관련

0

222

3

6.20 작업형 2 과적합

0

227

3

코딩팡 장업형2 베이스 라인 인코딩 종류 질문

0

86

2