"모의고사2" 질문
선생님!!
궁금한 점을 질문드리면 항상 빠른 답변 드리시는 점에 감사드립니다.
"모의고사2" 관련하여 궁금한점을 질문드립니다.
평가지표가 f1 인데, f1도 점수가 높은 경우 성능이 좋은건가요? 만약 하이퍼파라미터 투닝을 할 경우 f1 점수가 높게 나오는 것으로 test 데이터를 에측해서 csv 화일을 작성해야 하는 건지요?
'모의고사2'를 시험환경에서 연습하는데, 랜덤포레스트는 큰 문제 없이 진행되었는데, xgboost 모델로 할 경우 진행이 안되고 에러가 발생합니다.
이유가 무엇이고 어떻게 수정해야 하는지요?
답변 2
1
네~ f1스코어 높은 것이 좋습니다.
분류 평가 지표의 경우 대부분 높은 것이 좋고
회귀 평가 지표는 e가 붙어 있으면 에러 값이에요 대부분 작을 수록 좋습니다 (R2제외)전체코드를 올려주시겠어요?
0
아래 제가 작성한 코드입니다.
import pandas as pd
train = pd.read_csv("train.csv")
test = pd.read_csv("test.csv")
pd.set_option('display.max_columns', None)
# print(train.shape, test.shape)
# print(train.head(3))
# print(train.info())
# print(train.describe())
# print(train.isnull().sum())
from sklearn.model_selection import train_test_split
X_tr, X_val, y_tr, y_val = train_test_split(train.drop('target',axis=1), train['target'], test_size=0.1, random_state=2022)
# print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape)
# from sklearn.metrics import f1_score
# from sklearn.ensemble import RandomForestClassifier
# model = RandomForestClassifier(random_state=2022)
# model.fit(X_tr, y_tr)
# pred = model.predict(X_val)
# print(pred[:10])
# print(f1_score(y_val, pred))
from sklearn.metrics import f1_score
from xgboost import XGBClassifier
xgb = XGBClassifier(random_state=2022)
xgb.fit(X_tr, y_tr)
pred = xgb.predict(X_val)
print(pred[:10])
아래는 에러 내용입니다.
프로세스가 시작되었습니다.(입력값을 직접 입력해 주세요)
> [23:06:53] WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
[0 1 0 0 0 1 0 1 1 1]
/usr/local/lib/python3.9/dist-packages/xgboost/compat.py:31: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
from pandas import MultiIndex, Int64Index
/usr/local/lib/python3.9/dist-packages/xgboost/sklearn.py:1146: UserWarning: The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
warnings.warn(label_encoder_deprecation_msg, UserWarning)
/usr/local/lib/python3.9/dist-packages/xgboost/data.py:208: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
from pandas import MultiIndex, Int64Index
프로세스가 종료되었습니다.
1
안녕하세요 xgb 파라미터값을 수정하는 것 외에도 판다스 인덱스를 수정해야 할 것 같아요.
저는 lightgbm을 주로 사용하는데 xgb말고 이걸 추천할게요!!
(영상을 만들땐 lightgbm을 지원을 안 했어서 못넣었거든요)
lightGBM은
XGBoost와 함께 인기있는 부스팅계열 모델입니다.
학습과 예측 속도가 XGBoost에 비해 빠릅니다.
####### 분류 #######
import lightgbm as lgb
model = lgb.LGBMClassifier()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
####### 회귀 #######
import lightgbm as lgb
model = lgb.LGBMRegressor()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
# 하이퍼파라미터 튜닝은 모의고사3 - xgboost 영상과 동일하게 사용하면 됩니다.
데이터 전처리 관련
0
9
2
시험에서 문제 불러오기
0
7
2
2번문제 출력값 질문
0
12
2
pd.get_dummies()가 bool로 반환
0
13
2
대응표본검정 레빈
0
17
3
단일표본검정 문제 유형
0
17
2
[작업형 3] 6~7. 카이제곱 검정
0
15
2
9회 작업형3 문제 1-1
0
26
2
최종답안 계산 방식 질문
0
17
1
시험 치기 전 급하게 질문 사항
0
29
2
유형3
0
28
2
작업형 2 연습문제 섹션 3
0
18
2
11 기출문제 ipynb파일
0
27
2
작업형 3 유형
0
24
2
11회 기출 유형(작업형1) 2번 정답
0
22
2
f1 score 질문
0
19
2
10회 작업형 2 인코딩 질의
0
19
2
53번 강의에서 갑자기 수업노트가 없어졌습니다.
0
23
2
28:19 roc_auc이유
0
22
2
수강연장문의
0
25
2
전체적인 머신러닝 순서
0
27
2
빅분기 실기 유형2질문
0
27
1
ID 전처리 이유
0
34
2
데이터제공
0
33
2





