Xgboost: v1.2.1κ³Ό λ§ˆμŠ€ν„° λΈŒλžœμΉ˜μ—μ„œ λ‹€λ₯Έ 예츑

에 λ§Œλ“  2020λ…„ 11μ›” 06일  Β·  35μ½”λ©˜νŠΈ  Β·  좜처: dmlc/xgboost

μ €λŠ” 1.2.1 버전을 개발용으둜 μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 파이썬으둜 μ„€μΉ˜κ°€ 쉽기 λ•Œλ¬Έμž…λ‹ˆλ‹€. λ˜ν•œ c_apiλ₯Ό μ‚¬μš©ν•˜μ—¬ μ˜ˆμΈ‘μ„ μœ„ν•œ κ°„λ‹¨ν•œ c μ½”λ“œλ₯Ό μž‘μ„±ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. v1.2.1 libxgboost.so에 μ—°κ²°λœ 경우 pythonκ³Ό c κ°„μ˜ 예츑 μ°¨μ΄λŠ” μ •ν™•νžˆ 0μž…λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ λ§ˆμŠ€ν„° λΈŒλžœμΉ˜μ—μ„œ libxgboost.so둜 μ—°κ²°ν•˜λ©΄(2020λ…„ 11μ›” 5일 f3a425398 컀밋) 차이가 μžˆμŠ΅λ‹ˆλ‹€.

정적 libλ₯Ό κ΅¬μΆ•ν•˜κ³  μ‹ΆκΈ° λ•Œλ¬Έμ— master 브랜치λ₯Ό μ‚¬μš©ν•˜μ—¬ μ‹€μ œ μ‹œμŠ€ν…œμ— c μ½”λ“œλ₯Ό λ°°ν¬ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€. 이제 v1.2.1κ³Ό master 브랜치의 예츑 차이가 μ €λ₯Ό λ°©ν•΄ν•©λ‹ˆλ‹€.

감사 ν•΄μš”.

wontfix

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

@ShvetsKS

μš°λ¦¬λŠ” κ·ΈλŸ¬ν•œ 차이λ₯Ό λ―Έλž˜μ— μ€‘μš”ν•˜λ‹€κ³  μƒκ°ν•©λ‹ˆκΉŒ? 좔둠을 μœ„ν•΄ 뢀동 μ†Œμˆ˜μ  μ—°μ‚°μ˜ μˆœμ„œλ₯Ό λ³€κ²½ν•  수 없도둝 ν•˜λŠ” μ€‘μš”ν•œ μ œν•œ 사항인 것 κ°™μŠ΅λ‹ˆλ‹€.

μ‹€μ œλ‘œ, 우리( @RAMitchell , @trivialfis 및 I)λŠ” 여기에 λ™μ˜ν•©λ‹ˆλ‹€. 예츑의 μ •ν™•ν•œ μž¬ν˜„μ„±μ„ μ˜λ¬΄ν™”ν•˜λŠ” 것은 변경을 μˆ˜ν–‰ν•˜λŠ” λŠ₯λ ₯을 μ‹¬κ°ν•˜κ²Œ λ°©ν•΄ν•  κ²ƒμž…λ‹ˆλ‹€. 뢀동 μ†Œμˆ˜μ  μ‚°μˆ μ€ λΉ„μ—°κ΄€μœΌλ‘œ 유λͺ…ν•˜λ―€λ‘œ 숫자 λͺ©λ‘μ˜ 합은 λ§μ…ˆ μˆœμ„œμ— 따라 μ•½κ°„μ”© λ‹€λ¦…λ‹ˆλ‹€.

XGBoost 1.2.0κ³Ό μ΅œμ‹  master λΆ„κΈ° 간에 예츑이 μ–Όλ§ˆλ‚˜ λ³€κ²½λ˜λŠ”μ§€ μ •λŸ‰ν™”ν•˜λŠ” μ‹€ν—˜μ„ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.
Distribution of change in prediction

1000개의 μ„œλ‘œ λ‹€λ₯Έ μž„μ˜ μ‹œλ“œλ‘œ 데이터λ₯Ό μƒμ„±ν•œ λ‹€μŒ 버전 1.2.0κ³Ό λ§ˆμŠ€ν„°λ₯Ό λͺ¨λ‘ μ‚¬μš©ν•˜μ—¬ 1000개의 ν–‰λ ¬λ‘œ μ˜ˆμΈ‘μ„ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€. 예츑의 λ³€ν™”λŠ” μ‹œλ“œ μ‚¬μ΄μ—μ„œ μ•½κ°„ λ°”λ€Œμ§€λ§Œ κ·Έ μ°¨μ΄λŠ” κ²°μ½” 9.2e-7보닀 크지 μ•ŠμœΌλ―€λ‘œ 예츑 λ³€ν™”λŠ” 논리 였λ₯˜κ°€ μ•„λ‹Œ 뢀동 μ†Œμˆ˜μ  μ‚°μˆ λ‘œ 인해 λ°œμƒν–ˆμ„ κ°€λŠ₯성이 ν½λ‹ˆλ‹€ .

μ‹€ν—˜μš© 슀크립트

**test.py**: λ‹€λ₯Έ μž„μ˜μ˜ μ‹œλ“œλ‘œ 1000개의 행렬을 μƒμ„±ν•˜κ³  이에 λŒ€ν•œ μ˜ˆμΈ‘μ„ μ‹€ν–‰ν•©λ‹ˆλ‹€.

import numpy as np
import xgboost as xgb
import argparse

def main(args):
    m2 = xgb.Booster({'nthread': '4'})  # init model
    m2.load_model('xgb.model.bin')  # load data
    out = {}
    for seed in range(1000):
        rng = np.random.default_rng(seed=seed)
        rx = rng.standard_normal(size=(100, 127 + 7 + 1))
        rx = rx.astype(np.float32, order='C')
        dtest = xgb.DMatrix(rx, missing=0.0)
        out[str(seed)] = m2.predict(dtest)
    np.savez(args.out_pred, **out)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--out-pred', type=str, required=True)
    args = parser.parse_args()
    main(args)
λͺ…λ Ή: `python test.py --out-pred [out.npz]`. Python ν™˜κ²½μ— μ˜¬λ°”λ₯Έ λ²„μ „μ˜ XGBoostκ°€ μžˆλŠ”μ§€ ν™•μΈν•˜μ‹­μ‹œμ˜€. `xgb120.npz`κ°€ XGBoost 1.2.0에 λŒ€ν•œ κ²°κ³Όλ₯Ό μ €μž₯ν•˜κ³  `xgblatest.npz`κ°€ μ΅œμ‹  λ§ˆμŠ€ν„°μ— λŒ€ν•œ κ²°κ³Όλ₯Ό μ €μž₯ν•œλ‹€κ³  κ°€μ •ν•©μ‹œλ‹€. **compare.py**: 예츑 차이에 λŒ€ν•œ νžˆμŠ€ν† κ·Έλž¨ ν”Œλ‘― λ§Œλ“€κΈ°
import numpy as np
import matplotlib.pyplot as plt

xgb120 = np.load('xgb120.npz')
xgblatest = np.load('xgblatest.npz')

percentile_pts = [50, 90, 99]

colors = ['tab:cyan', 'tab:olive', 'tab:green', 'tab:pink']

percentile = {}
for x in percentile_pts:
    percentile[x] = []
percentile['max'] = []

for seed in range(1000):
    diff = np.abs(xgb120[str(seed)] - xgblatest[str(seed)])
    t = np.percentile(diff, percentile_pts)
    for x, y in zip(percentile_pts, t):
        percentile[x].append(y)
    percentile['max'].append(np.max(diff))

bins = np.linspace(0, np.max(percentile['max']), 100)
idx = 0
for x in percentile_pts:
    plt.hist(percentile[x], label=f'Percentile {x}%', bins=bins, alpha=0.8, color=colors[idx])
    idx += 1
plt.hist(percentile['max'], label='Max', bins=bins, alpha=0.8, color=colors[idx])
plt.legend(loc='best')
plt.title('Distribution in prediction difference between XGBoost 1.2.0\nand master branch, tried over seed=[0..1000]')
plt.xlabel('Absolute difference')
plt.ylabel('Frequency')
plt.savefig('foobar.png', dpi=100)

λͺ¨λ“  35 λŒ“κΈ€

버그λ₯Ό μž¬ν˜„ν•  수 μžˆλ„λ‘ 예제 ν”„λ‘œκ·Έλž¨μ„ κ²Œμ‹œν•  수 μžˆμŠ΅λ‹ˆκΉŒ?

λ˜ν•œ Python νŒ¨ν‚€μ§€μ˜ λ§ˆμŠ€ν„° 버전과 C API의 예츑이 λ‹€λ₯Έκ°€μš”?

CPU μ˜ˆμΈ‘μžμ—μ„œ μˆ˜ν–‰λœ 일뢀 μ΅œμ ν™”κ°€ 있으며 λ‹€λ₯Έ 뢀동 μ†Œμˆ˜μ  였λ₯˜λ‘œ 인해 λ‹€λ₯Έ κ²°κ³Όλ₯Ό 생성할 수 μžˆμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ 예, μž¬ν˜„ κ°€λŠ₯ν•œ μ˜ˆκ°€ μžˆμŠ΅λ‹ˆκΉŒ?

λ˜ν•œ Python νŒ¨ν‚€μ§€μ˜ λ§ˆμŠ€ν„° 버전과 C API의 예츑이 λ‹€λ₯Έκ°€μš”?

python νŒ¨ν‚€μ§€μ˜ v1.2.1κ³Ό C API의 λ§ˆμŠ€ν„° 브랜치λ₯Ό λΉ„κ΅ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

@7starsea λ§ˆμŠ€ν„° 브랜치의 Pythonκ³Ό C API의 좜λ ₯도 비ꡐ할 수 μžˆμŠ΅λ‹ˆκΉŒ? λ¬Έμ œλŠ” μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ C API ν•¨μˆ˜κ°€ μ‚¬μš©λ˜λŠ” 방식일 수 μžˆμŠ΅λ‹ˆλ‹€.

@7starsea λ§ˆμŠ€ν„° 브랜치의 Pythonκ³Ό C API의 좜λ ₯도 비ꡐ할 수 μžˆμŠ΅λ‹ˆκΉŒ? λ¬Έμ œλŠ” μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ C API ν•¨μˆ˜κ°€ μ‚¬μš©λ˜λŠ” 방식일 수 μžˆμŠ΅λ‹ˆλ‹€.

λ‚˜λŠ” v1.2.1의 pythonκ³Ό c apiλ₯Ό λΉ„κ΅ν–ˆκ³  μ˜ˆμΈ‘μ€ μ •ν™•νžˆ λ™μΌν•©λ‹ˆλ‹€.

@7starsea μ•Œκ² μŠ΅λ‹ˆλ‹€. λ™μΌν•œ λͺ¨λΈμ—μ„œ μ˜ˆμΈ‘ν•˜λŠ” Python 및 C ν”„λ‘œκ·Έλž¨μ„ λͺ¨λ‘ κ²Œμ‹œν•˜λ©΄ 문제λ₯Ό μΆ”κ°€λ‘œ ν•΄κ²°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

@hcho3 은 ν…ŒμŠ€νŠΈ μ½”λ“œμž…λ‹ˆλ‹€.

https://github.com/7starsea/xgboost-testing

@7starsea 방금 κ·€ν•˜μ˜ 예λ₯Ό μ‹œλ„ν•˜κ³  λ‹€μŒκ³Ό 같은 κ²°κ³Όλ₯Ό μ–»μ—ˆμŠ΅λ‹ˆλ‹€.

difference: [0. 0. 0. 0.] 0.0 0.0

XGBoost의 μ΅œμ‹  컀밋(debeae2509d90ec1d3402a3a185fba7a25113ff1)을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

@7starsea 방금 κ·€ν•˜μ˜ 예λ₯Ό μ‹œλ„ν•˜κ³  λ‹€μŒκ³Ό 같은 κ²°κ³Όλ₯Ό μ–»μ—ˆμŠ΅λ‹ˆλ‹€.

difference: [0. 0. 0. 0.] 0.0 0.0

XGBoost( debeae2 )의 μ΅œμ‹  컀밋을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

ν₯λ―Έλ‘­μŠ΅λ‹ˆλ‹€. 파이썬 버전이 v1.2.1μž…λ‹ˆκΉŒ?

λ‚˜λŠ” μ—¬μ „νžˆ python-version 1.2.1κ³Ό XGBoost( debeae2 )에 μ—°κ²°λœ c api 사이에 μ•½κ°„μ˜ 차이가 μžˆμŠ΅λ‹ˆλ‹€.

@7starsea μ•„λ‹ˆμš”, μ΅œμ‹  μ†ŒμŠ€(commit debeae2509d90ec1d3402a3a185fba7a25113ff1)μ—μ„œ XGBoostλ₯Ό 컴파일 ν–ˆμœΌλ―€λ‘œ v1.2.1보닀 μ΅œμ‹ μž…λ‹ˆλ‹€. λ‚΄ XGBoost Python νŒ¨ν‚€μ§€λŠ” xgboost.__version__ ν•„λ“œμ— λŒ€ν•΄ 1.3.0-SNAPSHOT λ₯Ό μΈμ‡„ν•©λ‹ˆλ‹€.

@hcho3 XGBoost κ°€ λ‹€λ₯Έ 버전(μ΅œμ†Œν•œ 연속 버전) 간에 μΌκ΄€λœ μ˜ˆμΈ‘μ„ μœ μ§€ν•΄μ•Ό ν•˜λŠ”μ§€ κΆκΈˆν•©λ‹ˆλ‹€.
λ˜ν•œ v1.3.0의 μΆœμ‹œλ₯Ό κΈ°λŒ€ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.
(μ§€κΈˆ λ§ˆμŠ€ν„° 브랜치λ₯Ό μ‚¬μš©ν•˜μ—¬ λͺ¨λΈμ„ ν›ˆλ ¨μ‹œμΌœμ•Ό ν•  것 κ°™μŠ΅λ‹ˆλ‹€)
μ‹œκ°„ λ‚΄ μ€˜μ„œ κ³ λ§ˆμ›Œ.

@7starsea 이전 λ²„μ „μ—μ„œ μ €μž₯된 λͺ¨λΈμ„

κ·€ν•˜μ˜ 슀크립트λ₯Ό μ‚¬μš©ν•˜μ—¬ 문제λ₯Ό μž¬ν˜„ν•  수 μ—†μŠ΅λ‹ˆλ‹€. Docker μ΄λ―Έμ§€λ‚˜ VM 이미지λ₯Ό λΉŒλ“œν•˜κ³  κ³΅μœ ν•΄ μ£Όμ‹œκ² μŠ΅λ‹ˆκΉŒ?

@7starsea 참고둜, λ‹€μŒκ³Ό 같이 μ†ŒμŠ€μ—μ„œ XGBoost 1.2.1 λΉŒλ“œλ„ μ‹œλ„ν–ˆμŠ΅λ‹ˆλ‹€.

git clone --recursive https://github.com/dmlc/xgboost -b release_1.2.0 xgb_source
cd xgb_source
mkdir build
cd build
cmake ..
make
cd ../python-package
python setup.py install

κ²°κ³Όκ°€ λ‹€μ‹œ difference: [0. 0. 0. 0.] 0.0 0.0

차이점을 ν™•μΈν•˜λ €λ©΄ 두 가지 λ²„μ „μ˜ XGBoost, Python용 v1.2.1 및

dtest = xgb.DMatrix(rx, missing=0.0)
y1 = m2.predict(dtest)   # # internally using libxgboost.so  v1.2.1

그리고 ν•˜λ‚˜λŠ” cpp용

m1 = XgbShannonPredictor(fname)
y2 = m1.predict(rx2)   # # internally using libxgboost.so from the master branch (debeae2)

λ‚˜λŠ” (λ‚˜μ—κ²Œ μƒˆλ‘œμš΄) 도컀 이미지λ₯Ό λ§Œλ“€λ €κ³  λ…Έλ ₯ν•  것이닀.

ν•œ 번 λ³Όκ²Œμš”.

λ‚˜λŠ” (λ‚˜μ—κ²Œ μƒˆλ‘œμš΄) 도컀 이미지λ₯Ό λ§Œλ“€λ €κ³  λ…Έλ ₯ν•  것이닀.

ν•„μš”ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

μ‹€μ œλ‘œ 문제λ₯Ό μž¬ν˜„ν•˜λŠ” 데 μ„±κ³΅ν–ˆμŠ΅λ‹ˆλ‹€. XGBoost의 dev 버전은 XGBoost 1.2.0κ³Ό λ‹€λ₯Έ μ˜ˆμΈ‘μ„ μƒμ„±ν•˜λŠ” κ²ƒμœΌλ‘œ λ‚˜νƒ€λ‚¬μŠ΅λ‹ˆλ‹€. 그리고 λ¬Έμ œλŠ” μž¬ν˜„ν•˜κΈ° μ‰½μŠ΅λ‹ˆλ‹€. C APIλ₯Ό μ‚¬μš©ν•  ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€.

μž¬ν˜„ κ°€λŠ₯ν•œ 예(νŽΈμ§‘: 랜덀 μ‹œλ“œ μ„€μ •):

import numpy as np
import xgboost as xgb

rng = np.random.default_rng(seed=2020)
rx = rng.standard_normal(size=(100, 127 + 7 + 1))
rx = rx.astype(np.float32, order='C')

m2 = xgb.Booster({'nthread': '4'})  # init model
m2.load_model('xgb.model.bin')  # load data

dtest = xgb.DMatrix(rx, missing=0.0)
y1 = m2.predict(dtest)
print(xgb.__version__)
print(y1)

1.2.0의 좜λ ₯:

1.2.0
[ 0.00698659 -0.00211251  0.00180039 -0.00016004  0.00526169  0.00801963
  0.00016755  0.00226218  0.00276762  0.00408182  0.00303206  0.00291929
  0.01101092  0.0068329   0.00145864  0.00326979  0.00572816  0.01019934
  0.00074345  0.00784767  0.00173795 -0.00219297  0.0060181   0.00606489
  0.00447372  0.00103396  0.00932363  0.00230178  0.00389203  0.00151157
  0.0034163   0.00821933  0.006686    0.00630778  0.00331488  0.00775066
  0.00443819  0.01030204  0.00924486  0.00645933  0.00777653  0.00231206
  0.00457835  0.00390425  0.00947028  0.00410065  0.00220913  0.00292507
  0.00637993  0.00796807  0.00140873  0.00887537  0.00496858  0.01049942
  0.00908098  0.00332722  0.00799242  0.00228494  0.00463879  0.00213429
  0.00729388  0.01049232  0.00790522  0.01269361 -0.00425893  0.00256333
  0.00859573  0.00472835  0.00077197  0.00191873  0.01546788  0.0014475
  0.00888193  0.00648022  0.00115797  0.00351191  0.00580138  0.00614035
  0.00632426  0.00408354  0.00346044 -0.00034332  0.00599384  0.00302595
  0.00657633  0.01086903  0.00625807  0.00096565  0.00061804  0.00038511
  0.00523874  0.00633043  0.00379965  0.00302553 -0.00123322  0.00153473
  0.00725579  0.00836438  0.01295918  0.00737873]

λ©”λͺ¨. XGBoost 1.0.0 및 1.1.0으둜 슀크립트λ₯Ό μ‹€ν–‰ν•˜λ©΄ 1.2.0κ³Ό λ™μΌν•œ 좜λ ₯이 μƒμ„±λ©λ‹ˆλ‹€.

개발 λ²„μ „μ˜ 좜λ ₯(c5645180a6afb9d3d771165e681985fe3522adf6)

1.3.0-SNAPSHOT
[ 0.00698666 -0.00211278  0.00180034 -0.00016027  0.00526194  0.00801962
  0.00016758  0.00226211  0.00276773  0.00408198  0.00303223  0.00291933
  0.01101091  0.00683288  0.00145871  0.00326988  0.00572827  0.01019943
  0.00074329  0.00784767  0.00173803 -0.00219286  0.00601804  0.00606472
  0.00447388  0.00103391  0.00932358  0.00230171  0.003892    0.00151177
  0.00341637  0.00821943  0.00668607  0.00630774  0.00331502  0.00775074
  0.0044381   0.01030211  0.00924495  0.00645958  0.00777672  0.00231205
  0.00457842  0.00390424  0.00947046  0.00410091  0.0022092   0.00292498
  0.00638005  0.00796804  0.00140869  0.00887531  0.00496863  0.01049942
  0.00908096  0.00332738  0.00799218  0.00228496  0.004639    0.00213413
  0.00729368  0.01049243  0.00790528  0.01269368 -0.00425872  0.00256319
  0.00859569  0.00472848  0.0007721   0.00191874  0.01546813  0.00144742
  0.00888212  0.00648021  0.00115819  0.00351191  0.00580168  0.00614044
  0.00632418  0.0040833   0.00346038 -0.00034315  0.00599405  0.00302578
  0.0065765   0.01086897  0.00625799  0.00096572  0.00061766  0.00038494
  0.00523901  0.00633054  0.00379964  0.00302567 -0.00123339  0.00153471
  0.00725584  0.00836433  0.01295913  0.00737863]

@hcho3 μ‚΄νŽ΄

μž κΉλ§Œμš”, 제 μž¬ν˜„μ— λ¬΄μž‘μœ„ μ‹œλ“œλ₯Ό μ„€μ •ν•˜λŠ” 것을 μžŠμ—ˆμŠ΅λ‹ˆλ‹€. 바보 λ‚˜.

κ³ μ • 랜덀 μ‹œλ“œλ‘œ μž¬ν˜„μ„ μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. 버그가 μ—¬μ „νžˆ μ§€μ†λ©λ‹ˆλ‹€. μ—…λ°μ΄νŠΈλœ μž¬ν˜„μ„ XGBoost 1.0.0 및 1.1.0으둜 μ‹€ν–‰ν•΄ λ³΄μ•˜λŠ”λ° 예츑이 XGBoost 1.2.0의 예츑과 μΌμΉ˜ν•©λ‹ˆλ‹€.

κ°„λ‹¨νžˆ λ§ν•΄μ„œ:

Prediction from 1.0.0
==  Prediction from 1.1.0
==  Prediction from 1.2.0
!=  Prediction from latest master

@trivialfis 예, 도움을 μ£Όμ‹œλ©΄ κ°μ‚¬ν•˜κ² μŠ΅λ‹ˆλ‹€.

μ°¨λ‹¨μœΌλ‘œ ν‘œμ‹œν•©λ‹ˆλ‹€.

μ•Œμ•˜μ–΄μš”.

좔적 a4ce0eae43f7e0e2f91566ef2360830b86b9fdcf . @ShvetsKS ν•œλ²ˆ λ³΄μ‹€λž˜μš” ?

a4ce0ea 둜 μΆ”μ λ©λ‹ˆλ‹€. @ShvetsKS ν•œλ²ˆ λ³΄μ‹€λž˜μš” ?

ν™•μ‹ ν•˜λŠ”. 파이썬 μž¬μƒμ‚°κΈ°μ—μ„œ λͺ¨λΈμ„ ν›ˆλ ¨ν•˜λŠ” 데 도움을 쀄 수 μžˆμŠ΅λ‹ˆκΉŒ?
m2.load_model('xgb.model.bin') # load data
ν›ˆλ ¨μ— μ‚¬μš©λ˜λŠ” XGBoost 버전은 무엇이며 μ •ν™•νžˆ μ–΄λ–€ λ§€κ°œλ³€μˆ˜λ₯Ό μ œκ³΅ν•΄μ•Ό ν•©λ‹ˆκΉŒ?

@ShvetsKS https://github.com/7starsea/xgboost-testing μ—μ„œ λͺ¨λΈ 파일 xgb.model.bin 을 얻을 수 μžˆμŠ΅λ‹ˆλ‹€ . λͺ¨λΈμ€ 1.0.0으둜 ν›ˆλ ¨λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

@ShvetsKS https://github.com/7starsea/xgboost-testing μ—μ„œ λͺ¨λΈ 파일 xgb.model.bin 을 얻을 수 μžˆμŠ΅λ‹ˆλ‹€ . λͺ¨λΈμ€ 1.0.0으둜 ν›ˆλ ¨λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λͺ¨λΈμ€ μ‹€μ œλ‘œ 1.2.1 및 λ§€κ°œλ³€μˆ˜λ‘œ ν›ˆλ ¨λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

 param = {'max_depth': 8, 'eta': 0.1, 'min_child_weight': 2, 'gamma': 1e-8, 'subsample': 0.6, 'nthread': 4}

감사 ν•΄μš”.

μž‘μ€ μ°¨μ΄λŠ” 뢀동 μ†Œμˆ˜μ  μ—°μ‚°μ˜ μˆœμ„œκ°€ λ³€κ²½λ˜μ—ˆκΈ° λ•Œλ¬ΈμΈ 것 κ°™μŠ΅λ‹ˆλ‹€.
_μ •ν™•ν•œ 이유:_
a4ce0ea 전에 μš°λ¦¬λŠ” λͺ¨λ“  λ‚˜λ¬΄ 응닡을 지역 λ³€μˆ˜ psum (초기 0κ³Ό 동일)둜 μ¦κ°€μ‹œν‚€κ³  out_preds μ—μ„œ μ μ ˆν•œ 값을 μ¦κ°€μ‹œν‚΅λ‹ˆλ‹€.
a4ce0eaμ—μ„œ μš°λ¦¬λŠ” 각 트리 응닡에 μ˜ν•΄ 직접 out_preds 값을 μ¦κ°€μ‹œν‚΅λ‹ˆλ‹€.

μˆ˜μ •μ΄ μ€€λΉ„λ˜μ—ˆμŠ΅λ‹ˆλ‹€: https://github.com/dmlc/xgboost/pull/6384

@7starsea 차이점을 μ°Ύμ•„μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. μœ„μ˜ μˆ˜μ • 사항을 확인할 수 μžˆμŠ΅λ‹ˆκΉŒ?

@hcho3 , @trivialfis 그런 차이가 λ―Έλž˜μ— μ€‘μš”ν•˜λ‹€κ³  μƒκ°ν•˜λ‚˜μš”? 좔둠을 μœ„ν•΄ 뢀동 μ†Œμˆ˜μ  μ—°μ‚°μ˜ μˆœμ„œλ₯Ό λ³€κ²½ν•  수 μ—†λ‹€λŠ” 것이 μ€‘μš”ν•œ μ œν•œμΈ 것 κ°™μŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ ν›ˆλ ¨ λ‹¨κ³„μ—λŠ” λ‚΄κ°€ κΈ°μ–΅ν•˜λŠ” 것과 같은 μš”κ΅¬ 사항이 μ—†μŠ΅λ‹ˆλ‹€.

μš°λ¦¬λŠ” κ·ΈλŸ¬ν•œ 차이λ₯Ό λ―Έλž˜μ— μ€‘μš”ν•˜λ‹€κ³  μƒκ°ν•©λ‹ˆκΉŒ?

일반적으둜 μ—†μŠ΅λ‹ˆλ‹€. λ³€κ²½ 사항을 μ‚΄νŽ΄λ³΄κ² μŠ΅λ‹ˆλ‹€. ;-)

@ShvetsKS 방금 ν™•μΈν•œ κ²°κ³Ό μ°¨μ΄λŠ” 이제 μ •ν™•νžˆ 0μž…λ‹ˆλ‹€. 예츑 차이λ₯Ό μˆ˜μ •ν•΄ μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€.

@ShvetsKS

μš°λ¦¬λŠ” κ·ΈλŸ¬ν•œ 차이λ₯Ό λ―Έλž˜μ— μ€‘μš”ν•˜λ‹€κ³  μƒκ°ν•©λ‹ˆκΉŒ? 좔둠을 μœ„ν•΄ 뢀동 μ†Œμˆ˜μ  μ—°μ‚°μ˜ μˆœμ„œλ₯Ό λ³€κ²½ν•  수 없도둝 ν•˜λŠ” μ€‘μš”ν•œ μ œν•œ 사항인 것 κ°™μŠ΅λ‹ˆλ‹€.

μ‹€μ œλ‘œ, 우리( @RAMitchell , @trivialfis 및 I)λŠ” 여기에 λ™μ˜ν•©λ‹ˆλ‹€. 예츑의 μ •ν™•ν•œ μž¬ν˜„μ„±μ„ μ˜λ¬΄ν™”ν•˜λŠ” 것은 변경을 μˆ˜ν–‰ν•˜λŠ” λŠ₯λ ₯을 μ‹¬κ°ν•˜κ²Œ λ°©ν•΄ν•  κ²ƒμž…λ‹ˆλ‹€. 뢀동 μ†Œμˆ˜μ  μ‚°μˆ μ€ λΉ„μ—°κ΄€μœΌλ‘œ 유λͺ…ν•˜λ―€λ‘œ 숫자 λͺ©λ‘μ˜ 합은 λ§μ…ˆ μˆœμ„œμ— 따라 μ•½κ°„μ”© λ‹€λ¦…λ‹ˆλ‹€.

XGBoost 1.2.0κ³Ό μ΅œμ‹  master λΆ„κΈ° 간에 예츑이 μ–Όλ§ˆλ‚˜ λ³€κ²½λ˜λŠ”μ§€ μ •λŸ‰ν™”ν•˜λŠ” μ‹€ν—˜μ„ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.
Distribution of change in prediction

1000개의 μ„œλ‘œ λ‹€λ₯Έ μž„μ˜ μ‹œλ“œλ‘œ 데이터λ₯Ό μƒμ„±ν•œ λ‹€μŒ 버전 1.2.0κ³Ό λ§ˆμŠ€ν„°λ₯Ό λͺ¨λ‘ μ‚¬μš©ν•˜μ—¬ 1000개의 ν–‰λ ¬λ‘œ μ˜ˆμΈ‘μ„ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€. 예츑의 λ³€ν™”λŠ” μ‹œλ“œ μ‚¬μ΄μ—μ„œ μ•½κ°„ λ°”λ€Œμ§€λ§Œ κ·Έ μ°¨μ΄λŠ” κ²°μ½” 9.2e-7보닀 크지 μ•ŠμœΌλ―€λ‘œ 예츑 λ³€ν™”λŠ” 논리 였λ₯˜κ°€ μ•„λ‹Œ 뢀동 μ†Œμˆ˜μ  μ‚°μˆ λ‘œ 인해 λ°œμƒν–ˆμ„ κ°€λŠ₯성이 ν½λ‹ˆλ‹€ .

μ‹€ν—˜μš© 슀크립트

**test.py**: λ‹€λ₯Έ μž„μ˜μ˜ μ‹œλ“œλ‘œ 1000개의 행렬을 μƒμ„±ν•˜κ³  이에 λŒ€ν•œ μ˜ˆμΈ‘μ„ μ‹€ν–‰ν•©λ‹ˆλ‹€.

import numpy as np
import xgboost as xgb
import argparse

def main(args):
    m2 = xgb.Booster({'nthread': '4'})  # init model
    m2.load_model('xgb.model.bin')  # load data
    out = {}
    for seed in range(1000):
        rng = np.random.default_rng(seed=seed)
        rx = rng.standard_normal(size=(100, 127 + 7 + 1))
        rx = rx.astype(np.float32, order='C')
        dtest = xgb.DMatrix(rx, missing=0.0)
        out[str(seed)] = m2.predict(dtest)
    np.savez(args.out_pred, **out)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--out-pred', type=str, required=True)
    args = parser.parse_args()
    main(args)
λͺ…λ Ή: `python test.py --out-pred [out.npz]`. Python ν™˜κ²½μ— μ˜¬λ°”λ₯Έ λ²„μ „μ˜ XGBoostκ°€ μžˆλŠ”μ§€ ν™•μΈν•˜μ‹­μ‹œμ˜€. `xgb120.npz`κ°€ XGBoost 1.2.0에 λŒ€ν•œ κ²°κ³Όλ₯Ό μ €μž₯ν•˜κ³  `xgblatest.npz`κ°€ μ΅œμ‹  λ§ˆμŠ€ν„°μ— λŒ€ν•œ κ²°κ³Όλ₯Ό μ €μž₯ν•œλ‹€κ³  κ°€μ •ν•©μ‹œλ‹€. **compare.py**: 예츑 차이에 λŒ€ν•œ νžˆμŠ€ν† κ·Έλž¨ ν”Œλ‘― λ§Œλ“€κΈ°
import numpy as np
import matplotlib.pyplot as plt

xgb120 = np.load('xgb120.npz')
xgblatest = np.load('xgblatest.npz')

percentile_pts = [50, 90, 99]

colors = ['tab:cyan', 'tab:olive', 'tab:green', 'tab:pink']

percentile = {}
for x in percentile_pts:
    percentile[x] = []
percentile['max'] = []

for seed in range(1000):
    diff = np.abs(xgb120[str(seed)] - xgblatest[str(seed)])
    t = np.percentile(diff, percentile_pts)
    for x, y in zip(percentile_pts, t):
        percentile[x].append(y)
    percentile['max'].append(np.max(diff))

bins = np.linspace(0, np.max(percentile['max']), 100)
idx = 0
for x in percentile_pts:
    plt.hist(percentile[x], label=f'Percentile {x}%', bins=bins, alpha=0.8, color=colors[idx])
    idx += 1
plt.hist(percentile['max'], label='Max', bins=bins, alpha=0.8, color=colors[idx])
plt.legend(loc='best')
plt.title('Distribution in prediction difference between XGBoost 1.2.0\nand master branch, tried over seed=[0..1000]')
plt.xlabel('Absolute difference')
plt.ylabel('Frequency')
plt.savefig('foobar.png', dpi=100)

μ—¬κΈ°μ„œ λ¬Έμ œλŠ” floatκ°€ μžˆλŠ” + κ°€ 그룹을 ν˜•μ„±ν•˜μ§€ μ•ŠλŠ”λ‹€λŠ” κ²ƒμ΄λ―€λ‘œ 합계λ₯Ό μ œκ±°ν•˜μ—¬ ν…ŒμŠ€νŠΈν•  수 μžˆμŠ΅λ‹ˆλ‹€. 단일 νŠΈλ¦¬μ—μ„œ μ˜ˆμΈ‘ν•©λ‹ˆλ‹€. κ²°κ³ΌλŠ” μ •ν™•νžˆ 동일해야 ν•©λ‹ˆλ‹€.

@trivialfis μ‹€μ œλ‘œ ntree_limit=1 인수λ₯Ό m2.predict() 에 μΆ”κ°€ν•˜λ©΄ 차이가 0으둜 μ‚¬λΌμ§‘λ‹ˆλ‹€.

μ—„μ²­λ‚œ! κ·Έλž˜μ„œ λ‹€μŒμ€ 그것을 λ¬Έμ„œν™”ν•˜λŠ” 방법 λ˜λŠ” λ¬Έμ„œν™”ν•΄μ•Ό ν•˜λŠ”μ§€ μ—¬λΆ€μž…λ‹ˆλ‹€.

λ‚΄κ°€ 자게 ν•΄μ€˜. ν˜„μž¬λ‘œμ„œλŠ” 이 λ¬Έμ œκ°€ μ‹€μ œλ‘œ 버그가 μ•„λ‹ˆλΌκ³  λ§ν•˜λŠ” κ²ƒμœΌλ‘œ μΆ©λΆ„ν•©λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰