Mismatch in number of quantiles created for a feature
- Dominant language
- C++
- Stars
- 28.8k
- Forks
- 8.9k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 54
Description
https://github.com/dmlc/xgboost/pull/1959/commits : This commit has changed the initialization of n from 'maxsize - 1' to 'maxsize - 2'. I understand that this change has been done to incorporate corner cases for quantile building. But this change has caused lesser number of quantiles being built for a particular feature (explained in example below)
Input to SetPrune function:
**src** =>
DATA:
value:0.01 rmin:0 rmax:1 WMIN: 1
value:0.03 rmin:2 rmax:3 WMIN: 1
value:0.05 rmin:4 rmax:5 WMIN: 1
value:0.08 rmin:7 rmax:8 WMIN: 1
value:0.1 rmin:9 rmax:10 WMIN: 1
value:0.13 rmin:12 rmax:13 WMIN: 1
value:0.15 rmin:14 rmax:15 WMIN: 1
value:0.18 rmin:17 rmax:18 WMIN: 1
value:0.2 rmin:19 rmax:20 WMIN: 1
**maxsize** => 8
- When n was initialized to be = 'maxsize - 1':
Printing which values are added to the output summary (print statements added in query part of SetPrune function):
dx2:7.14286 k:1 mrange:18 n:7 begin:1
dx2:7.14286 i:1 src.data[i].rmin_next():3 src.data[i + 1].rmax_prev():4
added src.data[i+1] to data at1:0.05
dx2:12.2857 k:2 mrange:18 n:7 begin:1
dx2:12.2857 i:2 src.data[i].rmin_next():5 src.data[i + 1].rmax_prev():7
added src.data[i+1] to data at2:0.08
dx2:17.4286 k:3 mrange:18 n:7 begin:1
dx2:17.4286 i:3 src.data[i].rmin_next():8 src.data[i + 1].rmax_prev():9
added src.data[i+1] to data at3:0.1
dx2:22.5714 k:4 mrange:18 n:7 begin:1
dx2:22.5714 i:4 src.data[i].rmin_next():10 src.data[i + 1].rmax_prev():12
added src.data[i+1] to data at4:0.13
dx2:27.7143 k:5 mrange:18 n:7 begin:1
dx2:27.7143 i:5 src.data[i].rmin_next():13 src.data[i + 1].rmax_prev():14
**added src.data[i+1] to data at5:0.15**
dx2:32.8571 k:6 mrange:18 n:7 begin:1
dx2:32.8571 i:6 src.data[i].rmin_next():15 src.data[i + 1].rmax_prev():17
added src.data[i+1] to data at6:0.18
added to data at end 7:0.2
Number of elements in output summary = 8
- When n was initialized to be = 'maxsize - 2':
dx2:8 k:1 mrange:18 n:6 begin:1
dx2:8 i:1 src.data[i].rmin_next():3 src.data[i + 1].rmax_prev():4
added src.data[i+1] to data at 1:0.05
dx2:14 k:2 mrange:18 n:6 begin:1
dx2:14 i:2 src.data[i].rmin_next():5 src.data[i + 1].rmax_prev():7
added src.data[i+1] to data at 2:0.08
dx2:20 k:3 mrange:18 n:6 begin:1
dx2:20 i:4 src.data[i].rmin_next():10 src.data[i + 1].rmax_prev():12
added src.data[i] to data at3:0.1
dx2:26 k:4 mrange:18 n:6 begin:1
dx2:26 i:5 src.data[i].rmin_next():13 src.data[i + 1].rmax_prev():14
added src.data[i] to data at4:0.13
dx2:32 k:5 mrange:18 n:6 begin:1
dx2:32 i:6 src.data[i].rmin_next():15 src.data[i + 1].rmax_prev():17
added src.data[i+1] to data at 5:0.18
added to data at end 6:0.2
As you can see the number number of elements in output summary = 7. (the value 0.15 not in summary). This is because the value of n is different so the computation 2d = 2*(k*mrange/n + begin) produces a different result in both the cases. This causes the query algorithm to work differently (where it adds data[i+1] instead of data[i] or vice versa).
This is causing a difference in the number of quantiles being created (lesser number of quantiles are created).
https://github.com/dmlc/xgboost/blob/830e73901da74c599f35efc0457ae77f14d4ebf5/src/common/quantile.h#L363
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.