xgboost๊ฐ ์ด๋ก ์ ์ผ๋ก ์ด๋ป๊ฒ ์๋ํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๊ทธ๋ฌ๋ xgboost๋ ํธ๋ฆฌ ๊ธฐ๋ฐ ๋ถ๋ฅ๊ธฐ์ด๋ฏ๋ก ๊ธฐ๋ฅ์ ์ ๊ทํ๊ฐ ํ์ํ์ง ์๋ค๊ณ ๊ฐ์ ํด๋ ๋ ๊น์?
์๋์ ๊ธฐ๋ฅ์ ์ ๊ทํํ ํ์๊ฐ ์์ต๋๋ค.
์์น์ ์ผ๋ก ๋๋ฌด๋ฅผ ๋ถ์คํธํ ๋ ์ ๊ทํํ ํ์๊ฐ ์๋ค๋ ๊ฒ์ ์ดํดํ๊ณ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ทธ๋ฌ๋ ํนํ ' reg:gamma '๋ฅผ ์ฌ์ฉํ์ฌ ๋์ y๋ฅผ ์กฐ์ ํ ๋ ์๋นํ ์ํฅ์ ๋ณผ ์ ์์ง๋ง ' reg:linear '(๊ธฐ๋ณธ๊ฐ)์ ๋ํด์๋ (๋ ์ ๋) ์ํฅ์ ๋ฏธ์นฉ๋๋ค. ๊ทธ ์ด์ ๋ ๋ฌด์์ ๋๊น?
Boston Housing ๋ฐ์ดํฐ ์ธํธ์ ์:
import numpy as np
import xgboost as xgb
from sklearn.metrics import mean_squared_error
from sklearn.datasets import load_boston
boston = load_boston()
y = boston['target']
X = boston['data']
for scale in np.logspace(-6, 6, 7):
xgb_model = xgb.XGBRegressor().fit(X, y / scale)
predictions = xgb_model.predict(X) * scale
print('{} (scale={})'.format(mean_squared_error(y, predictions), scale))
2.3432734454908335(์ถ์ฒ=1e-06)
2.343273977065266(์ถ์ฒ=0.0001)
2.3432793874455315(์ถ์ฒ=0.01)
2.290595204136888(์ถ์ฒ=1.0)
2.528513393507719(์ถ์ฒ=100.0)
7.228978353091473(์ถ์ฒ=10000.0)
272.29640759874474(์ถ์ฒ=1000000.0)
' reg:gamma '๋ฅผ ์ฌ์ฉํ ๋ y ์ค์ผ์ผ๋ง์ ์ํฅ์ ์ ๋ง ํฝ๋๋ค.
for scale in np.logspace(-6, 6, 7):
xgb_model = xgb.XGBRegressor(objective='reg:gamma').fit(X, y / scale)
predictions = xgb_model.predict(X) * scale
print('{} (scale={})'.format(mean_squared_error(y, predictions), scale))
591.6509503519147(์ถ์ฒ=1e-06)
545.8298971540023(์ถ์ฒ=0.0001)
37.68688286293508(์ถ์ฒ=0.01)
4.039819858716935(์ค์ผ์ผ=1.0)
2.505477263590776(์ถ์ฒ=100.0)
198.94093800190453(์ถ์ฒ=10000.0)
592.1469169959003(์ถ์ฒ=1000000.0)
@tqchen Boosted Trees์ ๋ํ ํ๋ฅญํ
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋์ ๊ธฐ๋ฅ์ ์ ๊ทํํ ํ์๊ฐ ์์ต๋๋ค.