WIP: enforce contiguous arrays to optimize construction
This commit is contained in:
parent
cc3f2cf124
commit
bbdccca354
|
|
@ -253,8 +253,10 @@ class BaseForest(six.with_metaclass(ABCMeta, BaseEnsemble,
|
|||
|
||||
# Precompute some data
|
||||
X, y = check_arrays(X, y, sparse_format="dense")
|
||||
if (getattr(X, "dtype", None) != DTYPE or X.ndim != 2):
|
||||
X = array2d(X, dtype=DTYPE)
|
||||
if ((getattr(X, "dtype", None) != DTYPE) or
|
||||
(X.ndim != 2) or
|
||||
(not X.flags.contiguous)):
|
||||
X = array2d(X, dtype=DTYPE, order="C")
|
||||
|
||||
n_samples, self.n_features_ = X.shape
|
||||
|
||||
|
|
|
|||
|
|
@ -496,8 +496,7 @@ class BaseGradientBoosting(six.with_metaclass(ABCMeta, BaseEnsemble)):
|
|||
----------
|
||||
X : array-like, shape = [n_samples, n_features]
|
||||
Training vectors, where n_samples is the number of samples
|
||||
and n_features is the number of features. Use fortran-style
|
||||
to avoid memory copies.
|
||||
and n_features is the number of features.
|
||||
|
||||
y : array-like, shape = [n_samples]
|
||||
Target values (integers in classification, real numbers in
|
||||
|
|
@ -511,9 +510,14 @@ class BaseGradientBoosting(six.with_metaclass(ABCMeta, BaseEnsemble)):
|
|||
Returns self.
|
||||
"""
|
||||
# Check input
|
||||
X, y = check_arrays(X, y, sparse_format='dense')
|
||||
X = np.asfortranarray(X, dtype=DTYPE)
|
||||
y = np.ravel(y, order='C')
|
||||
X, y = check_arrays(X, y, sparse_format="dense")
|
||||
|
||||
if ((getattr(X, "dtype", None) != DTYPE) or
|
||||
(X.ndim != 2) or
|
||||
(not X.flags.contiguous)):
|
||||
X = array2d(X, dtype=DTYPE, order="C")
|
||||
|
||||
y = np.ravel(y, order="C")
|
||||
|
||||
# Check parameters
|
||||
n_samples, n_features = X.shape
|
||||
|
|
@ -816,8 +820,7 @@ class GradientBoostingClassifier(BaseGradientBoosting, ClassifierMixin):
|
|||
----------
|
||||
X : array-like, shape = [n_samples, n_features]
|
||||
Training vectors, where n_samples is the number of samples
|
||||
and n_features is the number of features. Use fortran-style
|
||||
to avoid memory copies.
|
||||
and n_features is the number of features.
|
||||
|
||||
y : array-like, shape = [n_samples]
|
||||
Target values (integers in classification, real numbers in
|
||||
|
|
@ -1048,8 +1051,7 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin):
|
|||
----------
|
||||
X : array-like, shape = [n_samples, n_features]
|
||||
Training vectors, where n_samples is the number of samples
|
||||
and n_features is the number of features. Use fortran-style
|
||||
to avoid memory copies.
|
||||
and n_features is the number of features.
|
||||
|
||||
y : array-like, shape = [n_samples]
|
||||
Target values (integers in classification, real numbers in
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Generated by Cython 0.20dev on Thu Jul 18 08:49:01 2013 */
|
||||
/* Generated by Cython 0.20dev on Thu Jul 18 10:24:33 2013 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#ifndef CYTHON_USE_PYLONG_INTERNALS
|
||||
|
|
@ -1320,11 +1320,12 @@ static void __Pyx_WriteUnraisable(const char *name, int clineno,
|
|||
|
||||
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
|
||||
|
||||
#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1)
|
||||
#define __Pyx_BufPtrCContig2d(type, buf, i0, s0, i1, s1) ((type)((char*)buf + i0 * s0) + i1)
|
||||
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
|
||||
|
||||
static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
|
||||
|
||||
#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1)
|
||||
#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2)
|
||||
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
|
||||
|
||||
|
|
@ -6985,7 +6986,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8Splitter_6__setstate__(CYTHON_U
|
|||
/* "sklearn/tree/_tree.pyx":818
|
||||
* pass
|
||||
*
|
||||
* cdef void init(self, np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<<
|
||||
* cdef void init(self, np.ndarray[DTYPE_t, ndim=2, mode="c"] X, # <<<<<<<<<<<<<<
|
||||
* np.ndarray[DOUBLE_t, ndim=2, mode="c"] y,
|
||||
* DOUBLE_t* sample_weight):
|
||||
*/
|
||||
|
|
@ -7024,7 +7025,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_8Splitter_init(struct __pyx_obj_7sklea
|
|||
__pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y;
|
||||
{
|
||||
__Pyx_BufFmt_StackElem __pyx_stack[1];
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1];
|
||||
{
|
||||
|
|
@ -7922,7 +7923,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
* cdef SIZE_t* features = self.features
|
||||
* cdef SIZE_t n_features = self.n_features # <<<<<<<<<<<<<<
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
*/
|
||||
__pyx_t_3 = __pyx_v_self->__pyx_base.n_features;
|
||||
__pyx_v_n_features = __pyx_t_3;
|
||||
|
|
@ -7930,7 +7931,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
/* "sklearn/tree/_tree.pyx":907
|
||||
* cdef SIZE_t n_features = self.n_features
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X # <<<<<<<<<<<<<<
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X # <<<<<<<<<<<<<<
|
||||
* cdef SIZE_t max_features = self.max_features
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
*/
|
||||
|
|
@ -7938,7 +7939,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
__Pyx_INCREF(__pyx_t_1);
|
||||
{
|
||||
__Pyx_BufFmt_StackElem __pyx_stack[1];
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {
|
||||
__pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL;
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
} else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1];
|
||||
|
|
@ -7949,7 +7950,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
|
||||
/* "sklearn/tree/_tree.pyx":908
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
* cdef SIZE_t max_features = self.max_features # <<<<<<<<<<<<<<
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
* cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -7958,7 +7959,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
__pyx_v_max_features = __pyx_t_3;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":909
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
* cdef SIZE_t max_features = self.max_features
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf # <<<<<<<<<<<<<<
|
||||
* cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -8127,7 +8128,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
__pyx_t_6 = __pyx_v_current_feature;
|
||||
__pyx_t_7 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_8 = __pyx_v_current_feature;
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_X.diminfo[1].strides)) <= ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_X.diminfo[1].strides)) + 1.e-7)) != 0);
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_X.diminfo[1].strides)) <= ((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_X.diminfo[1].strides)) + 1.e-7)) != 0);
|
||||
__pyx_t_10 = __pyx_t_9;
|
||||
} else {
|
||||
__pyx_t_10 = __pyx_t_4;
|
||||
|
|
@ -8274,7 +8275,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
__pyx_t_12 = __pyx_v_current_feature;
|
||||
__pyx_t_13 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_14 = __pyx_v_current_feature;
|
||||
__pyx_v_current_threshold = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_X.diminfo[1].strides)) + (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_X.diminfo[1].strides))) / 2.0);
|
||||
__pyx_v_current_threshold = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_12, __pyx_pybuffernd_X.diminfo[1].strides)) + (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_X.diminfo[1].strides))) / 2.0);
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":972
|
||||
*
|
||||
|
|
@ -8285,7 +8286,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
*/
|
||||
__pyx_t_15 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_16 = __pyx_v_current_feature;
|
||||
__pyx_t_9 = ((__pyx_v_current_threshold == (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_X.diminfo[1].strides))) != 0);
|
||||
__pyx_t_9 = ((__pyx_v_current_threshold == (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_X.diminfo[1].strides))) != 0);
|
||||
if (__pyx_t_9) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":973
|
||||
|
|
@ -8297,7 +8298,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
*/
|
||||
__pyx_t_17 = (__pyx_v_samples[(__pyx_v_p - 1)]);
|
||||
__pyx_t_18 = __pyx_v_current_feature;
|
||||
__pyx_v_current_threshold = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
__pyx_v_current_threshold = (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
goto __pyx_L12;
|
||||
}
|
||||
__pyx_L12:;
|
||||
|
|
@ -8432,7 +8433,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
*/
|
||||
__pyx_t_3 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_19 = __pyx_v_best_feature;
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_best_threshold) != 0);
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_best_threshold) != 0);
|
||||
if (__pyx_t_9) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":994
|
||||
|
|
@ -8512,7 +8513,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
* feature[0] = best_feature
|
||||
* threshold[0] = best_threshold # <<<<<<<<<<<<<<
|
||||
*
|
||||
* cdef void sort(np.ndarray[DTYPE_t, ndim=2] X, SIZE_t current_feature,
|
||||
* cdef void sort(np.ndarray[DTYPE_t, ndim=2, mode="c"] X, SIZE_t current_feature,
|
||||
*/
|
||||
(__pyx_v_threshold[0]) = __pyx_v_best_threshold;
|
||||
|
||||
|
|
@ -8536,7 +8537,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_12BestSplitter_node_split(struct __pyx
|
|||
/* "sklearn/tree/_tree.pyx":1008
|
||||
* threshold[0] = best_threshold
|
||||
*
|
||||
* cdef void sort(np.ndarray[DTYPE_t, ndim=2] X, SIZE_t current_feature, # <<<<<<<<<<<<<<
|
||||
* cdef void sort(np.ndarray[DTYPE_t, ndim=2, mode="c"] X, SIZE_t current_feature, # <<<<<<<<<<<<<<
|
||||
* SIZE_t* samples, SIZE_t length):
|
||||
* """In-place sorting of samples[start:end] using
|
||||
*/
|
||||
|
|
@ -8572,7 +8573,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_sort(PyArrayObject *__pyx_v_X, __pyx_t
|
|||
__pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X;
|
||||
{
|
||||
__Pyx_BufFmt_StackElem __pyx_stack[1];
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1];
|
||||
|
||||
|
|
@ -8695,7 +8696,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_sort(PyArrayObject *__pyx_v_X, __pyx_t
|
|||
*/
|
||||
__pyx_t_2 = __pyx_v_tmp;
|
||||
__pyx_t_3 = __pyx_v_current_feature;
|
||||
__pyx_v_tmp_value = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
__pyx_v_tmp_value = (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1031
|
||||
*
|
||||
|
|
@ -8747,7 +8748,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_sort(PyArrayObject *__pyx_v_X, __pyx_t
|
|||
__pyx_t_5 = __pyx_v_current_feature;
|
||||
__pyx_t_6 = (__pyx_v_samples[__pyx_v_child]);
|
||||
__pyx_t_7 = __pyx_v_current_feature;
|
||||
__pyx_t_8 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_X.diminfo[1].strides)) > (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_X.diminfo[1].strides))) != 0);
|
||||
__pyx_t_8 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_X.diminfo[1].strides)) > (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_X.diminfo[1].strides))) != 0);
|
||||
__pyx_t_9 = __pyx_t_8;
|
||||
} else {
|
||||
__pyx_t_9 = __pyx_t_1;
|
||||
|
|
@ -8775,7 +8776,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_sort(PyArrayObject *__pyx_v_X, __pyx_t
|
|||
*/
|
||||
__pyx_t_10 = (__pyx_v_samples[__pyx_v_child]);
|
||||
__pyx_t_11 = __pyx_v_current_feature;
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_X.diminfo[1].strides)) > __pyx_v_tmp_value) != 0);
|
||||
__pyx_t_9 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_X.diminfo[1].strides)) > __pyx_v_tmp_value) != 0);
|
||||
if (__pyx_t_9) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1040
|
||||
|
|
@ -9080,7 +9081,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
* cdef SIZE_t* features = self.features
|
||||
* cdef SIZE_t n_features = self.n_features # <<<<<<<<<<<<<<
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
*/
|
||||
__pyx_t_3 = __pyx_v_self->__pyx_base.n_features;
|
||||
__pyx_v_n_features = __pyx_t_3;
|
||||
|
|
@ -9088,7 +9089,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
/* "sklearn/tree/_tree.pyx":1069
|
||||
* cdef SIZE_t n_features = self.n_features
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X # <<<<<<<<<<<<<<
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X # <<<<<<<<<<<<<<
|
||||
* cdef SIZE_t max_features = self.max_features
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
*/
|
||||
|
|
@ -9096,7 +9097,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
__Pyx_INCREF(__pyx_t_1);
|
||||
{
|
||||
__Pyx_BufFmt_StackElem __pyx_stack[1];
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
|
||||
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {
|
||||
__pyx_v_X = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_X.rcbuffer->pybuffer.buf = NULL;
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
} else {__pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X.diminfo[1].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X.diminfo[1].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[1];
|
||||
|
|
@ -9107,7 +9108,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
|
||||
/* "sklearn/tree/_tree.pyx":1070
|
||||
*
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
* cdef SIZE_t max_features = self.max_features # <<<<<<<<<<<<<<
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
* cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -9116,7 +9117,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
__pyx_v_max_features = __pyx_t_3;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1071
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
* cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
* cdef SIZE_t max_features = self.max_features
|
||||
* cdef SIZE_t min_samples_leaf = self.min_samples_leaf # <<<<<<<<<<<<<<
|
||||
* cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -9234,7 +9235,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
*/
|
||||
__pyx_t_4 = (__pyx_v_samples[__pyx_v_start]);
|
||||
__pyx_t_5 = __pyx_v_current_feature;
|
||||
__pyx_t_6 = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
__pyx_t_6 = (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
__pyx_v_min_feature_value = __pyx_t_6;
|
||||
__pyx_v_max_feature_value = __pyx_t_6;
|
||||
|
||||
|
|
@ -9257,7 +9258,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
*/
|
||||
__pyx_t_8 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_9 = __pyx_v_current_feature;
|
||||
__pyx_v_current_feature_value = (*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
__pyx_v_current_feature_value = (*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_X.diminfo[1].strides));
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1110
|
||||
* current_feature_value = X[samples[p], current_feature]
|
||||
|
|
@ -9403,7 +9404,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
*/
|
||||
__pyx_t_7 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_11 = __pyx_v_current_feature;
|
||||
__pyx_t_10 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_current_threshold) != 0);
|
||||
__pyx_t_10 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_current_threshold) != 0);
|
||||
if (__pyx_t_10) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1132
|
||||
|
|
@ -9675,7 +9676,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_14RandomSplitter_node_split(struct __p
|
|||
*/
|
||||
__pyx_t_3 = (__pyx_v_samples[__pyx_v_p]);
|
||||
__pyx_t_14 = __pyx_v_best_feature;
|
||||
__pyx_t_12 = (((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_best_threshold) != 0);
|
||||
__pyx_t_12 = (((*__Pyx_BufPtrCContig2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_X.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_X.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_X.diminfo[1].strides)) <= __pyx_v_best_threshold) != 0);
|
||||
if (__pyx_t_12) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1173
|
||||
|
|
@ -12032,9 +12033,9 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
PyObject *__pyx_t_2 = NULL;
|
||||
PyObject *__pyx_t_3 = NULL;
|
||||
int __pyx_t_4;
|
||||
PyObject *__pyx_t_5 = NULL;
|
||||
int __pyx_t_5;
|
||||
int __pyx_t_6;
|
||||
int __pyx_t_7;
|
||||
PyObject *__pyx_t_7 = NULL;
|
||||
struct __pyx_opt_args_7sklearn_4tree_5_tree_4Tree__resize __pyx_t_8;
|
||||
__pyx_t_7sklearn_4tree_5_tree_SIZE_t __pyx_t_9;
|
||||
int __pyx_t_10;
|
||||
|
|
@ -12091,8 +12092,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
/* "sklearn/tree/_tree.pyx":1430
|
||||
* """Build a decision tree from the training set (X, y)."""
|
||||
* # Prepare data before recursive partitioning
|
||||
* if X.dtype != DTYPE: # <<<<<<<<<<<<<<
|
||||
* X = np.asarray(X, dtype=DTYPE)
|
||||
* if X.dtype != DTYPE or not X.flags.contiguous: # <<<<<<<<<<<<<<
|
||||
* X = np.asarray(X, dtype=DTYPE, order="C")
|
||||
*
|
||||
*/
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_X), __pyx_n_s__dtype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
|
|
@ -12104,73 +12105,87 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (__pyx_t_4) {
|
||||
if (!__pyx_t_4) {
|
||||
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_X), __pyx_n_s__flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__contiguous); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__pyx_t_6 = (!__pyx_t_5);
|
||||
__pyx_t_5 = __pyx_t_6;
|
||||
} else {
|
||||
__pyx_t_5 = __pyx_t_4;
|
||||
}
|
||||
if (__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1431
|
||||
* # Prepare data before recursive partitioning
|
||||
* if X.dtype != DTYPE:
|
||||
* X = np.asarray(X, dtype=DTYPE) # <<<<<<<<<<<<<<
|
||||
* if X.dtype != DTYPE or not X.flags.contiguous:
|
||||
* X = np.asarray(X, dtype=DTYPE, order="C") # <<<<<<<<<<<<<<
|
||||
*
|
||||
* if y.dtype != DOUBLE or not y.flags.contiguous:
|
||||
*/
|
||||
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__asarray); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_X));
|
||||
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_X));
|
||||
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_X));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_X));
|
||||
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
|
||||
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
|
||||
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
||||
if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
|
||||
if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_X, ((PyArrayObject *)__pyx_t_5));
|
||||
__pyx_t_5 = 0;
|
||||
if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_X, ((PyArrayObject *)__pyx_t_7));
|
||||
__pyx_t_7 = 0;
|
||||
goto __pyx_L3;
|
||||
}
|
||||
__pyx_L3:;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1433
|
||||
* X = np.asarray(X, dtype=DTYPE)
|
||||
* X = np.asarray(X, dtype=DTYPE, order="C")
|
||||
*
|
||||
* if y.dtype != DOUBLE or not y.flags.contiguous: # <<<<<<<<<<<<<<
|
||||
* y = np.asarray(y, dtype=DOUBLE, order="C")
|
||||
*
|
||||
*/
|
||||
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__dtype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__dtype); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_3 = PyObject_RichCompare(__pyx_t_7, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (!__pyx_t_4) {
|
||||
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__contiguous); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
if (!__pyx_t_5) {
|
||||
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s__flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__contiguous); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_7 = (!__pyx_t_6);
|
||||
__pyx_t_6 = __pyx_t_7;
|
||||
__pyx_t_6 = (!__pyx_t_4);
|
||||
__pyx_t_4 = __pyx_t_6;
|
||||
} else {
|
||||
__pyx_t_6 = __pyx_t_4;
|
||||
__pyx_t_4 = __pyx_t_5;
|
||||
}
|
||||
if (__pyx_t_6) {
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1434
|
||||
*
|
||||
|
|
@ -12181,29 +12196,29 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
*/
|
||||
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__asarray); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_y));
|
||||
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_y));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_y));
|
||||
__pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
|
||||
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_7));
|
||||
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_y, ((PyArrayObject *)__pyx_t_3));
|
||||
__pyx_t_3 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
|
||||
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_y, ((PyArrayObject *)__pyx_t_2));
|
||||
__pyx_t_2 = 0;
|
||||
goto __pyx_L4;
|
||||
}
|
||||
__pyx_L4:;
|
||||
|
|
@ -12224,9 +12239,9 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* if ((sample_weight.dtype != DOUBLE) or
|
||||
* (not sample_weight.flags.contiguous)):
|
||||
*/
|
||||
__pyx_t_6 = (((PyObject *)__pyx_v_sample_weight) != Py_None);
|
||||
__pyx_t_4 = (__pyx_t_6 != 0);
|
||||
if (__pyx_t_4) {
|
||||
__pyx_t_4 = (((PyObject *)__pyx_v_sample_weight) != Py_None);
|
||||
__pyx_t_5 = (__pyx_t_4 != 0);
|
||||
if (__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1438
|
||||
* cdef DOUBLE_t* sample_weight_ptr = NULL
|
||||
|
|
@ -12235,16 +12250,16 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* (not sample_weight.flags.contiguous)):
|
||||
* sample_weight = np.asarray(sample_weight,
|
||||
*/
|
||||
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_sample_weight), __pyx_n_s__dtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_sample_weight), __pyx_n_s__dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
||||
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
if (!__pyx_t_4) {
|
||||
if (!__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1439
|
||||
* if sample_weight is not None:
|
||||
|
|
@ -12255,17 +12270,17 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
*/
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_sample_weight), __pyx_n_s__flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__contiguous); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__contiguous); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_7 = (!__pyx_t_6);
|
||||
__pyx_t_6 = __pyx_t_7;
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
||||
__pyx_t_6 = (!__pyx_t_4);
|
||||
__pyx_t_4 = __pyx_t_6;
|
||||
} else {
|
||||
__pyx_t_6 = __pyx_t_4;
|
||||
__pyx_t_4 = __pyx_t_5;
|
||||
}
|
||||
if (__pyx_t_6) {
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1440
|
||||
* if ((sample_weight.dtype != DOUBLE) or
|
||||
|
|
@ -12274,18 +12289,18 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* dtype=DOUBLE, order="C")
|
||||
* sample_weight_ptr = <DOUBLE_t*> sample_weight.data
|
||||
*/
|
||||
__pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__asarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
||||
__pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_7);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_sample_weight));
|
||||
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_sample_weight));
|
||||
PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_sample_weight));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_sample_weight));
|
||||
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
|
||||
__pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1441
|
||||
* (not sample_weight.flags.contiguous)):
|
||||
|
|
@ -12294,19 +12309,19 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* sample_weight_ptr = <DOUBLE_t*> sample_weight.data
|
||||
*
|
||||
*/
|
||||
__pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_3);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
|
||||
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_sample_weight, ((PyArrayObject *)__pyx_t_2));
|
||||
__pyx_t_2 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
|
||||
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF_SET(__pyx_v_sample_weight, ((PyArrayObject *)__pyx_t_3));
|
||||
__pyx_t_3 = 0;
|
||||
goto __pyx_L6;
|
||||
}
|
||||
__pyx_L6:;
|
||||
|
|
@ -12330,8 +12345,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* init_capacity = (2 ** (self.max_depth + 1)) - 1
|
||||
* else:
|
||||
*/
|
||||
__pyx_t_6 = ((__pyx_v_self->max_depth <= 10) != 0);
|
||||
if (__pyx_t_6) {
|
||||
__pyx_t_4 = ((__pyx_v_self->max_depth <= 10) != 0);
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1448
|
||||
*
|
||||
|
|
@ -12374,10 +12389,10 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* splitter.init(X, y, sample_weight_ptr)
|
||||
*
|
||||
*/
|
||||
__pyx_t_2 = ((PyObject *)__pyx_v_self->splitter);
|
||||
__Pyx_INCREF(__pyx_t_2);
|
||||
__pyx_v_splitter = ((struct __pyx_obj_7sklearn_4tree_5_tree_Splitter *)__pyx_t_2);
|
||||
__pyx_t_2 = 0;
|
||||
__pyx_t_3 = ((PyObject *)__pyx_v_self->splitter);
|
||||
__Pyx_INCREF(__pyx_t_3);
|
||||
__pyx_v_splitter = ((struct __pyx_obj_7sklearn_4tree_5_tree_Splitter *)__pyx_t_3);
|
||||
__pyx_t_3 = 0;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1456
|
||||
* # Recursive partition (without actual recursion)
|
||||
|
|
@ -12469,8 +12484,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
*
|
||||
*/
|
||||
while (1) {
|
||||
__pyx_t_6 = ((__pyx_v_stack_n_values > 0) != 0);
|
||||
if (!__pyx_t_6) break;
|
||||
__pyx_t_4 = ((__pyx_v_stack_n_values > 0) != 0);
|
||||
if (!__pyx_t_4) break;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1484
|
||||
*
|
||||
|
|
@ -12542,8 +12557,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* (n_node_samples < self.min_samples_split) or
|
||||
* (n_node_samples < 2 * self.min_samples_leaf))
|
||||
*/
|
||||
__pyx_t_6 = (__pyx_v_depth >= __pyx_v_self->max_depth);
|
||||
if (!__pyx_t_6) {
|
||||
__pyx_t_4 = (__pyx_v_depth >= __pyx_v_self->max_depth);
|
||||
if (!__pyx_t_4) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1494
|
||||
* n_node_samples = end - start
|
||||
|
|
@ -12552,8 +12567,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* (n_node_samples < 2 * self.min_samples_leaf))
|
||||
*
|
||||
*/
|
||||
__pyx_t_4 = (__pyx_v_n_node_samples < __pyx_v_self->min_samples_split);
|
||||
if (!__pyx_t_4) {
|
||||
__pyx_t_5 = (__pyx_v_n_node_samples < __pyx_v_self->min_samples_split);
|
||||
if (!__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1495
|
||||
* is_leaf = ((depth >= self.max_depth) or
|
||||
|
|
@ -12562,16 +12577,16 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
*
|
||||
* splitter.node_reset(start, end, &impurity)
|
||||
*/
|
||||
__pyx_t_7 = (__pyx_v_n_node_samples < (2 * __pyx_v_self->min_samples_leaf));
|
||||
__pyx_t_10 = __pyx_t_7;
|
||||
__pyx_t_6 = (__pyx_v_n_node_samples < (2 * __pyx_v_self->min_samples_leaf));
|
||||
__pyx_t_10 = __pyx_t_6;
|
||||
} else {
|
||||
__pyx_t_10 = __pyx_t_4;
|
||||
__pyx_t_10 = __pyx_t_5;
|
||||
}
|
||||
__pyx_t_4 = __pyx_t_10;
|
||||
__pyx_t_5 = __pyx_t_10;
|
||||
} else {
|
||||
__pyx_t_4 = __pyx_t_6;
|
||||
__pyx_t_5 = __pyx_t_4;
|
||||
}
|
||||
__pyx_v_is_leaf = __pyx_t_4;
|
||||
__pyx_v_is_leaf = __pyx_t_5;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1497
|
||||
* (n_node_samples < 2 * self.min_samples_leaf))
|
||||
|
|
@ -12590,12 +12605,12 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* if not is_leaf:
|
||||
*/
|
||||
if (!__pyx_v_is_leaf) {
|
||||
__pyx_t_4 = (__pyx_v_impurity == 0.0);
|
||||
__pyx_t_6 = __pyx_t_4;
|
||||
__pyx_t_5 = (__pyx_v_impurity == 0.0);
|
||||
__pyx_t_4 = __pyx_t_5;
|
||||
} else {
|
||||
__pyx_t_6 = __pyx_v_is_leaf;
|
||||
__pyx_t_4 = __pyx_v_is_leaf;
|
||||
}
|
||||
__pyx_v_is_leaf = __pyx_t_6;
|
||||
__pyx_v_is_leaf = __pyx_t_4;
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1500
|
||||
* is_leaf = is_leaf or (impurity == 0.0)
|
||||
|
|
@ -12604,8 +12619,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* splitter.node_split(&pos, &feature, &threshold)
|
||||
* is_leaf = is_leaf or (pos >= end)
|
||||
*/
|
||||
__pyx_t_6 = ((!(__pyx_v_is_leaf != 0)) != 0);
|
||||
if (__pyx_t_6) {
|
||||
__pyx_t_4 = ((!(__pyx_v_is_leaf != 0)) != 0);
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1501
|
||||
*
|
||||
|
|
@ -12624,12 +12639,12 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* node_id = self._add_node(parent, is_left, is_leaf, feature,
|
||||
*/
|
||||
if (!__pyx_v_is_leaf) {
|
||||
__pyx_t_6 = (__pyx_v_pos >= __pyx_v_end);
|
||||
__pyx_t_4 = __pyx_t_6;
|
||||
__pyx_t_4 = (__pyx_v_pos >= __pyx_v_end);
|
||||
__pyx_t_5 = __pyx_t_4;
|
||||
} else {
|
||||
__pyx_t_4 = __pyx_v_is_leaf;
|
||||
__pyx_t_5 = __pyx_v_is_leaf;
|
||||
}
|
||||
__pyx_v_is_leaf = __pyx_t_4;
|
||||
__pyx_v_is_leaf = __pyx_t_5;
|
||||
goto __pyx_L10;
|
||||
}
|
||||
__pyx_L10:;
|
||||
|
|
@ -12650,8 +12665,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* # Don't store value for internal nodes
|
||||
* splitter.node_value(self.value + node_id * self.value_stride)
|
||||
*/
|
||||
__pyx_t_4 = (__pyx_v_is_leaf != 0);
|
||||
if (__pyx_t_4) {
|
||||
__pyx_t_5 = (__pyx_v_is_leaf != 0);
|
||||
if (__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1509
|
||||
* if is_leaf:
|
||||
|
|
@ -12672,8 +12687,8 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
* stack_capacity *= 2
|
||||
* stack = <SIZE_t*> realloc(stack, stack_capacity * sizeof(SIZE_t))
|
||||
*/
|
||||
__pyx_t_4 = (((__pyx_v_stack_n_values + 10) > __pyx_v_stack_capacity) != 0);
|
||||
if (__pyx_t_4) {
|
||||
__pyx_t_5 = (((__pyx_v_stack_n_values + 10) > __pyx_v_stack_capacity) != 0);
|
||||
if (__pyx_t_5) {
|
||||
|
||||
/* "sklearn/tree/_tree.pyx":1513
|
||||
* else:
|
||||
|
|
@ -12833,7 +12848,7 @@ static PyObject *__pyx_f_7sklearn_4tree_5_tree_4Tree_build(struct __pyx_obj_7skl
|
|||
__Pyx_XDECREF(__pyx_t_1);
|
||||
__Pyx_XDECREF(__pyx_t_2);
|
||||
__Pyx_XDECREF(__pyx_t_3);
|
||||
__Pyx_XDECREF(__pyx_t_5);
|
||||
__Pyx_XDECREF(__pyx_t_7);
|
||||
__Pyx_AddTraceback("sklearn.tree._tree.Tree.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
|
||||
__pyx_r = 0;
|
||||
__pyx_L0:;
|
||||
|
|
|
|||
|
|
@ -815,7 +815,7 @@ cdef class Splitter:
|
|||
def __setstate__(self, d):
|
||||
pass
|
||||
|
||||
cdef void init(self, np.ndarray[DTYPE_t, ndim=2] X,
|
||||
cdef void init(self, np.ndarray[DTYPE_t, ndim=2, mode="c"] X,
|
||||
np.ndarray[DOUBLE_t, ndim=2, mode="c"] y,
|
||||
DOUBLE_t* sample_weight):
|
||||
"""Initialize the splitter."""
|
||||
|
|
@ -904,7 +904,7 @@ cdef class BestSplitter(Splitter):
|
|||
cdef SIZE_t* features = self.features
|
||||
cdef SIZE_t n_features = self.n_features
|
||||
|
||||
cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
cdef SIZE_t max_features = self.max_features
|
||||
cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -1005,7 +1005,7 @@ cdef class BestSplitter(Splitter):
|
|||
feature[0] = best_feature
|
||||
threshold[0] = best_threshold
|
||||
|
||||
cdef void sort(np.ndarray[DTYPE_t, ndim=2] X, SIZE_t current_feature,
|
||||
cdef void sort(np.ndarray[DTYPE_t, ndim=2, mode="c"] X, SIZE_t current_feature,
|
||||
SIZE_t* samples, SIZE_t length):
|
||||
"""In-place sorting of samples[start:end] using
|
||||
X[sample[i], current_feature] as key."""
|
||||
|
|
@ -1066,7 +1066,7 @@ cdef class RandomSplitter(Splitter):
|
|||
cdef SIZE_t* features = self.features
|
||||
cdef SIZE_t n_features = self.n_features
|
||||
|
||||
cdef np.ndarray[DTYPE_t, ndim=2] X = self.X
|
||||
cdef np.ndarray[DTYPE_t, ndim=2, mode="c"] X = self.X
|
||||
cdef SIZE_t max_features = self.max_features
|
||||
cdef SIZE_t min_samples_leaf = self.min_samples_leaf
|
||||
cdef unsigned int* random_state = &self.rand_r_state
|
||||
|
|
@ -1427,8 +1427,8 @@ cdef class Tree:
|
|||
np.ndarray sample_weight=None):
|
||||
"""Build a decision tree from the training set (X, y)."""
|
||||
# Prepare data before recursive partitioning
|
||||
if X.dtype != DTYPE:
|
||||
X = np.asarray(X, dtype=DTYPE)
|
||||
if X.dtype != DTYPE or not X.flags.contiguous:
|
||||
X = np.asarray(X, dtype=DTYPE, order="C")
|
||||
|
||||
if y.dtype != DOUBLE or not y.flags.contiguous:
|
||||
y = np.asarray(y, dtype=DOUBLE, order="C")
|
||||
|
|
|
|||
|
|
@ -129,8 +129,10 @@ class BaseDecisionTree(six.with_metaclass(ABCMeta, BaseEstimator,
|
|||
X, y = check_arrays(X, y)
|
||||
random_state = check_random_state(self.random_state)
|
||||
|
||||
if (getattr(X, "dtype", None) != DTYPE or X.ndim != 2):
|
||||
X = array2d(X, dtype=DTYPE)
|
||||
if ((getattr(X, "dtype", None) != DTYPE) or
|
||||
(X.ndim != 2) or
|
||||
(not X.flags.contiguous)):
|
||||
X = array2d(X, dtype=DTYPE, order="C")
|
||||
|
||||
n_samples, self.n_features_ = X.shape
|
||||
is_classification = isinstance(self, ClassifierMixin)
|
||||
|
|
|
|||
Loading…
Reference in New Issue