/
githubmirror
/
scikit-learn
Обзор
Документация
Войти
/
githubmirror
/
scikit-learn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
sklearn/utils/_bitset.pyx
29 строк
1 KB
Itamar Turner-Trauring
ENH Speed up histogram gradient categorical data prediction (and perhaps other code) by ensuring C/Cython inlining actually happens (#34486)
20 июл 2026, 20:04
Не верифицирован
20 июл 2026, 20:04
2668f2d
Код
Авторство
О чём код?
""" A bitset is a data structure used to represent sets of integers in [0, n]. For decision trees, we use them to represent sets of features indices (e.g. features that go to the left child, or features that are categorical). For familiarity with bitsets and bitwise operations see: https://en.wikipedia.org/wiki/Bit_array https://en.wikipedia.org/wiki/Bitwise_operation """ # Authors: The scikit-learn developers # SPDX-License-Identifier: BSD-3-Clause def set_raw_bitset_from_binned_bitset( BITSET_INNER_DTYPE_C[:] raw_bitset, BITSET_INNER_DTYPE_C[:] binned_bitset, float64_t[:] categories, ): """Set the raw_bitset from the values of the binned bitset categories is a mapping from binned category value to raw category value. """ cdef: int binned_cat_value float64_t raw_cat_value for binned_cat_value, raw_cat_value in enumerate(categories): if in_bitset_memoryview(binned_bitset, binned_cat_value): set_bitset_memoryview(raw_bitset, <uint8_t>raw_cat_value)