Jika saya melatih model saya menggunakan kode berikut:
import xgboost as xg
params = {'max_depth':3,
'min_child_weight':10,
'learning_rate':0.3,
'subsample':0.5,
'colsample_bytree':0.6,
'obj':'reg:linear',
'n_estimators':1000,
'eta':0.3}
features = df[feature_columns]
target = df[target_columns]
dmatrix = xg.DMatrix(features.values,
target.values,
feature_names=features.columns.values)
clf = xg.train(params, dmatrix)
selesai dalam waktu sekitar 1 menit.
Jika saya melatih model saya menggunakan metode belajar Sci-Kit:
import xgboost as xg
max_depth = 3
min_child_weight = 10
subsample = 0.5
colsample_bytree = 0.6
objective = 'reg:linear'
num_estimators = 1000
learning_rate = 0.3
features = df[feature_columns]
target = df[target_columns]
clf = xg.XGBRegressor(max_depth=max_depth,
min_child_weight=min_child_weight,
subsample=subsample,
colsample_bytree=colsample_bytree,
objective=objective,
n_estimators=num_estimators,
learning_rate=learning_rate)
clf.fit(features, target)
dibutuhkan lebih dari 30 menit.
Saya akan berpikir kode yang mendasarinya hampir persis sama (yaitu XGBRegressor
panggilan xg.train
) - apa yang terjadi di sini?
sumber