Upload edit\Qwen3-TTS-test\.venv\Lib\site-packages\sklearn\ensemble\_hist_gradient_boosting\common.pyx with huggingface_hub
Browse files
edit//Qwen3-TTS-test//.venv//Lib//site-packages//sklearn//ensemble//_hist_gradient_boosting//common.pyx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
# Y_DYTPE is the dtype to which the targets y are converted to. This is also
|
| 4 |
+
# dtype for leaf values, gains, and sums of gradients / hessians. The gradients
|
| 5 |
+
# and hessians arrays are stored as floats to avoid using too much memory.
|
| 6 |
+
Y_DTYPE = np.float64
|
| 7 |
+
X_DTYPE = np.float64
|
| 8 |
+
X_BINNED_DTYPE = np.uint8 # hence max_bins == 256
|
| 9 |
+
# dtype for gradients and hessians arrays
|
| 10 |
+
G_H_DTYPE = np.float32
|
| 11 |
+
X_BITSET_INNER_DTYPE = np.uint32
|
| 12 |
+
|
| 13 |
+
# Note that we use Y_DTYPE=float64 to avoid issues with floating point precision when
|
| 14 |
+
# summing gradients and hessians (both float32). Those are difficult to protect via
|
| 15 |
+
# tools like (Kahan-) Neumaier summation as in CPython, see
|
| 16 |
+
# https://github.com/python/cpython/issues/100425, or pairwise summation as numpy, see
|
| 17 |
+
# https://github.com/numpy/numpy/pull/3685, due to the way histograms are summed
|
| 18 |
+
# (number of additions per bin is not known in advance). See also comment in
|
| 19 |
+
# _subtract_histograms.
|
| 20 |
+
HISTOGRAM_DTYPE = np.dtype([
|
| 21 |
+
('sum_gradients', Y_DTYPE), # sum of sample gradients in bin
|
| 22 |
+
('sum_hessians', Y_DTYPE), # sum of sample hessians in bin
|
| 23 |
+
('count', np.uint32), # number of samples in bin
|
| 24 |
+
])
|
| 25 |
+
|
| 26 |
+
PREDICTOR_RECORD_DTYPE = np.dtype([
|
| 27 |
+
('value', Y_DTYPE),
|
| 28 |
+
('count', np.uint32),
|
| 29 |
+
('feature_idx', np.intp),
|
| 30 |
+
('num_threshold', X_DTYPE),
|
| 31 |
+
('missing_go_to_left', np.uint8),
|
| 32 |
+
('left', np.uint32),
|
| 33 |
+
('right', np.uint32),
|
| 34 |
+
('gain', Y_DTYPE),
|
| 35 |
+
('depth', np.uint32),
|
| 36 |
+
('is_leaf', np.uint8),
|
| 37 |
+
('bin_threshold', X_BINNED_DTYPE),
|
| 38 |
+
('is_categorical', np.uint8),
|
| 39 |
+
# The index of the corresponding bitsets in the Predictor's bitset arrays.
|
| 40 |
+
# Only used if is_categorical is True
|
| 41 |
+
('bitset_idx', np.uint32)
|
| 42 |
+
])
|
| 43 |
+
|
| 44 |
+
ALMOST_INF = 1e300 # see LightGBM AvoidInf()
|