针对pulse-transit的工具

This commit is contained in:
2025-02-22 16:12:02 +08:00
commit 6bc25b4e3a
7719 changed files with 1530886 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
from .common cimport X_BINNED_DTYPE_C
from .common cimport BITSET_DTYPE_C
from .common cimport BITSET_INNER_DTYPE_C
from .common cimport X_DTYPE_C
cdef void init_bitset(BITSET_DTYPE_C bitset) nogil
cdef void set_bitset(BITSET_DTYPE_C bitset, X_BINNED_DTYPE_C val) nogil
cdef unsigned char in_bitset(BITSET_DTYPE_C bitset, X_BINNED_DTYPE_C val) nogil
cpdef unsigned char in_bitset_memoryview(const BITSET_INNER_DTYPE_C[:] bitset,
X_BINNED_DTYPE_C val) nogil
cdef unsigned char in_bitset_2d_memoryview(
const BITSET_INNER_DTYPE_C [:, :] bitset,
X_BINNED_DTYPE_C val,
unsigned int row) nogil

View File

@@ -0,0 +1,44 @@
import numpy as np
cimport numpy as np
np.import_array()
ctypedef np.npy_float64 X_DTYPE_C
ctypedef np.npy_uint8 X_BINNED_DTYPE_C
ctypedef np.npy_float64 Y_DTYPE_C
ctypedef np.npy_float32 G_H_DTYPE_C
ctypedef np.npy_uint32 BITSET_INNER_DTYPE_C
ctypedef BITSET_INNER_DTYPE_C[8] BITSET_DTYPE_C
cdef packed struct hist_struct:
# Same as histogram dtype but we need a struct to declare views. It needs
# to be packed since by default numpy dtypes aren't aligned
Y_DTYPE_C sum_gradients
Y_DTYPE_C sum_hessians
unsigned int count
cdef packed struct node_struct:
# Equivalent struct to PREDICTOR_RECORD_DTYPE to use in memory views. It
# needs to be packed since by default numpy dtypes aren't aligned
Y_DTYPE_C value
unsigned int count
unsigned int feature_idx
X_DTYPE_C num_threshold
unsigned char missing_go_to_left
unsigned int left
unsigned int right
Y_DTYPE_C gain
unsigned int depth
unsigned char is_leaf
X_BINNED_DTYPE_C bin_threshold
unsigned char is_categorical
# The index of the corresponding bitsets in the Predictor's bitset arrays.
# Only used if is_categorical is True
unsigned int bitset_idx
cpdef enum MonotonicConstraint:
NO_CST = 0
POS = 1
NEG = -1