예시문제 신용카드 데이터 문제 문의
# 출력을 원하실 경우 print() 함수 활용
# 예시) print(df.head())
# getcwd(), chdir() 등 작업 폴더 설정 불필요
# 파일 경로 상 내부 드라이브 경로(C: 등) 접근 불가
# 데이터 파일 읽기 예제
import pandas as pd
X_test = pd.read_csv("data/X_test.csv")
X_train = pd.read_csv("data/X_train.csv")
y_train = pd.read_csv("data/y_train.csv")
# 사용자 코딩
# 답안 제출 참고
# 아래 코드 예측변수와 수험번호를 개인별로 변경하여 활용
# pd.DataFrame({'cust_id': X_test.cust_id, 'gender': pred}).to_csv('003000000.csv', index=False)
# print(X_test.shape, X_train.shape, y_train.shape)
# print(X_test.isnull().sum())
# print(X_test['환불금액'].describe())
# print(X_train.isnull().sum())
# print(y_train.isnull().sum())
# print(X_test.shape, X_train.shape, y_train.shape)
# print(X_train.isnull().sum())
X_test['환불금액'] = X_test['환불금액'].fillna(0)
X_train['환불금액'] = X_train['환불금액'].fillna(0)
# print(X_train.isnull().sum())
# print(X_test.shape, X_train.shape)
# print(X_test.describe(include ='object'))
# print(X_train.describe(include ='object'))
# print(X_test.shape, X_train.shape)
# con_data = X_train.concat(X_test.)
print(X_test.shape, X_train.shape)
cust_ID= X_test.pop('cust_id')
X_train = X_train.drop('cust_id',axis =1)
y_cust_ID = y_train.pop('cust_id')
print(X_test.shape, X_train.shape)
print(y_train.head())
X_com = pd.concat([X_test, X_train],axis=0)
X_com = pd.get_dummies(X_com)
print(X_com.shape)
X_test = X_com.iloc[0:2482,:]
X_train = X_com.iloc[2482:5982,:]
print(X_test.shape, X_train.shape,y_train.shape)
from sklearn.model_selection import train_test_split
X_tr, X_val, y_tr, y_val =train_test_split(X_train,y_train,test_size =0.1,random_state =0)
print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape)
import lightgbm as lgm
model = lgm.LGBMClassifier()
model.fit(X_tr, y_tr)
pred = model.predict_proba(X_val)
마지막에서 오류가 발생했습니다.
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)
# from sklearn.ensemble import RandomForestClassifier
# rf = RandomForestClassifier()
# rf.fit(X_tr, y_tr)
# pred = rf.predict_proba(X_val)
랜덤 포레스트로 돌려도 같은 오류가 발생합니다
어떤걸 잘못한건가요?
답변 1
0
train_test_split(X_train,y_train['타겟 컬럼'])
y_train['타겟 컬럼'] -> 이 부분이 시리즈 형태여야 합니다. 현재 데이터 프레임 형태임
출력값 질문
0
12
1
수업노트가 어디에 있나요?
0
21
1
실기시험 제출관련
0
154
2
6.20 작업형 2 과적합
0
158
3
코딩팡 장업형2 베이스 라인 인코딩 종류 질문
0
50
2
로지스틱회귀, 회귀
0
48
2
회귀 문제를 풀때 질문입니다.
0
56
1
불균형 처리 후 성능이 더 낮아졌다면,
0
62
2
실기 체험 제2유형 에러 문의
0
61
1
LIGHTGBM 으로 하면 pred값이 소수점 6자리까지 나오는게 맞나요
0
50
2
3번문제 등분산 가정
0
48
2
작업형3 target 형 변환 질문
0
35
2
[작업형1] 연습문제 섹션1 ~ 10 의 section4
0
36
3
원핫인코딩과 레이블 인코딩에서 concat
0
59
2
제2유형 질문입니다.
0
46
2
C()
0
44
2
작업형 2에서 strafity 적용 유무
0
52
2
수강 기간 연장 가능 여부 문의드립니다.
0
61
1
ols
0
43
2
2유형 작성관련 질문(일반 심화)
0
39
2
2유형 작성관련 질문
0
41
2
2유형 object컬럼 개수 다르면
0
48
2
코딩팡질문이요ㅠㅠ
0
45
2
관찰값과 기대값의 개념이 헷갈립니다.
0
25
2





