boostcampaitech7 / level2-competitiveds-recsys-06

level2-competitiveds-recsys-06 created by GitHub Classroom
2 stars 0 forks source link

[Model] XGBoost #47

Closed 13aek closed 1 week ago

13aek commented 2 weeks ago
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error
# # 학습에 사용할 특징 열
# feature_columns = [col for col in data.columns if col not in ['deposit', '_type', 'index']]
# 학습 및 테스트 데이터 준비
X_train = train_data.drop(columns=['deposit'])
y_train = train_data['deposit']
X_test = test_data.copy()
# 학습 데이터를 검증용으로 분할
X_train_split, X_val_split, y_train_split, y_val_split = train_test_split(X_train, y_train, test_size=0.2, random_state=42)
# XGBoost를 위한 DMatrix 생성
dtrain = xgb.DMatrix(X_train_split, label=y_train_split)
dval = xgb.DMatrix(X_val_split, label=y_val_split)
dtest = xgb.DMatrix(X_test)
# XGBoost 파라미터 설정
params = {
    'objective': 'reg:absoluteerror',
    'eval_metric': 'mae',
    'max_depth': 6,
    'eta': 0.05,
    'subsample': 0.8,
    'colsample_bytree': 0.8,
    'seed': 42
}
# 모델 학습
evals = [(dtrain, 'train'), (dval, 'eval')]
model = xgb.train(params, dtrain, num_boost_round=500, early_stopping_rounds=50, evals=evals, verbose_eval=10)
# 테스트 세트에 대한 예측
y_pred = model.predict(dtest)
13aek commented 2 weeks ago

XGBoost 1

13aek commented 2 weeks ago

XGBoost 2

13aek commented 2 weeks ago

XGBoost 3

13aek commented 2 weeks ago

XGBoost 4

13aek commented 2 weeks ago

XGBoost 5

13aek commented 2 weeks ago

XGBoost 6

13aek commented 2 weeks ago

XGBoost 6

13aek commented 2 weeks ago

XGBoost 7

13aek commented 2 weeks ago

XGBoost 8

13aek commented 2 weeks ago

XGBoost 9

13aek commented 1 week ago

241021 기준점

XGBoost 10

13aek commented 1 week ago

XGBoost 11

13aek commented 1 week ago

XGBoost 12

13aek commented 1 week ago

XGBoost 12

13aek commented 1 week ago

XGBoost 13

13aek commented 1 week ago

XGBoost 14

13aek commented 1 week ago

XGBoost 15

13aek commented 1 week ago

XGBoost 16

13aek commented 1 week ago

XGBoost 17

13aek commented 1 week ago

XGBoost 18

13aek commented 1 week ago

XGBoost 19

13aek commented 1 week ago

XGBoost 20