inflearn logo
강의

Course

Instructor

[Side Project After Work] Big Data Analysis Certification Practical Exam (Type 1, 2, 3)

"모의고사2" 질문

Resolved

399

ycann

26 asked

0

선생님!!

궁금한 점을 질문드리면 항상 빠른 답변 드리시는 점에 감사드립니다.

"모의고사2" 관련하여 궁금한점을 질문드립니다.

  1. 평가지표가 f1 인데, f1도 점수가 높은 경우 성능이 좋은건가요? 만약 하이퍼파라미터 투닝을 할 경우 f1 점수가 높게 나오는 것으로 test 데이터를 에측해서 csv 화일을 작성해야 하는 건지요?

  2. '모의고사2'를 시험환경에서 연습하는데, 랜덤포레스트는 큰 문제 없이 진행되었는데, xgboost 모델로 할 경우 진행이 안되고 에러가 발생합니다.

    이유가 무엇이고 어떻게 수정해야 하는지요?

    스크린샷 2023-06-05 162800.png

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

Answer 2

1

roadmap

  1. 네~ f1스코어 높은 것이 좋습니다.
    분류 평가 지표의 경우 대부분 높은 것이 좋고
    회귀 평가 지표는 e가 붙어 있으면 에러 값이에요 대부분 작을 수록 좋습니다 (R2제외)

  2. 전체코드를 올려주시겠어요?

0

ycann

아래 제가 작성한 코드입니다.

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

roadmap

안녕하세요 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

ycann

예, 감사합니다.

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

0

8

1

인덱스 슬라이싱

0

11

2

질문 드립니다.

0

41

2

강의 내용 관련 질문드립니다~

0

40

2

수강 연장 문의

0

44

2

강의자료 일괄 다운로드

0

47

2

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

0

36

2

list 문제 질문드립니다~

0

34

2

빅분기 실기 12회 재도전

0

47

2

강의 기간 연장 가능여부 검토 요청건

0

34

2

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

0

43

2

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

0

49

2

질문이요

0

52

2

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

0

55

2

문제 3-2 질문드립니다

0

46

2

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

0

61

2

변수, 칼럼 , df 구분

0

51

2

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

0

50

2

수강기간 연장 문의

0

49

2

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

0

42

2

수강기한 연장 문의

0

81

2

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

0

60

2

결정트리에서 적절한 깊이 선택 후 시각화 과정에서 학습 데이터만 사용하는 이유

0

45

2

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

0

72

2