common.pxd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cimport numpy as cnp
  2. from sklearn.utils._typedefs cimport intp_t
  3. cnp.import_array()
  4. ctypedef cnp.npy_float64 X_DTYPE_C
  5. ctypedef cnp.npy_uint8 X_BINNED_DTYPE_C
  6. ctypedef cnp.npy_float64 Y_DTYPE_C
  7. ctypedef cnp.npy_float32 G_H_DTYPE_C
  8. ctypedef cnp.npy_uint32 BITSET_INNER_DTYPE_C
  9. ctypedef BITSET_INNER_DTYPE_C[8] BITSET_DTYPE_C
  10. cdef packed struct hist_struct:
  11. # Same as histogram dtype but we need a struct to declare views. It needs
  12. # to be packed since by default numpy dtypes aren't aligned
  13. Y_DTYPE_C sum_gradients
  14. Y_DTYPE_C sum_hessians
  15. unsigned int count
  16. cdef packed struct node_struct:
  17. # Equivalent struct to PREDICTOR_RECORD_DTYPE to use in memory views. It
  18. # needs to be packed since by default numpy dtypes aren't aligned
  19. Y_DTYPE_C value
  20. unsigned int count
  21. intp_t feature_idx
  22. X_DTYPE_C num_threshold
  23. unsigned char missing_go_to_left
  24. unsigned int left
  25. unsigned int right
  26. Y_DTYPE_C gain
  27. unsigned int depth
  28. unsigned char is_leaf
  29. X_BINNED_DTYPE_C bin_threshold
  30. unsigned char is_categorical
  31. # The index of the corresponding bitsets in the Predictor's bitset arrays.
  32. # Only used if is_categorical is True
  33. unsigned int bitset_idx
  34. cpdef enum MonotonicConstraint:
  35. NO_CST = 0
  36. POS = 1
  37. NEG = -1