From a25522e8838868cdba04eff33e508cf0bb1d38b5 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 25 Jun 2012 16:37:37 +0200 Subject: [PATCH 01/33] ENH: MultiOutputTree (wip) --- sklearn/tree/_tree.c | 5449 ++++++++++++++++++++-------------------- sklearn/tree/_tree.pyx | 54 + sklearn/tree/tree.py | 2 +- 3 files changed, 2759 insertions(+), 2746 deletions(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index bc272ce176bd5..e1b7873bb1828 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,12 +1,11 @@ -/* Generated by Cython 0.16 on Mon Jun 25 08:54:47 2012 */ +/* Generated by Cython 0.15.1 on Mon Jun 25 16:36:47 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02040000 - #error Cython requires Python 2.4+. #else + #include /* For offsetof */ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -35,22 +34,10 @@ #define PY_LONG_LONG LONG_LONG #endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif - -#ifdef PYPY_VERSION -#define CYTHON_COMPILING_IN_PYPY 1 -#define CYTHON_COMPILING_IN_CPYTHON 0 -#else -#define CYTHON_COMPILING_IN_PYPY 0 -#define CYTHON_COMPILING_IN_CPYTHON 1 -#endif - -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyCFunction_Call PyObject_Call -#else - #define __Pyx_PyCFunction_Call PyCFunction_Call +#if PY_VERSION_HEX < 0x02040000 + #define METH_COEXIST 0 + #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) + #define PyDict_Contains(d,o) PySequence_Contains(d,o) #endif #if PY_VERSION_HEX < 0x02050000 @@ -63,9 +50,6 @@ #define PyNumber_Index(o) PyNumber_Int(o) #define PyIndex_Check(o) PyNumber_Check(o) #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) - #define __PYX_BUILD_PY_SSIZE_T "i" -#else - #define __PYX_BUILD_PY_SSIZE_T "n" #endif #if PY_VERSION_HEX < 0x02060000 @@ -99,25 +83,13 @@ #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) - #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) - #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) - typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); - typedef void (*releasebufferproc)(PyObject *, Py_buffer *); #endif #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - -#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 - #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif #if PY_MAJOR_VERSION >= 3 @@ -129,17 +101,6 @@ #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif - -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) -#else - #define CYTHON_PEP393_ENABLED 0 - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) -#endif - #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject @@ -207,6 +168,15 @@ #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) @@ -248,14 +218,6 @@ #define __Pyx_DOCSTR(n) (n) #endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -306,7 +268,7 @@ # else # define CYTHON_UNUSED # endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# elif defined(__ICC) || defined(__INTEL_COMPILER) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED @@ -331,7 +293,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) + #ifdef __GNUC__ /* Test for GCC > 2.95 */ @@ -356,6 +318,7 @@ static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; + #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 @@ -365,6 +328,7 @@ static const char *__pyx_filename; #define CYTHON_CCOMPLEX 0 #endif #endif + #if CYTHON_CCOMPLEX #ifdef __cplusplus #include @@ -372,53 +336,18 @@ static const char *__pyx_filename; #include #endif #endif + #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif - static const char *__pyx_f[] = { "_tree.pyx", "numpy.pxd", }; -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; /* for error messages only */ - struct __Pyx_StructField_* fields; - size_t size; /* sizeof(type) */ - size_t arraysize[8]; /* length of array in each dimension */ - int ndim; - char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */ - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - -/* "numpy.pxd":722 +/* "numpy.pxd":719 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -427,7 +356,7 @@ typedef struct { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "numpy.pxd":723 +/* "numpy.pxd":720 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -436,7 +365,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "numpy.pxd":724 +/* "numpy.pxd":721 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -445,7 +374,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "numpy.pxd":725 +/* "numpy.pxd":722 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -454,7 +383,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "numpy.pxd":729 +/* "numpy.pxd":726 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -463,7 +392,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "numpy.pxd":730 +/* "numpy.pxd":727 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -472,7 +401,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "numpy.pxd":731 +/* "numpy.pxd":728 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -481,7 +410,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "numpy.pxd":732 +/* "numpy.pxd":729 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -490,7 +419,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "numpy.pxd":736 +/* "numpy.pxd":733 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -499,7 +428,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "numpy.pxd":737 +/* "numpy.pxd":734 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -508,7 +437,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "numpy.pxd":746 +/* "numpy.pxd":743 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -517,7 +446,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "numpy.pxd":747 +/* "numpy.pxd":744 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -526,7 +455,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "numpy.pxd":748 +/* "numpy.pxd":745 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -535,7 +464,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "numpy.pxd":750 +/* "numpy.pxd":747 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -544,7 +473,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "numpy.pxd":751 +/* "numpy.pxd":748 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -553,7 +482,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "numpy.pxd":752 +/* "numpy.pxd":749 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -562,7 +491,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "numpy.pxd":754 +/* "numpy.pxd":751 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -571,7 +500,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "numpy.pxd":755 +/* "numpy.pxd":752 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -580,7 +509,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "numpy.pxd":757 +/* "numpy.pxd":754 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -589,7 +518,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "numpy.pxd":758 +/* "numpy.pxd":755 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -598,7 +527,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "numpy.pxd":759 +/* "numpy.pxd":756 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -624,6 +553,7 @@ typedef __pyx_t_5numpy_float32_t __pyx_t_7sklearn_4tree_5_tree_DTYPE_t; * cdef extern from "math.h": */ typedef __pyx_t_5numpy_int8_t __pyx_t_7sklearn_4tree_5_tree_BOOL_t; + #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; @@ -644,16 +574,16 @@ typedef __pyx_t_5numpy_int8_t __pyx_t_7sklearn_4tree_5_tree_BOOL_t; typedef struct { double real, imag; } __pyx_t_double_complex; #endif - /*--- Type declarations ---*/ struct __pyx_obj_7sklearn_4tree_5_tree_Criterion; +struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion; struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion; struct __pyx_obj_7sklearn_4tree_5_tree_Gini; struct __pyx_obj_7sklearn_4tree_5_tree_Entropy; struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion; struct __pyx_obj_7sklearn_4tree_5_tree_MSE; -/* "numpy.pxd":761 +/* "numpy.pxd":758 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -662,7 +592,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_MSE; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "numpy.pxd":762 +/* "numpy.pxd":759 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -671,7 +601,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "numpy.pxd":763 +/* "numpy.pxd":760 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -680,7 +610,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "numpy.pxd":765 +/* "numpy.pxd":762 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -702,6 +632,20 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Criterion { }; +/* "sklearn/tree/_tree.pyx":404 + * + * + * cdef class MultiOuputCriterion(Criterion): # <<<<<<<<<<<<<< + * cdef int n_outputs + * cdef int y_stride + */ +struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion __pyx_base; + int n_outputs; + int y_stride; +}; + + /* "sklearn/tree/_tree.pyx":67 * * @@ -802,6 +746,20 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; +/* "sklearn/tree/_tree.pyx":404 + * + * + * cdef class MultiOuputCriterion(Criterion): # <<<<<<<<<<<<<< + * cdef int n_outputs + * cdef int y_stride + */ + +struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MultiOuputCriterion { + struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion __pyx_base; +}; +static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_MultiOuputCriterion; + + /* "sklearn/tree/_tree.pyx":245 * * @@ -816,6 +774,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; + /* "sklearn/tree/_tree.pyx":394 * * @@ -870,9 +829,11 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy { struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion __pyx_base; }; static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy *__pyx_vtabptr_7sklearn_4tree_5_tree_Entropy; + #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif + #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); @@ -885,21 +846,8 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy *__pyx_vtabptr_7skl static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ - if (acquire_gil) { \ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ - PyGILState_Release(__pyx_gilstate_save); \ - } else { \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext() \ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_RefNannySetupContext(name) __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) + #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) @@ -910,7 +858,7 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy *__pyx_vtabptr_7skl #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannySetupContext(name) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) @@ -921,37 +869,72 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy *__pyx_vtabptr_7skl #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif /* CYTHON_REFNANNY */ -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, PyObject* kw_name); /*proto*/ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ - const char* function_name); /*proto*/ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ -static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +/* Run-time type information about structs used with buffers */ +struct __Pyx_StructField_; + +typedef struct { + const char* name; /* for error messages only */ + struct __Pyx_StructField_* fields; + size_t size; /* sizeof(type) */ + char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */ +} __Pyx_TypeInfo; + +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; + +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; + + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, + const char* function_name, int kw_allowed); /*proto*/ +static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { + if (likely(PyList_CheckExact(L))) { + if (PyList_Append(L, x) < 0) return NULL; + Py_INCREF(Py_None); + return Py_None; /* this is just to have an accurate signature */ + } + else { + PyObject *r, *m; + m = __Pyx_GetAttrString(L, "append"); + if (!m) return NULL; + r = PyObject_CallFunctionObjArgs(m, x, NULL); + Py_DECREF(m); + return r; + } +} #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0) + static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); /*proto*/ - #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) + static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ @@ -963,30 +946,16 @@ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/ - -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - #if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); +static void __Pyx_ReleaseBuffer(Py_buffer *view); #else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release +#define __Pyx_GetBuffer PyObject_GetBuffer +#define __Pyx_ReleaseBuffer PyBuffer_Release #endif -static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; -static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; +Py_ssize_t __Pyx_zeros[] = {0, 0}; +Py_ssize_t __Pyx_minusones[] = {-1, -1}; static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ @@ -1002,6 +971,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif + #if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) @@ -1120,41 +1090,23 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + static int __Pyx_check_binary_version(void); static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) -#else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif -#endif - static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ -typedef struct { - int code_line; - PyCodeObject* code_object; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); /*proto*/ +static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, + int __pyx_lineno, const char *__pyx_filename); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ +/* Module declarations from 'cython.cython.view' */ /* Module declarations from 'cython' */ @@ -1176,7 +1128,14 @@ static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *, PyObject *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *); /*proto*/ /* Module declarations from 'sklearn.tree._tree' */ static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Criterion = 0; @@ -1185,12 +1144,13 @@ static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Gini = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Entropy = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_MSE = 0; +static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_MultiOuputCriterion = 0; static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t = { "BOOL_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_BOOL_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_7sklearn_4tree_5_tree_BOOL_t), 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t = { "int64_t", NULL, sizeof(__pyx_t_5numpy_int64_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int64_t), 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), 'I' }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), 'R' }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t = { "BOOL_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_BOOL_t), 'I' }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t), 'R' }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t = { "int64_t", NULL, sizeof(__pyx_t_5numpy_int64_t), 'I' }; #define __Pyx_MODULE_NAME "sklearn.tree._tree" int __pyx_module_is_main_sklearn__tree___tree = 0; @@ -1199,58 +1159,35 @@ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self); /* proto */ -static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_n_classes); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self); /* proto */ -static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n_total_samples, int __pyx_v_n_total_in_bag, PyObject *__pyx_v_random_state); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_out); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_pred); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_sample_mask, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, int __pyx_v_n_samples); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_X_argsorted, PyArrayObject *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_min_leaf, int __pyx_v_max_features, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, PyObject *__pyx_v_random_state); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_X_argsorted, PyArrayObject *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_min_leaf, int __pyx_v_max_features, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, PyObject *__pyx_v_random_state); /* proto */ -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static char __pyx_k_1[] = "ndarray is not C contiguous"; static char __pyx_k_3[] = "ndarray is not Fortran contiguous"; static char __pyx_k_5[] = "Non-native byte order not supported"; static char __pyx_k_7[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_8[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_11[] = "Format string allocated too short."; -static char __pyx_k_15[] = "/home/pprett/workspace/scikit-learn/sklearn/tree/_tree.pyx"; -static char __pyx_k_16[] = "sklearn.tree._tree"; -static char __pyx_k_23[] = "X_argsorted_elem_stride"; -static char __pyx_k_24[] = "X_argsorted_col_stride"; -static char __pyx_k_29[] = "_find_best_random_split"; +static char __pyx_k_13[] = "sklearn.tree._tree"; +static char __pyx_k_14[] = "_find_best_random_split"; static char __pyx_k__B[] = "B"; static char __pyx_k__C[] = "C"; static char __pyx_k__H[] = "H"; static char __pyx_k__I[] = "I"; -static char __pyx_k__K[] = "K"; static char __pyx_k__L[] = "L"; static char __pyx_k__O[] = "O"; static char __pyx_k__Q[] = "Q"; static char __pyx_k__X[] = "X"; -static char __pyx_k__a[] = "a"; static char __pyx_k__b[] = "b"; -static char __pyx_k__c[] = "c"; static char __pyx_k__d[] = "d"; static char __pyx_k__f[] = "f"; static char __pyx_k__g[] = "g"; static char __pyx_k__h[] = "h"; static char __pyx_k__i[] = "i"; -static char __pyx_k__k[] = "k"; static char __pyx_k__l[] = "l"; -static char __pyx_k__n[] = "n"; static char __pyx_k__q[] = "q"; -static char __pyx_k__t[] = "t"; static char __pyx_k__y[] = "y"; static char __pyx_k__Zd[] = "Zd"; static char __pyx_k__Zf[] = "Zf"; static char __pyx_k__Zg[] = "Zg"; static char __pyx_k__np[] = "np"; -static char __pyx_k__X_i[] = "X_i"; static char __pyx_k__inf[] = "inf"; static char __pyx_k__out[] = "out"; static char __pyx_k__bool[] = "bool"; @@ -1259,83 +1196,57 @@ static char __pyx_k__pred[] = "pred"; static char __pyx_k__rand[] = "rand"; static char __pyx_k__DTYPE[] = "DTYPE"; static char __pyx_k__dtype[] = "dtype"; -static char __pyx_k__error[] = "error"; static char __pyx_k__int32[] = "int32"; static char __pyx_k__numpy[] = "numpy"; static char __pyx_k__order[] = "order"; static char __pyx_k__range[] = "range"; -static char __pyx_k__y_ptr[] = "y_ptr"; static char __pyx_k__zeros[] = "zeros"; static char __pyx_k__arange[] = "arange"; static char __pyx_k__astype[] = "astype"; -static char __pyx_k__best_i[] = "best_i"; -static char __pyx_k__best_t[] = "best_t"; -static char __pyx_k__n_left[] = "n_left"; +static char __pyx_k__hstack[] = "hstack"; static char __pyx_k__values[] = "values"; static char __pyx_k__xrange[] = "xrange"; static char __pyx_k__asarray[] = "asarray"; static char __pyx_k__feature[] = "feature"; static char __pyx_k__float32[] = "float32"; -static char __pyx_k__node_id[] = "node_id"; -static char __pyx_k__X_stride[] = "X_stride"; static char __pyx_k____main__[] = "__main__"; static char __pyx_k____test__[] = "__test__"; static char __pyx_k__children[] = "children"; -static char __pyx_k__features[] = "features"; +static char __pyx_k__criteria[] = "criteria"; static char __pyx_k__min_leaf[] = "min_leaf"; -static char __pyx_k__n_bagged[] = "n_bagged"; static char __pyx_k__criterion[] = "criterion"; static char __pyx_k__n_classes[] = "n_classes"; static char __pyx_k__n_samples[] = "n_samples"; static char __pyx_k__threshold[] = "threshold"; static char __pyx_k__ValueError[] = "ValueError"; -static char __pyx_k__best_error[] = "best_error"; static char __pyx_k__init_value[] = "init_value"; -static char __pyx_k__n_features[] = "n_features"; static char __pyx_k__X_argsorted[] = "X_argsorted"; static char __pyx_k___apply_tree[] = "_apply_tree"; -static char __pyx_k__feature_idx[] = "feature_idx"; static char __pyx_k__permutation[] = "permutation"; static char __pyx_k__sample_mask[] = "sample_mask"; static char __pyx_k__RuntimeError[] = "RuntimeError"; -static char __pyx_k__X_col_stride[] = "X_col_stride"; static char __pyx_k__max_features[] = "max_features"; static char __pyx_k__random_state[] = "random_state"; -static char __pyx_k__X_argsorted_i[] = "X_argsorted_i"; -static char __pyx_k__X_elem_stride[] = "X_elem_stride"; static char __pyx_k___predict_tree[] = "_predict_tree"; -static char __pyx_k__initial_error[] = "initial_error"; static char __pyx_k___error_at_leaf[] = "_error_at_leaf"; static char __pyx_k__n_total_in_bag[] = "n_total_in_bag"; static char __pyx_k__n_total_samples[] = "n_total_samples"; -static char __pyx_k__sample_mask_ptr[] = "sample_mask_ptr"; static char __pyx_k___find_best_split[] = "_find_best_split"; -static char __pyx_k__X_argsorted_stride[] = "X_argsorted_stride"; static char __pyx_k___random_sample_mask[] = "_random_sample_mask"; static PyObject *__pyx_kp_u_1; static PyObject *__pyx_kp_u_11; -static PyObject *__pyx_kp_s_15; -static PyObject *__pyx_n_s_16; -static PyObject *__pyx_n_s_23; -static PyObject *__pyx_n_s_24; -static PyObject *__pyx_n_s_29; +static PyObject *__pyx_n_s_13; +static PyObject *__pyx_n_s_14; static PyObject *__pyx_kp_u_3; static PyObject *__pyx_kp_u_5; static PyObject *__pyx_kp_u_7; static PyObject *__pyx_kp_u_8; static PyObject *__pyx_n_s__C; static PyObject *__pyx_n_s__DTYPE; -static PyObject *__pyx_n_s__K; static PyObject *__pyx_n_s__RuntimeError; static PyObject *__pyx_n_s__ValueError; static PyObject *__pyx_n_s__X; static PyObject *__pyx_n_s__X_argsorted; -static PyObject *__pyx_n_s__X_argsorted_i; -static PyObject *__pyx_n_s__X_argsorted_stride; -static PyObject *__pyx_n_s__X_col_stride; -static PyObject *__pyx_n_s__X_elem_stride; -static PyObject *__pyx_n_s__X_i; -static PyObject *__pyx_n_s__X_stride; static PyObject *__pyx_n_s____main__; static PyObject *__pyx_n_s____test__; static PyObject *__pyx_n_s___apply_tree; @@ -1343,42 +1254,27 @@ static PyObject *__pyx_n_s___error_at_leaf; static PyObject *__pyx_n_s___find_best_split; static PyObject *__pyx_n_s___predict_tree; static PyObject *__pyx_n_s___random_sample_mask; -static PyObject *__pyx_n_s__a; static PyObject *__pyx_n_s__arange; static PyObject *__pyx_n_s__asarray; static PyObject *__pyx_n_s__astype; -static PyObject *__pyx_n_s__b; -static PyObject *__pyx_n_s__best_error; -static PyObject *__pyx_n_s__best_i; -static PyObject *__pyx_n_s__best_t; static PyObject *__pyx_n_s__bool; -static PyObject *__pyx_n_s__c; static PyObject *__pyx_n_s__children; +static PyObject *__pyx_n_s__criteria; static PyObject *__pyx_n_s__criterion; static PyObject *__pyx_n_s__dtype; -static PyObject *__pyx_n_s__error; static PyObject *__pyx_n_s__feature; -static PyObject *__pyx_n_s__feature_idx; -static PyObject *__pyx_n_s__features; static PyObject *__pyx_n_s__float32; -static PyObject *__pyx_n_s__i; +static PyObject *__pyx_n_s__hstack; static PyObject *__pyx_n_s__inf; static PyObject *__pyx_n_s__init_value; -static PyObject *__pyx_n_s__initial_error; static PyObject *__pyx_n_s__int32; static PyObject *__pyx_n_s__int8; -static PyObject *__pyx_n_s__k; static PyObject *__pyx_n_s__max_features; static PyObject *__pyx_n_s__min_leaf; -static PyObject *__pyx_n_s__n; -static PyObject *__pyx_n_s__n_bagged; static PyObject *__pyx_n_s__n_classes; -static PyObject *__pyx_n_s__n_features; -static PyObject *__pyx_n_s__n_left; static PyObject *__pyx_n_s__n_samples; static PyObject *__pyx_n_s__n_total_in_bag; static PyObject *__pyx_n_s__n_total_samples; -static PyObject *__pyx_n_s__node_id; static PyObject *__pyx_n_s__np; static PyObject *__pyx_n_s__numpy; static PyObject *__pyx_n_s__order; @@ -1389,13 +1285,10 @@ static PyObject *__pyx_n_s__rand; static PyObject *__pyx_n_s__random_state; static PyObject *__pyx_n_s__range; static PyObject *__pyx_n_s__sample_mask; -static PyObject *__pyx_n_s__sample_mask_ptr; -static PyObject *__pyx_n_s__t; static PyObject *__pyx_n_s__threshold; static PyObject *__pyx_n_s__values; static PyObject *__pyx_n_s__xrange; static PyObject *__pyx_n_s__y; -static PyObject *__pyx_n_s__y_ptr; static PyObject *__pyx_n_s__zeros; static PyObject *__pyx_int_15; static PyObject *__pyx_k_tuple_2; @@ -1404,18 +1297,6 @@ static PyObject *__pyx_k_tuple_6; static PyObject *__pyx_k_tuple_9; static PyObject *__pyx_k_tuple_10; static PyObject *__pyx_k_tuple_12; -static PyObject *__pyx_k_tuple_13; -static PyObject *__pyx_k_tuple_17; -static PyObject *__pyx_k_tuple_19; -static PyObject *__pyx_k_tuple_21; -static PyObject *__pyx_k_tuple_25; -static PyObject *__pyx_k_tuple_27; -static PyObject *__pyx_k_codeobj_14; -static PyObject *__pyx_k_codeobj_18; -static PyObject *__pyx_k_codeobj_20; -static PyObject *__pyx_k_codeobj_22; -static PyObject *__pyx_k_codeobj_26; -static PyObject *__pyx_k_codeobj_28; /* "sklearn/tree/_tree.pyx":43 * """Interface for splitting criteria (regression and classification)""" @@ -1425,9 +1306,9 @@ static PyObject *__pyx_k_codeobj_28; * """Initialise the criterion class for new split point.""" */ -static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, CYTHON_UNUSED int __pyx_v_n_samples, CYTHON_UNUSED int __pyx_v_n_total_samples) { +static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init", 0); + __Pyx_RefNannySetupContext("init"); __Pyx_RefNannyFinishContext(); } @@ -1440,9 +1321,9 @@ static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(CYTHON_UNUSED struct _ * pass */ -static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_reset(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self) { +static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_reset(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("reset", 0); + __Pyx_RefNannySetupContext("reset"); __Pyx_RefNannyFinishContext(); } @@ -1455,10 +1336,10 @@ static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_reset(CYTHON_UNUSED struct * """Update the criteria for each value in interval [a,b) (where a and b */ -static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED int __pyx_v_a, CYTHON_UNUSED int __pyx_v_b, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED int *__pyx_v_X_argsorted_i, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { +static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("update", 0); + __Pyx_RefNannySetupContext("update"); __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -1473,10 +1354,10 @@ static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct * pass */ -static double __pyx_f_7sklearn_4tree_5_tree_9Criterion_eval(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self) { +static double __pyx_f_7sklearn_4tree_5_tree_9Criterion_eval(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self) { double __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("eval", 0); + __Pyx_RefNannySetupContext("eval"); __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -1491,8 +1372,8 @@ static double __pyx_f_7sklearn_4tree_5_tree_9Criterion_eval(CYTHON_UNUSED struct * pass */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, int __pyx_skip_dispatch) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, int __pyx_skip_dispatch) { PyArrayObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -1500,14 +1381,14 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); @@ -1541,18 +1422,6 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_9Criterion_init_value[] = "Get the init value of the criterion - `init` must be called before."; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init_value (wrapper)", 0); - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - /* "sklearn/tree/_tree.pyx":62 * pass * @@ -1561,16 +1430,18 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject * pass */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_9Criterion_init_value[] = "Get the init value of the criterion - `init` must be called before."; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self->__pyx_vtab)->init_value(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self)->__pyx_vtab)->init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1588,33 +1459,62 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __p return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":107 + * cdef ndarray_label_count_init + * + * def __init__(self, int n_classes): # <<<<<<<<<<<<<< + * cdef np.ndarray[np.int32_t, ndim=1] ndarray_label_count_left \ + * = np.zeros((n_classes,), dtype=np.int32, order='C') + */ + +static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_n_classes; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_classes,0}; + PyArrayObject *__pyx_v_ndarray_label_count_left = 0; + PyArrayObject *__pyx_v_ndarray_label_count_right = 0; + PyArrayObject *__pyx_v_ndarray_label_count_init = 0; + Py_buffer __pyx_bstruct_ndarray_label_count_right; + Py_ssize_t __pyx_bstride_0_ndarray_label_count_right = 0; + Py_ssize_t __pyx_bshape_0_ndarray_label_count_right = 0; + Py_buffer __pyx_bstruct_ndarray_label_count_left; + Py_ssize_t __pyx_bstride_0_ndarray_label_count_left = 0; + Py_ssize_t __pyx_bshape_0_ndarray_label_count_left = 0; + Py_buffer __pyx_bstruct_ndarray_label_count_init; + Py_ssize_t __pyx_bstride_0_ndarray_label_count_init = 0; + Py_ssize_t __pyx_bshape_0_ndarray_label_count_init = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyArrayObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_classes,0}; + __Pyx_RefNannySetupContext("__init__"); { PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_classes); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -1631,55 +1531,9 @@ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(Py __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self), __pyx_v_n_classes); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":107 - * cdef ndarray_label_count_init - * - * def __init__(self, int n_classes): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.int32_t, ndim=1] ndarray_label_count_left \ - * = np.zeros((n_classes,), dtype=np.int32, order='C') - */ - -static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_n_classes) { - PyArrayObject *__pyx_v_ndarray_label_count_left = 0; - PyArrayObject *__pyx_v_ndarray_label_count_right = 0; - PyArrayObject *__pyx_v_ndarray_label_count_init = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_init; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_init; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_left; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_left; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_right; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_right; - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyArrayObject *__pyx_t_6 = NULL; - PyArrayObject *__pyx_t_7 = NULL; - PyArrayObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__init__", 0); - __pyx_pybuffer_ndarray_label_count_left.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_left.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_left.data = NULL; - __pyx_pybuffernd_ndarray_label_count_left.rcbuffer = &__pyx_pybuffer_ndarray_label_count_left; - __pyx_pybuffer_ndarray_label_count_right.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_right.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_right.data = NULL; - __pyx_pybuffernd_ndarray_label_count_right.rcbuffer = &__pyx_pybuffer_ndarray_label_count_right; - __pyx_pybuffer_ndarray_label_count_init.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_init.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_init.data = NULL; - __pyx_pybuffernd_ndarray_label_count_init.rcbuffer = &__pyx_pybuffer_ndarray_label_count_init; + __pyx_bstruct_ndarray_label_count_left.buf = NULL; + __pyx_bstruct_ndarray_label_count_right.buf = NULL; + __pyx_bstruct_ndarray_label_count_init.buf = NULL; /* "sklearn/tree/_tree.pyx":109 * def __init__(self, int n_classes): @@ -1696,12 +1550,12 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_1 = PyInt_FromLong(__pyx_v_n_classes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__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 = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -1715,7 +1569,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -1724,10 +1578,11 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.buf = NULL; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_ndarray_label_count_left, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_ndarray_label_count_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_ndarray_label_count_left.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_left.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_left.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.shape[0]; + } else {__pyx_bstride_0_ndarray_label_count_left = __pyx_bstruct_ndarray_label_count_left.strides[0]; + __pyx_bshape_0_ndarray_label_count_left = __pyx_bstruct_ndarray_label_count_left.shape[0]; } } __pyx_t_6 = 0; @@ -1749,12 +1604,12 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_5 = PyInt_FromLong(__pyx_v_n_classes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_GIVEREF(__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 = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -1768,7 +1623,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_3, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; @@ -1777,10 +1632,11 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_7 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.buf = NULL; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_ndarray_label_count_right, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_ndarray_label_count_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_ndarray_label_count_right.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_right.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_right.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.shape[0]; + } else {__pyx_bstride_0_ndarray_label_count_right = __pyx_bstruct_ndarray_label_count_right.strides[0]; + __pyx_bshape_0_ndarray_label_count_right = __pyx_bstruct_ndarray_label_count_right.shape[0]; } } __pyx_t_7 = 0; @@ -1802,12 +1658,12 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_4 = PyInt_FromLong(__pyx_v_n_classes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; @@ -1821,7 +1677,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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 = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -1830,10 +1686,11 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_8 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_init = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.buf = NULL; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_ndarray_label_count_init, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_ndarray_label_count_init = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_ndarray_label_count_init.buf = NULL; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_init.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_init.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.shape[0]; + } else {__pyx_bstride_0_ndarray_label_count_init = __pyx_bstruct_ndarray_label_count_init.strides[0]; + __pyx_bshape_0_ndarray_label_count_init = __pyx_bstruct_ndarray_label_count_init.shape[0]; } } __pyx_t_8 = 0; @@ -1847,7 +1704,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.n_samples = 0 * self.n_left = 0 */ - __pyx_v_self->n_classes = __pyx_v_n_classes; + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->n_classes = __pyx_v_n_classes; /* "sklearn/tree/_tree.pyx":116 * @@ -1856,7 +1713,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.n_left = 0 * self.n_right = 0 */ - __pyx_v_self->n_samples = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->n_samples = 0; /* "sklearn/tree/_tree.pyx":117 * self.n_classes = n_classes @@ -1865,7 +1722,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.n_right = 0 * self.label_count_left = ndarray_label_count_left.data */ - __pyx_v_self->n_left = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->n_left = 0; /* "sklearn/tree/_tree.pyx":118 * self.n_samples = 0 @@ -1874,7 +1731,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.label_count_left = ndarray_label_count_left.data * self.label_count_right = ndarray_label_count_right.data */ - __pyx_v_self->n_right = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->n_right = 0; /* "sklearn/tree/_tree.pyx":119 * self.n_left = 0 @@ -1883,7 +1740,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.label_count_right = ndarray_label_count_right.data * self.label_count_init = ndarray_label_count_init.data */ - __pyx_v_self->label_count_left = ((int *)__pyx_v_ndarray_label_count_left->data); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->label_count_left = ((int *)__pyx_v_ndarray_label_count_left->data); /* "sklearn/tree/_tree.pyx":120 * self.n_right = 0 @@ -1892,7 +1749,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.label_count_init = ndarray_label_count_init.data * self.ndarray_label_count_left = ndarray_label_count_left */ - __pyx_v_self->label_count_right = ((int *)__pyx_v_ndarray_label_count_right->data); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->label_count_right = ((int *)__pyx_v_ndarray_label_count_right->data); /* "sklearn/tree/_tree.pyx":121 * self.label_count_left = ndarray_label_count_left.data @@ -1901,7 +1758,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str * self.ndarray_label_count_left = ndarray_label_count_left * self.ndarray_label_count_right = ndarray_label_count_right */ - __pyx_v_self->label_count_init = ((int *)__pyx_v_ndarray_label_count_init->data); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->label_count_init = ((int *)__pyx_v_ndarray_label_count_init->data); /* "sklearn/tree/_tree.pyx":122 * self.label_count_right = ndarray_label_count_right.data @@ -1912,9 +1769,9 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_left)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_left)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_left); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_left); - __pyx_v_self->ndarray_label_count_left = ((PyObject *)__pyx_v_ndarray_label_count_left); + __Pyx_GOTREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_left); + __Pyx_DECREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_left); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_left = ((PyObject *)__pyx_v_ndarray_label_count_left); /* "sklearn/tree/_tree.pyx":123 * self.label_count_init = ndarray_label_count_init.data @@ -1925,9 +1782,9 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_right)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_right)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_right); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_right); - __pyx_v_self->ndarray_label_count_right = ((PyObject *)__pyx_v_ndarray_label_count_right); + __Pyx_GOTREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_right); + __Pyx_DECREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_right); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_right = ((PyObject *)__pyx_v_ndarray_label_count_right); /* "sklearn/tree/_tree.pyx":124 * self.ndarray_label_count_left = ndarray_label_count_left @@ -1938,9 +1795,9 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_init)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_init)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_init); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_init); - __pyx_v_self->ndarray_label_count_init = ((PyObject *)__pyx_v_ndarray_label_count_init); + __Pyx_GOTREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_init); + __Pyx_DECREF(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_init); + ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->ndarray_label_count_init = ((PyObject *)__pyx_v_ndarray_label_count_init); __pyx_r = 0; goto __pyx_L0; @@ -1952,17 +1809,17 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __Pyx_XDECREF(__pyx_t_5); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_right); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_left); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_init); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree.ClassificationCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_right); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_left); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ndarray_label_count_init); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_label_count_left); __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_label_count_right); @@ -1986,7 +1843,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; - __Pyx_RefNannySetupContext("init", 0); + __Pyx_RefNannySetupContext("init"); /* "sklearn/tree/_tree.pyx":129 * int n_total_samples): @@ -2112,7 +1969,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct int __pyx_v_c; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("reset", 0); + __Pyx_RefNannySetupContext("reset"); /* "sklearn/tree/_tree.pyx":148 * """Reset label_counts by setting `label_count_left to zero @@ -2190,7 +2047,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; - __Pyx_RefNannySetupContext("update", 0); + __Pyx_RefNannySetupContext("update"); /* "sklearn/tree/_tree.pyx":162 * cdef int c @@ -2306,10 +2163,10 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct * */ -static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { +static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { double __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("eval", 0); + __Pyx_RefNannySetupContext("eval"); __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -2324,7 +2181,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(CYTHO * */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_skip_dispatch) { PyArrayObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -2333,14 +2190,14 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_1init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); @@ -2379,17 +2236,6 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init_value (wrapper)", 0); - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - /* "sklearn/tree/_tree.pyx":177 * pass * @@ -2398,16 +2244,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_ * */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2445,7 +2292,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("eval", 0); + __Pyx_RefNannySetupContext("eval"); /* "sklearn/tree/_tree.pyx":190 * cdef double eval(self): @@ -2658,7 +2505,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("eval", 0); + __Pyx_RefNannySetupContext("eval"); /* "sklearn/tree/_tree.pyx":225 * cdef double eval(self): @@ -2785,20 +2632,6 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - /* "sklearn/tree/_tree.pyx":299 * cdef double var_right * @@ -2807,10 +2640,14 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje * self.n_left = 0 */ -static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { +static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__", 0); + __Pyx_RefNannySetupContext("__init__"); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; /* "sklearn/tree/_tree.pyx":300 * @@ -2819,7 +2656,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.n_left = 0 * self.n_right = 0 */ - __pyx_v_self->n_samples = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->n_samples = 0; /* "sklearn/tree/_tree.pyx":301 * def __init__(self): @@ -2828,7 +2665,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.n_right = 0 * self.mean_left = 0.0 */ - __pyx_v_self->n_left = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->n_left = 0; /* "sklearn/tree/_tree.pyx":302 * self.n_samples = 0 @@ -2837,7 +2674,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.mean_left = 0.0 * self.mean_right = 0.0 */ - __pyx_v_self->n_right = 0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->n_right = 0; /* "sklearn/tree/_tree.pyx":303 * self.n_left = 0 @@ -2846,7 +2683,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.mean_right = 0.0 * self.mean_init = 0.0 */ - __pyx_v_self->mean_left = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->mean_left = 0.0; /* "sklearn/tree/_tree.pyx":304 * self.n_right = 0 @@ -2855,7 +2692,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.mean_init = 0.0 * self.sq_sum_right = 0.0 */ - __pyx_v_self->mean_right = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->mean_right = 0.0; /* "sklearn/tree/_tree.pyx":305 * self.mean_left = 0.0 @@ -2864,7 +2701,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.sq_sum_right = 0.0 * self.sq_sum_left = 0.0 */ - __pyx_v_self->mean_init = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->mean_init = 0.0; /* "sklearn/tree/_tree.pyx":306 * self.mean_right = 0.0 @@ -2873,7 +2710,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.sq_sum_left = 0.0 * self.sq_sum_init = 0.0 */ - __pyx_v_self->sq_sum_right = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->sq_sum_right = 0.0; /* "sklearn/tree/_tree.pyx":307 * self.mean_init = 0.0 @@ -2882,7 +2719,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.sq_sum_init = 0.0 * self.var_left = 0.0 */ - __pyx_v_self->sq_sum_left = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->sq_sum_left = 0.0; /* "sklearn/tree/_tree.pyx":308 * self.sq_sum_right = 0.0 @@ -2891,7 +2728,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.var_left = 0.0 * self.var_right = 0.0 */ - __pyx_v_self->sq_sum_init = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->sq_sum_init = 0.0; /* "sklearn/tree/_tree.pyx":309 * self.sq_sum_left = 0.0 @@ -2900,7 +2737,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * self.var_right = 0.0 * */ - __pyx_v_self->var_left = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->var_left = 0.0; /* "sklearn/tree/_tree.pyx":310 * self.sq_sum_init = 0.0 @@ -2909,7 +2746,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct * * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, */ - __pyx_v_self->var_right = 0.0; + ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->var_right = 0.0; __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -2929,7 +2766,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("init", 0); + __Pyx_RefNannySetupContext("init"); /* "sklearn/tree/_tree.pyx":317 * are in the right branch and store the mean and squared @@ -3104,7 +2941,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("reset", 0); + __Pyx_RefNannySetupContext("reset"); /* "sklearn/tree/_tree.pyx":345 * right branch. @@ -3197,7 +3034,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("update", 0); + __Pyx_RefNannySetupContext("update"); /* "sklearn/tree/_tree.pyx":359 * """Update the criteria for each value in interval [a,b) (where a and b @@ -3356,10 +3193,10 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p * */ -static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { +static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { double __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("eval", 0); + __Pyx_RefNannySetupContext("eval"); __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -3374,7 +3211,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(CYTHON_UN * return np.asarray(self.mean_init) */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_skip_dispatch) { PyArrayObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -3384,14 +3221,14 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_1init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); @@ -3420,7 +3257,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->mean_init); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3447,35 +3284,747 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init_value (wrapper)", 0); - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} +/* "sklearn/tree/_tree.pyx":389 + * pass + * + * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< + * ## TODO is calling np.asarray a performance issue? + * return np.asarray(self.mean_init) + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_1init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init_value"); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":400 + * """ + * + * cdef double eval(self): # <<<<<<<<<<<<<< + * return self.var_left + self.var_right + * + */ + +static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_4tree_5_tree_MSE *__pyx_v_self) { + double __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("eval"); + + /* "sklearn/tree/_tree.pyx":401 + * + * cdef double eval(self): + * return self.var_left + self.var_right # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = (__pyx_v_self->__pyx_base.var_left + __pyx_v_self->__pyx_base.var_right); + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":408 + * cdef int y_stride + * + * def __init__(self): # <<<<<<<<<<<<<< + * self.criteria = [] + * + */ + +static int __pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__"); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; + + /* "sklearn/tree/_tree.pyx":409 + * + * def __init__(self): + * self.criteria = [] # <<<<<<<<<<<<<< + * + * self.n_outputs = 0 + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__criteria, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":411 + * self.criteria = [] + * + * self.n_outputs = 0 # <<<<<<<<<<<<<< + * self.y_stride = -1 + * + */ + ((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)__pyx_v_self)->n_outputs = 0; + + /* "sklearn/tree/_tree.pyx":412 + * + * self.n_outputs = 0 + * self.y_stride = -1 # <<<<<<<<<<<<<< + * + * def add_criterion(self, criterion): + */ + ((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)__pyx_v_self)->y_stride = -1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("sklearn.tree._tree.MultiOuputCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":414 + * self.y_stride = -1 + * + * def add_criterion(self, criterion): # <<<<<<<<<<<<<< + * self.criteria.append(criterion) + * self.n_outputs += 1 + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_1add_criterion(PyObject *__pyx_v_self, PyObject *__pyx_v_criterion); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_1add_criterion(PyObject *__pyx_v_self, PyObject *__pyx_v_criterion) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("add_criterion"); + + /* "sklearn/tree/_tree.pyx":415 + * + * def add_criterion(self, criterion): + * self.criteria.append(criterion) # <<<<<<<<<<<<<< + * self.n_outputs += 1 + * + */ + __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_criterion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/tree/_tree.pyx":416 + * def add_criterion(self, criterion): + * self.criteria.append(criterion) + * self.n_outputs += 1 # <<<<<<<<<<<<<< + * + * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, int n_total_samples): + */ + ((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)__pyx_v_self)->n_outputs = (((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)__pyx_v_self)->n_outputs + 1); + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("sklearn.tree._tree.MultiOuputCriterion.add_criterion", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":418 + * self.n_outputs += 1 + * + * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, int n_total_samples): # <<<<<<<<<<<<<< + * cdef Criterion criterion + * self.y_stride = n_total_samples + */ + +static void __pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init"); + + /* "sklearn/tree/_tree.pyx":420 + * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, int n_total_samples): + * cdef Criterion criterion + * self.y_stride = n_total_samples # <<<<<<<<<<<<<< + * + * for criterion in self.criteria: + */ + __pyx_v_self->y_stride = __pyx_v_n_total_samples; + + /* "sklearn/tree/_tree.pyx":422 + * self.y_stride = n_total_samples + * + * for criterion in self.criteria: # <<<<<<<<<<<<<< + * criterion.init(y, sample_mask, n_samples, n_total_samples) + * y += self.y_stride + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else if (PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_4tree_5_tree_Criterion))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_criterion)); + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":423 + * + * for criterion in self.criteria: + * criterion.init(y, sample_mask, n_samples, n_total_samples) # <<<<<<<<<<<<<< + * y += self.y_stride + * + */ + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_n_total_samples); + + /* "sklearn/tree/_tree.pyx":424 + * for criterion in self.criteria: + * criterion.init(y, sample_mask, n_samples, n_total_samples) + * y += self.y_stride # <<<<<<<<<<<<<< + * + * cdef void reset(self): + */ + __pyx_v_y = (__pyx_v_y + __pyx_v_self->y_stride); + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.tree._tree.MultiOuputCriterion.init", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_criterion); + __Pyx_RefNannyFinishContext(); +} + +/* "sklearn/tree/_tree.pyx":426 + * y += self.y_stride + * + * cdef void reset(self): # <<<<<<<<<<<<<< + * cdef Criterion criterion + * + */ + +static void __pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_reset(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_v_self) { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset"); + + /* "sklearn/tree/_tree.pyx":429 + * cdef Criterion criterion + * + * for criterion in self.criteria: # <<<<<<<<<<<<<< + * criterion.reset() + * + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else if (PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_4tree_5_tree_Criterion))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_criterion)); + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":430 + * + * for criterion in self.criteria: + * criterion.reset() # <<<<<<<<<<<<<< + * + * cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, BOOL_t *sample_mask): + */ + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.tree._tree.MultiOuputCriterion.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_criterion); + __Pyx_RefNannyFinishContext(); +} + +/* "sklearn/tree/_tree.pyx":432 + * criterion.reset() + * + * cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, BOOL_t *sample_mask): # <<<<<<<<<<<<<< + * cdef Criterion criterion + * + */ + +static int __pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; + int __pyx_v_n_left; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update"); + + /* "sklearn/tree/_tree.pyx":435 + * cdef Criterion criterion + * + * for criterion in self.criteria: # <<<<<<<<<<<<<< + * n_left = criterion.update(a, b, y, X_argsorted_i, sample_mask) + * y += self.y_stride + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else if (PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_4tree_5_tree_Criterion))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_criterion)); + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":436 + * + * for criterion in self.criteria: + * n_left = criterion.update(a, b, y, X_argsorted_i, sample_mask) # <<<<<<<<<<<<<< + * y += self.y_stride + * + */ + __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y, __pyx_v_X_argsorted_i, __pyx_v_sample_mask); + + /* "sklearn/tree/_tree.pyx":437 + * for criterion in self.criteria: + * n_left = criterion.update(a, b, y, X_argsorted_i, sample_mask) + * y += self.y_stride # <<<<<<<<<<<<<< + * + * cdef double eval(self): + */ + __pyx_v_y = (__pyx_v_y + __pyx_v_self->y_stride); + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.tree._tree.MultiOuputCriterion.update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_criterion); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":439 + * y += self.y_stride + * + * cdef double eval(self): # <<<<<<<<<<<<<< + * cdef Criterion criterion + * cdef double value = 0.0 + */ + +static double __pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_eval(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_v_self) { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; + double __pyx_v_value; + double __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("eval"); + + /* "sklearn/tree/_tree.pyx":441 + * cdef double eval(self): + * cdef Criterion criterion + * cdef double value = 0.0 # <<<<<<<<<<<<<< + * + * for criterion in self.criteria: + */ + __pyx_v_value = 0.0; + + /* "sklearn/tree/_tree.pyx":443 + * cdef double value = 0.0 + * + * for criterion in self.criteria: # <<<<<<<<<<<<<< + * value += criterion.eval() + * + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else if (PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_4tree_5_tree_Criterion))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_criterion)); + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":444 + * + * for criterion in self.criteria: + * value += criterion.eval() # <<<<<<<<<<<<<< + * + * return value / self.n_outputs + */ + __pyx_v_value = (__pyx_v_value + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/tree/_tree.pyx":446 + * value += criterion.eval() + * + * return value / self.n_outputs # <<<<<<<<<<<<<< + * + * cpdef np.ndarray init_value(self): + */ + __pyx_r = (__pyx_v_value / __pyx_v_self->n_outputs); + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("sklearn.tree._tree.MultiOuputCriterion.eval", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_criterion); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":448 + * return value / self.n_outputs + * + * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< + * cdef Criterion criterion + * values = [] + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_2init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; + PyObject *__pyx_v_values = NULL; + PyArrayObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("init_value"); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overriden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_2init_value)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "sklearn/tree/_tree.pyx":450 + * cpdef np.ndarray init_value(self): + * cdef Criterion criterion + * values = [] # <<<<<<<<<<<<<< + * + * for criterion in self.criteria: + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_v_values = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":452 + * values = [] + * + * for criterion in self.criteria: # <<<<<<<<<<<<<< + * values.append(criterion.init_value()) + * + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__criteria); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else if (PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7sklearn_4tree_5_tree_Criterion))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(((PyObject *)__pyx_v_criterion)); + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_t_1); + __pyx_t_1 = 0; -/* "sklearn/tree/_tree.pyx":389 - * pass + /* "sklearn/tree/_tree.pyx":453 + * + * for criterion in self.criteria: + * values.append(criterion.init_value()) # <<<<<<<<<<<<<< + * + * return np.hstack(values) + */ + if (unlikely(((PyObject *)__pyx_v_values) == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init_value(__pyx_v_criterion, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "sklearn/tree/_tree.pyx":455 + * values.append(criterion.init_value()) + * + * return np.hstack(values) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__hstack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __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 = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __Pyx_INCREF(((PyObject *)__pyx_v_values)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_values)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_values)); + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + goto __pyx_L0; + + __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("sklearn.tree._tree.MultiOuputCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_criterion); + __Pyx_XDECREF(__pyx_v_values); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":448 + * return value / self.n_outputs * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< - * ## TODO is calling np.asarray a performance issue? - * return np.asarray(self.mean_init) + * cdef Criterion criterion + * values = [] */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_2init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_2init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("init_value", 0); + __Pyx_RefNannySetupContext("init_value"); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MultiOuputCriterion *)((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3485,7 +4034,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_valu goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("sklearn.tree._tree.MultiOuputCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3493,54 +4042,56 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":400 - * """ - * - * cdef double eval(self): # <<<<<<<<<<<<<< - * return self.var_left + self.var_right - * - */ - -static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_4tree_5_tree_MSE *__pyx_v_self) { - double __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("eval", 0); - - /* "sklearn/tree/_tree.pyx":401 +/* "sklearn/tree/_tree.pyx":463 * - * cdef double eval(self): - * return self.var_left + self.var_right # <<<<<<<<<<<<<< * + * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< + * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_r = (__pyx_v_self->__pyx_base.var_left + __pyx_v_self->__pyx_base.var_right); - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_7sklearn_4tree_5_tree__random_sample_mask[] = "Create a random sample mask where ``n_total_in_bag`` elements are set.\n\n Parameters\n ----------\n n_total_samples : int\n The length of the resulting mask.\n n_total_in_bag : int\n The number of elements in the sample mask which are set to 1.\n random_state : np.RandomState\n A numpy ``RandomState`` object.\n\n Returns\n -------\n sample_mask : np.ndarray, shape=[n_total_samples]\n An ndarray where ``n_total_in_bag`` elements are set to ``True``\n the others are ``False``.\n "; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask = {__Pyx_NAMESTR("_random_sample_mask"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree__random_sample_mask)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree__random_sample_mask = {__Pyx_NAMESTR("_random_sample_mask"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree__random_sample_mask)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_n_total_samples; int __pyx_v_n_total_in_bag; PyObject *__pyx_v_random_state = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_total_samples,&__pyx_n_s__n_total_in_bag,&__pyx_n_s__random_state,0}; - PyObject *__pyx_r = 0; + PyArrayObject *__pyx_v_rand = 0; + PyArrayObject *__pyx_v_sample_mask = 0; + int __pyx_v_n_bagged; + int __pyx_v_i; + Py_buffer __pyx_bstruct_rand; + Py_ssize_t __pyx_bstride_0_rand = 0; + Py_ssize_t __pyx_bshape_0_rand = 0; + Py_buffer __pyx_bstruct_sample_mask; + Py_ssize_t __pyx_bstride_0_sample_mask = 0; + Py_ssize_t __pyx_bshape_0_sample_mask = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_random_sample_mask (wrapper)", 0); + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_total_samples,&__pyx_n_s__n_total_in_bag,&__pyx_n_s__random_state,0}; + __Pyx_RefNannySetupContext("_random_sample_mask"); __pyx_self = __pyx_self; { PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -3548,7 +4099,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_total_samples); if (likely(values[0])) kw_args--; @@ -3557,17 +4108,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_total_in_bag); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -3576,154 +4127,110 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } - __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_random_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._random_sample_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(__pyx_self, __pyx_v_n_total_samples, __pyx_v_n_total_in_bag, __pyx_v_random_state); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":409 - * - * - * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< - * """Create a random sample mask where ``n_total_in_bag`` elements are set. - * - */ + __pyx_bstruct_rand.buf = NULL; + __pyx_bstruct_sample_mask.buf = NULL; -static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n_total_samples, int __pyx_v_n_total_in_bag, PyObject *__pyx_v_random_state) { - PyArrayObject *__pyx_v_rand = 0; - PyArrayObject *__pyx_v_sample_mask = 0; - int __pyx_v_n_bagged; - int __pyx_v_i; - __Pyx_LocalBuf_ND __pyx_pybuffernd_rand; - __Pyx_Buffer __pyx_pybuffer_rand; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sample_mask; - __Pyx_Buffer __pyx_pybuffer_sample_mask; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyArrayObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyArrayObject *__pyx_t_7 = NULL; - int __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - int __pyx_t_12; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_random_sample_mask", 0); - __pyx_pybuffer_rand.pybuffer.buf = NULL; - __pyx_pybuffer_rand.refcount = 0; - __pyx_pybuffernd_rand.data = NULL; - __pyx_pybuffernd_rand.rcbuffer = &__pyx_pybuffer_rand; - __pyx_pybuffer_sample_mask.pybuffer.buf = NULL; - __pyx_pybuffer_sample_mask.refcount = 0; - __pyx_pybuffernd_sample_mask.data = NULL; - __pyx_pybuffernd_sample_mask.rcbuffer = &__pyx_pybuffer_sample_mask; - - /* "sklearn/tree/_tree.pyx":428 + /* "sklearn/tree/_tree.pyx":482 * """ * cdef np.ndarray[np.float64_t, ndim=1, mode="c"] rand = \ * random_state.rand(n_total_samples) # <<<<<<<<<<<<<< * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rand.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - __pyx_v_rand = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_rand.diminfo[0].strides = __pyx_pybuffernd_rand.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rand.diminfo[0].shape = __pyx_pybuffernd_rand.rcbuffer->pybuffer.shape[0]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_rand, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + __pyx_v_rand = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_rand.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_rand = __pyx_bstruct_rand.strides[0]; + __pyx_bshape_0_rand = __pyx_bstruct_rand.shape[0]; } } __pyx_t_4 = 0; __pyx_v_rand = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":430 + /* "sklearn/tree/_tree.pyx":484 * random_state.rand(n_total_samples) * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) # <<<<<<<<<<<<<< * * cdef int n_bagged = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__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 = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { - __pyx_v_sample_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_sample_mask.diminfo[0].strides = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_mask.diminfo[0].shape = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.shape[0]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sample_mask, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_sample_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_sample_mask.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_sample_mask = __pyx_bstruct_sample_mask.strides[0]; + __pyx_bshape_0_sample_mask = __pyx_bstruct_sample_mask.shape[0]; } } __pyx_t_7 = 0; __pyx_v_sample_mask = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":432 + /* "sklearn/tree/_tree.pyx":486 * np.zeros((n_total_samples,), dtype=np.int8) * * cdef int n_bagged = 0 # <<<<<<<<<<<<<< @@ -3732,7 +4239,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_n_bagged = 0; - /* "sklearn/tree/_tree.pyx":433 + /* "sklearn/tree/_tree.pyx":487 * * cdef int n_bagged = 0 * cdef int i = 0 # <<<<<<<<<<<<<< @@ -3741,7 +4248,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":434 + /* "sklearn/tree/_tree.pyx":488 * cdef int n_bagged = 0 * cdef int i = 0 * for i in range(n_total_samples): # <<<<<<<<<<<<<< @@ -3752,7 +4259,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9; - /* "sklearn/tree/_tree.pyx":435 + /* "sklearn/tree/_tree.pyx":489 * cdef int i = 0 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): # <<<<<<<<<<<<<< @@ -3760,10 +4267,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * n_bagged += 1 */ __pyx_t_10 = __pyx_v_i; - __pyx_t_11 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_rand.diminfo[0].strides)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); + __pyx_t_11 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_rand.buf, __pyx_t_10, __pyx_bstride_0_rand)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); if (__pyx_t_11) { - /* "sklearn/tree/_tree.pyx":436 + /* "sklearn/tree/_tree.pyx":490 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 # <<<<<<<<<<<<<< @@ -3771,9 +4278,9 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * */ __pyx_t_12 = __pyx_v_i; - *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_sample_mask.diminfo[0].strides) = 1; + *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_bstruct_sample_mask.buf, __pyx_t_12, __pyx_bstride_0_sample_mask) = 1; - /* "sklearn/tree/_tree.pyx":437 + /* "sklearn/tree/_tree.pyx":491 * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 * n_bagged += 1 # <<<<<<<<<<<<<< @@ -3781,12 +4288,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * return sample_mask.astype(np.bool) */ __pyx_v_n_bagged = (__pyx_v_n_bagged + 1); - goto __pyx_L5; + goto __pyx_L8; } - __pyx_L5:; + __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":439 + /* "sklearn/tree/_tree.pyx":493 * n_bagged += 1 * * return sample_mask.astype(np.bool) # <<<<<<<<<<<<<< @@ -3794,19 +4301,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -3824,15 +4331,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __Pyx_XDECREF(__pyx_t_6); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rand.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_rand); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sample_mask); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._random_sample_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rand.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_rand); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sample_mask); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_rand); __Pyx_XDECREF((PyObject *)__pyx_v_sample_mask); @@ -3841,27 +4348,76 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_2_apply_tree[] = "Finds the terminal region (=leaf node) for each sample in\n `X` and sets the corresponding element in `out` to its node id."; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree = {__Pyx_NAMESTR("_apply_tree"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_2_apply_tree)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":496 + * + * + * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< + * np.ndarray[np.int32_t, ndim=2] children, + * np.ndarray[np.int32_t, ndim=1] feature, + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_1_apply_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_1_apply_tree[] = "Finds the terminal region (=leaf node) for each sample in\n `X` and sets the corresponding element in `out` to its node id."; +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_1_apply_tree = {__Pyx_NAMESTR("_apply_tree"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_1_apply_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_1_apply_tree)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_1_apply_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_children = 0; PyArrayObject *__pyx_v_feature = 0; PyArrayObject *__pyx_v_threshold = 0; PyArrayObject *__pyx_v_out = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__children,&__pyx_n_s__feature,&__pyx_n_s__threshold,&__pyx_n_s__out,0}; - PyObject *__pyx_r = 0; + int __pyx_v_i; + int __pyx_v_n; + int __pyx_v_node_id; + Py_buffer __pyx_bstruct_feature; + Py_ssize_t __pyx_bstride_0_feature = 0; + Py_ssize_t __pyx_bshape_0_feature = 0; + Py_buffer __pyx_bstruct_threshold; + Py_ssize_t __pyx_bstride_0_threshold = 0; + Py_ssize_t __pyx_bshape_0_threshold = 0; + Py_buffer __pyx_bstruct_X; + Py_ssize_t __pyx_bstride_0_X = 0; + Py_ssize_t __pyx_bstride_1_X = 0; + Py_ssize_t __pyx_bshape_0_X = 0; + Py_ssize_t __pyx_bshape_1_X = 0; + Py_buffer __pyx_bstruct_children; + Py_ssize_t __pyx_bstride_0_children = 0; + Py_ssize_t __pyx_bstride_1_children = 0; + Py_ssize_t __pyx_bshape_0_children = 0; + Py_ssize_t __pyx_bshape_1_children = 0; + Py_buffer __pyx_bstruct_out; + Py_ssize_t __pyx_bstride_0_out = 0; + Py_ssize_t __pyx_bshape_0_out = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_apply_tree (wrapper)", 0); + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + long __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + long __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + __pyx_t_5numpy_int32_t __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + long __pyx_t_15; + int __pyx_t_16; + long __pyx_t_17; + int __pyx_t_18; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__children,&__pyx_n_s__feature,&__pyx_n_s__threshold,&__pyx_n_s__out,0}; + __Pyx_RefNannySetupContext("_apply_tree"); __pyx_self = __pyx_self; { PyObject* values[5] = {0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); @@ -3871,7 +4427,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X); if (likely(values[0])) kw_args--; @@ -3880,29 +4436,29 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__out); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -3921,119 +4477,54 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._apply_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_out); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":442 - * - * - * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< - * np.ndarray[np.int32_t, ndim=2] children, - * np.ndarray[np.int32_t, ndim=1] feature, - */ - -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_out) { - int __pyx_v_i; - int __pyx_v_n; - int __pyx_v_node_id; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X; - __Pyx_Buffer __pyx_pybuffer_X; - __Pyx_LocalBuf_ND __pyx_pybuffernd_children; - __Pyx_Buffer __pyx_pybuffer_children; - __Pyx_LocalBuf_ND __pyx_pybuffernd_feature; - __Pyx_Buffer __pyx_pybuffer_feature; - __Pyx_LocalBuf_ND __pyx_pybuffernd_out; - __Pyx_Buffer __pyx_pybuffer_out; - __Pyx_LocalBuf_ND __pyx_pybuffernd_threshold; - __Pyx_Buffer __pyx_pybuffer_threshold; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - long __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - long __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - __pyx_t_5numpy_int32_t __pyx_t_12; - int __pyx_t_13; - int __pyx_t_14; - long __pyx_t_15; - int __pyx_t_16; - long __pyx_t_17; - int __pyx_t_18; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_apply_tree", 0); - __pyx_pybuffer_X.pybuffer.buf = NULL; - __pyx_pybuffer_X.refcount = 0; - __pyx_pybuffernd_X.data = NULL; - __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; - __pyx_pybuffer_children.pybuffer.buf = NULL; - __pyx_pybuffer_children.refcount = 0; - __pyx_pybuffernd_children.data = NULL; - __pyx_pybuffernd_children.rcbuffer = &__pyx_pybuffer_children; - __pyx_pybuffer_feature.pybuffer.buf = NULL; - __pyx_pybuffer_feature.refcount = 0; - __pyx_pybuffernd_feature.data = NULL; - __pyx_pybuffernd_feature.rcbuffer = &__pyx_pybuffer_feature; - __pyx_pybuffer_threshold.pybuffer.buf = NULL; - __pyx_pybuffer_threshold.refcount = 0; - __pyx_pybuffernd_threshold.data = NULL; - __pyx_pybuffernd_threshold.rcbuffer = &__pyx_pybuffer_threshold; - __pyx_pybuffer_out.pybuffer.buf = NULL; - __pyx_pybuffer_out.refcount = 0; - __pyx_pybuffernd_out.data = NULL; - __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out; + __pyx_bstruct_X.buf = NULL; + __pyx_bstruct_children.buf = NULL; + __pyx_bstruct_feature.buf = NULL; + __pyx_bstruct_threshold.buf = NULL; + __pyx_bstruct_out.buf = NULL; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __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 = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (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 = 496; __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]; + __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; + __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_children, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_children = __pyx_bstruct_children.strides[0]; __pyx_bstride_1_children = __pyx_bstruct_children.strides[1]; + __pyx_bshape_0_children = __pyx_bstruct_children.shape[0]; __pyx_bshape_1_children = __pyx_bstruct_children.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_feature, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_feature = __pyx_bstruct_feature.strides[0]; + __pyx_bshape_0_feature = __pyx_bstruct_feature.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_threshold, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_threshold = __pyx_bstruct_threshold.strides[0]; + __pyx_bshape_0_threshold = __pyx_bstruct_threshold.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_out, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_out = __pyx_bstruct_out.strides[0]; + __pyx_bshape_0_out = __pyx_bstruct_out.shape[0]; - /* "sklearn/tree/_tree.pyx":449 + /* "sklearn/tree/_tree.pyx":503 * """Finds the terminal region (=leaf node) for each sample in * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 # <<<<<<<<<<<<<< @@ -4042,7 +4533,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":450 + /* "sklearn/tree/_tree.pyx":504 * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< @@ -4051,7 +4542,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":451 + /* "sklearn/tree/_tree.pyx":505 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< @@ -4060,7 +4551,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":452 + /* "sklearn/tree/_tree.pyx":506 * cdef int n = X.shape[0] * cdef int node_id = 0 * for i in xrange(n): # <<<<<<<<<<<<<< @@ -4071,7 +4562,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "sklearn/tree/_tree.pyx":453 + /* "sklearn/tree/_tree.pyx":507 * cdef int node_id = 0 * for i in xrange(n): * node_id = 0 # <<<<<<<<<<<<<< @@ -4080,7 +4571,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":455 + /* "sklearn/tree/_tree.pyx":509 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -4090,18 +4581,18 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj while (1) { __pyx_t_3 = __pyx_v_node_id; __pyx_t_4 = 0; - __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_3, __pyx_bstride_0_children, __pyx_t_4, __pyx_bstride_1_children)) != -1); if (__pyx_t_5) { __pyx_t_6 = __pyx_v_node_id; __pyx_t_7 = 1; - __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_6, __pyx_bstride_0_children, __pyx_t_7, __pyx_bstride_1_children)) != -1); __pyx_t_9 = __pyx_t_8; } else { __pyx_t_9 = __pyx_t_5; } if (!__pyx_t_9) break; - /* "sklearn/tree/_tree.pyx":456 + /* "sklearn/tree/_tree.pyx":510 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -4110,12 +4601,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_t_10 = __pyx_v_node_id; __pyx_t_11 = __pyx_v_i; - __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_feature.diminfo[0].strides)); + __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_feature.buf, __pyx_t_10, __pyx_bstride_0_feature)); __pyx_t_13 = __pyx_v_node_id; - __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); + __pyx_t_9 = ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_bstruct_X.buf, __pyx_t_11, __pyx_bstride_0_X, __pyx_t_12, __pyx_bstride_1_X)) <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_threshold.buf, __pyx_t_13, __pyx_bstride_0_threshold))); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":457 + /* "sklearn/tree/_tree.pyx":511 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -4124,12 +4615,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_t_14 = __pyx_v_node_id; __pyx_t_15 = 0; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_children.diminfo[1].strides)); - goto __pyx_L7; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_14, __pyx_bstride_0_children, __pyx_t_15, __pyx_bstride_1_children)); + goto __pyx_L10; } /*else*/ { - /* "sklearn/tree/_tree.pyx":459 + /* "sklearn/tree/_tree.pyx":513 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< @@ -4138,12 +4629,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_t_16 = __pyx_v_node_id; __pyx_t_17 = 1; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_16, __pyx_bstride_0_children, __pyx_t_17, __pyx_bstride_1_children)); } - __pyx_L7:; + __pyx_L10:; } - /* "sklearn/tree/_tree.pyx":460 + /* "sklearn/tree/_tree.pyx":514 * else: * node_id = children[node_id, 1] * out[i] = node_id # <<<<<<<<<<<<<< @@ -4151,7 +4642,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj * */ __pyx_t_18 = __pyx_v_i; - *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_v_node_id; + *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_out.buf, __pyx_t_18, __pyx_bstride_0_out) = __pyx_v_node_id; } __pyx_r = Py_None; __Pyx_INCREF(Py_None); @@ -4159,49 +4650,112 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_L1_error:; { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_children.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_feature.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_feature); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_threshold); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_children); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_out); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._apply_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_children.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_feature.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_feature); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_threshold); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_children); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_out); __pyx_L2:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_4_predict_tree[] = "Finds the terminal region (=leaf node) values for each sample. "; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree = {__Pyx_NAMESTR("_predict_tree"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_4_predict_tree)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":517 + * + * + * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< + * np.ndarray[np.int32_t, ndim=2] children, + * np.ndarray[np.int32_t, ndim=1] feature, + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_predict_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_2_predict_tree[] = "Finds the terminal region (=leaf node) values for each sample. "; +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_2_predict_tree = {__Pyx_NAMESTR("_predict_tree"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_2_predict_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_2_predict_tree)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_predict_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_children = 0; PyArrayObject *__pyx_v_feature = 0; PyArrayObject *__pyx_v_threshold = 0; PyArrayObject *__pyx_v_values = 0; PyArrayObject *__pyx_v_pred = 0; + int __pyx_v_i; + int __pyx_v_n; + int __pyx_v_node_id; + int __pyx_v_K; + int __pyx_v_k; + Py_buffer __pyx_bstruct_pred; + Py_ssize_t __pyx_bstride_0_pred = 0; + Py_ssize_t __pyx_bstride_1_pred = 0; + Py_ssize_t __pyx_bshape_0_pred = 0; + Py_ssize_t __pyx_bshape_1_pred = 0; + Py_buffer __pyx_bstruct_feature; + Py_ssize_t __pyx_bstride_0_feature = 0; + Py_ssize_t __pyx_bshape_0_feature = 0; + Py_buffer __pyx_bstruct_values; + Py_ssize_t __pyx_bstride_0_values = 0; + Py_ssize_t __pyx_bstride_1_values = 0; + Py_ssize_t __pyx_bshape_0_values = 0; + Py_ssize_t __pyx_bshape_1_values = 0; + Py_buffer __pyx_bstruct_threshold; + Py_ssize_t __pyx_bstride_0_threshold = 0; + Py_ssize_t __pyx_bshape_0_threshold = 0; + Py_buffer __pyx_bstruct_X; + Py_ssize_t __pyx_bstride_0_X = 0; + Py_ssize_t __pyx_bstride_1_X = 0; + Py_ssize_t __pyx_bshape_0_X = 0; + Py_ssize_t __pyx_bshape_1_X = 0; + Py_buffer __pyx_bstruct_children; + Py_ssize_t __pyx_bstride_0_children = 0; + Py_ssize_t __pyx_bstride_1_children = 0; + Py_ssize_t __pyx_bshape_0_children = 0; + Py_ssize_t __pyx_bshape_1_children = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + long __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + long __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + __pyx_t_5numpy_int32_t __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + long __pyx_t_15; + int __pyx_t_16; + long __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + int __pyx_t_21; + int __pyx_t_22; + int __pyx_t_23; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__children,&__pyx_n_s__feature,&__pyx_n_s__threshold,&__pyx_n_s__values,&__pyx_n_s__pred,0}; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_predict_tree (wrapper)", 0); + __Pyx_RefNannySetupContext("_predict_tree"); __pyx_self = __pyx_self; { PyObject* values[6] = {0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); @@ -4212,7 +4766,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X); if (likely(values[0])) kw_args--; @@ -4221,35 +4775,35 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__values); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -4270,138 +4824,62 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._predict_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_values, __pyx_v_pred); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":463 - * - * - * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< - * np.ndarray[np.int32_t, ndim=2] children, - * np.ndarray[np.int32_t, ndim=1] feature, - */ - -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_pred) { - int __pyx_v_i; - int __pyx_v_n; - int __pyx_v_node_id; - int __pyx_v_K; - int __pyx_v_k; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X; - __Pyx_Buffer __pyx_pybuffer_X; - __Pyx_LocalBuf_ND __pyx_pybuffernd_children; - __Pyx_Buffer __pyx_pybuffer_children; - __Pyx_LocalBuf_ND __pyx_pybuffernd_feature; - __Pyx_Buffer __pyx_pybuffer_feature; - __Pyx_LocalBuf_ND __pyx_pybuffernd_pred; - __Pyx_Buffer __pyx_pybuffer_pred; - __Pyx_LocalBuf_ND __pyx_pybuffernd_threshold; - __Pyx_Buffer __pyx_pybuffer_threshold; - __Pyx_LocalBuf_ND __pyx_pybuffernd_values; - __Pyx_Buffer __pyx_pybuffer_values; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - long __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - long __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - __pyx_t_5numpy_int32_t __pyx_t_12; - int __pyx_t_13; - int __pyx_t_14; - long __pyx_t_15; - int __pyx_t_16; - long __pyx_t_17; - int __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; - int __pyx_t_21; - int __pyx_t_22; - int __pyx_t_23; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_predict_tree", 0); - __pyx_pybuffer_X.pybuffer.buf = NULL; - __pyx_pybuffer_X.refcount = 0; - __pyx_pybuffernd_X.data = NULL; - __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; - __pyx_pybuffer_children.pybuffer.buf = NULL; - __pyx_pybuffer_children.refcount = 0; - __pyx_pybuffernd_children.data = NULL; - __pyx_pybuffernd_children.rcbuffer = &__pyx_pybuffer_children; - __pyx_pybuffer_feature.pybuffer.buf = NULL; - __pyx_pybuffer_feature.refcount = 0; - __pyx_pybuffernd_feature.data = NULL; - __pyx_pybuffernd_feature.rcbuffer = &__pyx_pybuffer_feature; - __pyx_pybuffer_threshold.pybuffer.buf = NULL; - __pyx_pybuffer_threshold.refcount = 0; - __pyx_pybuffernd_threshold.data = NULL; - __pyx_pybuffernd_threshold.rcbuffer = &__pyx_pybuffer_threshold; - __pyx_pybuffer_values.pybuffer.buf = NULL; - __pyx_pybuffer_values.refcount = 0; - __pyx_pybuffernd_values.data = NULL; - __pyx_pybuffernd_values.rcbuffer = &__pyx_pybuffer_values; - __pyx_pybuffer_pred.pybuffer.buf = NULL; - __pyx_pybuffer_pred.refcount = 0; - __pyx_pybuffernd_pred.data = NULL; - __pyx_pybuffernd_pred.rcbuffer = &__pyx_pybuffer_pred; + __pyx_bstruct_X.buf = NULL; + __pyx_bstruct_children.buf = NULL; + __pyx_bstruct_feature.buf = NULL; + __pyx_bstruct_threshold.buf = NULL; + __pyx_bstruct_values.buf = NULL; + __pyx_bstruct_pred.buf = NULL; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __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 = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (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 = 517; __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]; + __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; + __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_children, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_children = __pyx_bstruct_children.strides[0]; __pyx_bstride_1_children = __pyx_bstruct_children.strides[1]; + __pyx_bshape_0_children = __pyx_bstruct_children.shape[0]; __pyx_bshape_1_children = __pyx_bstruct_children.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_feature, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_feature = __pyx_bstruct_feature.strides[0]; + __pyx_bshape_0_feature = __pyx_bstruct_feature.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_threshold, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_threshold = __pyx_bstruct_threshold.strides[0]; + __pyx_bshape_0_threshold = __pyx_bstruct_threshold.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_values, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_values = __pyx_bstruct_values.strides[0]; __pyx_bstride_1_values = __pyx_bstruct_values.strides[1]; + __pyx_bshape_0_values = __pyx_bstruct_values.shape[0]; __pyx_bshape_1_values = __pyx_bstruct_values.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pred, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_pred.diminfo[0].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred.diminfo[0].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred.diminfo[1].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred.diminfo[1].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_pred = __pyx_bstruct_pred.strides[0]; __pyx_bstride_1_pred = __pyx_bstruct_pred.strides[1]; + __pyx_bshape_0_pred = __pyx_bstruct_pred.shape[0]; __pyx_bshape_1_pred = __pyx_bstruct_pred.shape[1]; - /* "sklearn/tree/_tree.pyx":470 + /* "sklearn/tree/_tree.pyx":524 * np.ndarray[np.float64_t, ndim=2] pred): * """Finds the terminal region (=leaf node) values for each sample. """ * cdef int i = 0 # <<<<<<<<<<<<<< @@ -4410,7 +4888,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":471 + /* "sklearn/tree/_tree.pyx":525 * """Finds the terminal region (=leaf node) values for each sample. """ * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< @@ -4419,7 +4897,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":472 + /* "sklearn/tree/_tree.pyx":526 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< @@ -4428,7 +4906,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":473 + /* "sklearn/tree/_tree.pyx":527 * cdef int n = X.shape[0] * cdef int node_id = 0 * cdef int K = values.shape[1] # <<<<<<<<<<<<<< @@ -4437,7 +4915,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_K = (__pyx_v_values->dimensions[1]); - /* "sklearn/tree/_tree.pyx":474 + /* "sklearn/tree/_tree.pyx":528 * cdef int node_id = 0 * cdef int K = values.shape[1] * for i in xrange(n): # <<<<<<<<<<<<<< @@ -4448,7 +4926,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "sklearn/tree/_tree.pyx":475 + /* "sklearn/tree/_tree.pyx":529 * cdef int K = values.shape[1] * for i in xrange(n): * node_id = 0 # <<<<<<<<<<<<<< @@ -4457,7 +4935,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":477 + /* "sklearn/tree/_tree.pyx":531 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -4467,18 +4945,18 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO while (1) { __pyx_t_3 = __pyx_v_node_id; __pyx_t_4 = 0; - __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_3, __pyx_bstride_0_children, __pyx_t_4, __pyx_bstride_1_children)) != -1); if (__pyx_t_5) { __pyx_t_6 = __pyx_v_node_id; __pyx_t_7 = 1; - __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_6, __pyx_bstride_0_children, __pyx_t_7, __pyx_bstride_1_children)) != -1); __pyx_t_9 = __pyx_t_8; } else { __pyx_t_9 = __pyx_t_5; } if (!__pyx_t_9) break; - /* "sklearn/tree/_tree.pyx":478 + /* "sklearn/tree/_tree.pyx":532 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -4487,12 +4965,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_t_10 = __pyx_v_node_id; __pyx_t_11 = __pyx_v_i; - __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_feature.diminfo[0].strides)); + __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_feature.buf, __pyx_t_10, __pyx_bstride_0_feature)); __pyx_t_13 = __pyx_v_node_id; - __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); + __pyx_t_9 = ((*__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_bstruct_X.buf, __pyx_t_11, __pyx_bstride_0_X, __pyx_t_12, __pyx_bstride_1_X)) <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_threshold.buf, __pyx_t_13, __pyx_bstride_0_threshold))); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":479 + /* "sklearn/tree/_tree.pyx":533 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -4501,12 +4979,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_t_14 = __pyx_v_node_id; __pyx_t_15 = 0; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_children.diminfo[1].strides)); - goto __pyx_L7; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_14, __pyx_bstride_0_children, __pyx_t_15, __pyx_bstride_1_children)); + goto __pyx_L10; } /*else*/ { - /* "sklearn/tree/_tree.pyx":481 + /* "sklearn/tree/_tree.pyx":535 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< @@ -4515,12 +4993,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_t_16 = __pyx_v_node_id; __pyx_t_17 = 1; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_children.buf, __pyx_t_16, __pyx_bstride_0_children, __pyx_t_17, __pyx_bstride_1_children)); } - __pyx_L7:; + __pyx_L10:; } - /* "sklearn/tree/_tree.pyx":482 + /* "sklearn/tree/_tree.pyx":536 * else: * node_id = children[node_id, 1] * for k in xrange(K): # <<<<<<<<<<<<<< @@ -4531,7 +5009,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_k = __pyx_t_19; - /* "sklearn/tree/_tree.pyx":483 + /* "sklearn/tree/_tree.pyx":537 * node_id = children[node_id, 1] * for k in xrange(K): * pred[i, k] = values[node_id, k] # <<<<<<<<<<<<<< @@ -4542,7 +5020,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_21 = __pyx_v_k; __pyx_t_22 = __pyx_v_i; __pyx_t_23 = __pyx_v_k; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_pred.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_pred.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_pred.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_values.diminfo[1].strides)); + *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_pred.buf, __pyx_t_22, __pyx_bstride_0_pred, __pyx_t_23, __pyx_bstride_1_pred) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_values.buf, __pyx_t_20, __pyx_bstride_0_values, __pyx_t_21, __pyx_bstride_1_values)); } } @@ -4551,49 +5029,65 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_L1_error:; { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_children.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_feature.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pred.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pred); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_feature); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_values); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_threshold); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_children); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._predict_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_children.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_feature.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pred.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_values.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pred); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_feature); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_values); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_threshold); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_children); __pyx_L2:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_6_error_at_leaf[] = "Compute criterion error at leaf with terminal region defined\n by `sample_mask`. "; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf = {__Pyx_NAMESTR("_error_at_leaf"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_6_error_at_leaf)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":540 + * + * + * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< + * np.ndarray sample_mask, Criterion criterion, + * int n_samples): + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_3_error_at_leaf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_3_error_at_leaf[] = "Compute criterion error at leaf with terminal region defined\n by `sample_mask`. "; +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_3_error_at_leaf = {__Pyx_NAMESTR("_error_at_leaf"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_3_error_at_leaf, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_3_error_at_leaf)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_3_error_at_leaf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_y = 0; PyArrayObject *__pyx_v_sample_mask = 0; struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; int __pyx_v_n_samples; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,&__pyx_n_s__sample_mask,&__pyx_n_s__criterion,&__pyx_n_s__n_samples,0}; - PyObject *__pyx_r = 0; + int __pyx_v_n_total_samples; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; + __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; + Py_buffer __pyx_bstruct_y; + Py_ssize_t __pyx_bstride_0_y = 0; + Py_ssize_t __pyx_bshape_0_y = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_error_at_leaf (wrapper)", 0); + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,&__pyx_n_s__sample_mask,&__pyx_n_s__criterion,&__pyx_n_s__n_samples,0}; + __Pyx_RefNannySetupContext("_error_at_leaf"); __pyx_self = __pyx_self; { PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); @@ -4602,7 +5096,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[0])) kw_args--; @@ -4611,23 +5105,23 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -4640,60 +5134,28 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ __pyx_v_y = ((PyArrayObject *)values[0]); __pyx_v_sample_mask = ((PyArrayObject *)values[1]); __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[2]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._error_at_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(__pyx_self, __pyx_v_y, __pyx_v_sample_mask, __pyx_v_criterion, __pyx_v_n_samples); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":486 - * - * - * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< - * np.ndarray sample_mask, Criterion criterion, - * int n_samples): - */ - -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_sample_mask, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, int __pyx_v_n_samples) { - int __pyx_v_n_total_samples; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; - __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; - __Pyx_LocalBuf_ND __pyx_pybuffernd_y; - __Pyx_Buffer __pyx_pybuffer_y; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_error_at_leaf", 0); - __pyx_pybuffer_y.pybuffer.buf = NULL; - __pyx_pybuffer_y.refcount = 0; - __pyx_pybuffernd_y.data = NULL; - __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; + __pyx_bstruct_y.buf = NULL; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_y = __pyx_bstruct_y.strides[0]; + __pyx_bshape_0_y = __pyx_bstruct_y.shape[0]; - /* "sklearn/tree/_tree.pyx":491 + /* "sklearn/tree/_tree.pyx":545 * """Compute criterion error at leaf with terminal region defined * by `sample_mask`. """ * cdef int n_total_samples = y.shape[0] # <<<<<<<<<<<<<< @@ -4702,7 +5164,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_n_total_samples = (__pyx_v_y->dimensions[0]); - /* "sklearn/tree/_tree.pyx":492 + /* "sklearn/tree/_tree.pyx":546 * by `sample_mask`. """ * cdef int n_total_samples = y.shape[0] * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< @@ -4711,7 +5173,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":493 + /* "sklearn/tree/_tree.pyx":547 * cdef int n_total_samples = y.shape[0] * cdef DTYPE_t *y_ptr = y.data * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -4720,7 +5182,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":494 + /* "sklearn/tree/_tree.pyx":548 * cdef DTYPE_t *y_ptr = y.data * cdef BOOL_t *sample_mask_ptr = sample_mask.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -4729,7 +5191,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":495 + /* "sklearn/tree/_tree.pyx":549 * cdef BOOL_t *sample_mask_ptr = sample_mask.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) * return criterion.eval() # <<<<<<<<<<<<<< @@ -4737,7 +5199,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4749,20 +5211,20 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py __Pyx_XDECREF(__pyx_t_1); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._error_at_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __pyx_L2:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":498 +/* "sklearn/tree/_tree.pyx":552 * * * cdef int smallest_sample_larger_than(int sample_idx, DTYPE_t *X_i, # <<<<<<<<<<<<<< @@ -4778,9 +5240,9 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - __Pyx_RefNannySetupContext("smallest_sample_larger_than", 0); + __Pyx_RefNannySetupContext("smallest_sample_larger_than"); - /* "sklearn/tree/_tree.pyx":515 + /* "sklearn/tree/_tree.pyx":569 * -1 if no such element exists. * """ * cdef int idx = 0, j # <<<<<<<<<<<<<< @@ -4789,7 +5251,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_idx = 0; - /* "sklearn/tree/_tree.pyx":516 + /* "sklearn/tree/_tree.pyx":570 * """ * cdef int idx = 0, j * cdef DTYPE_t threshold = -DBL_MAX # <<<<<<<<<<<<<< @@ -4798,7 +5260,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_threshold = (-DBL_MAX); - /* "sklearn/tree/_tree.pyx":518 + /* "sklearn/tree/_tree.pyx":572 * cdef DTYPE_t threshold = -DBL_MAX * * if sample_idx > -1: # <<<<<<<<<<<<<< @@ -4808,7 +5270,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = (__pyx_v_sample_idx > -1); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":519 + /* "sklearn/tree/_tree.pyx":573 * * if sample_idx > -1: * threshold = X_i[X_argsorted_i[sample_idx]] # <<<<<<<<<<<<<< @@ -4820,7 +5282,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":521 + /* "sklearn/tree/_tree.pyx":575 * threshold = X_i[X_argsorted_i[sample_idx]] * * for idx from sample_idx < idx < n_total_samples: # <<<<<<<<<<<<<< @@ -4830,7 +5292,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_2 = __pyx_v_n_total_samples; for (__pyx_v_idx = __pyx_v_sample_idx+1; __pyx_v_idx < __pyx_t_2; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":522 + /* "sklearn/tree/_tree.pyx":576 * * for idx from sample_idx < idx < n_total_samples: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -4839,7 +5301,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":524 + /* "sklearn/tree/_tree.pyx":578 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -4849,7 +5311,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":525 + /* "sklearn/tree/_tree.pyx":579 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -4861,7 +5323,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L6:; - /* "sklearn/tree/_tree.pyx":527 + /* "sklearn/tree/_tree.pyx":581 * continue * * if X_i[j] > threshold + 1.e-7: # <<<<<<<<<<<<<< @@ -4871,7 +5333,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_X_i[__pyx_v_j]) > (__pyx_v_threshold + 1.e-7)); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":528 + /* "sklearn/tree/_tree.pyx":582 * * if X_i[j] > threshold + 1.e-7: * return idx # <<<<<<<<<<<<<< @@ -4886,7 +5348,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_L4_continue:; } - /* "sklearn/tree/_tree.pyx":530 + /* "sklearn/tree/_tree.pyx":584 * return idx * * return -1 # <<<<<<<<<<<<<< @@ -4902,11 +5364,18 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_8_find_best_split[] = "Find the best dimension and threshold that minimises the error.\n\n Parameters\n ----------\n X : ndarray, shape (n_total_samples, n_features), dtype=DTYPE_t\n The feature values.\n\n y : ndarray, shape (n_total_samples,), dtype=float\n The label to predict for each sample.\n\n X_argsorted : ndarray, shape (n_samples, n_features)\n Argsort of cols of `X`. `X_argsorted[0,j]` gives the example\n index of the smallest value of feature `j`.\n\n sample_mask : ndarray, shape (n_samples,), dtype=np.bool\n A mask for the samples to be considered. Only samples `j` for which\n sample_mask[j] != 0 are considered.\n\n n_samples : int\n The number of samples in the current sample_mask\n (i.e. `sample_mask.sum()`).\n\n min_leaf : int\n The minimum number of samples required to be at a leaf node.\n\n max_features : int\n The number of features to consider when looking for the best split.\n\n criterion : Criterion\n The criterion function to be minimized.\n\n random_state : RandomState\n The numpy random state to use.\n\n Returns\n -------\n best_i : int\n The split feature or -1 if criterion not smaller than\n `parent_split_error`.\n\n best_t : DTYPE_t\n The split threshold\n\n best_error : DTYPE_t\n The split error\n\n initial_error : DTYPE_t\n The initial error contained in the node.\n "; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split = {__Pyx_NAMESTR("_find_best_split"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_8_find_best_split)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":587 + * + * + * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, + * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_find_best_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_4_find_best_split[] = "Find the best dimension and threshold that minimises the error.\n\n Parameters\n ----------\n X : ndarray, shape (n_total_samples, n_features), dtype=DTYPE_t\n The feature values.\n\n y : ndarray, shape (n_total_samples,), dtype=float\n The label to predict for each sample.\n\n X_argsorted : ndarray, shape (n_samples, n_features)\n Argsort of cols of `X`. `X_argsorted[0,j]` gives the example\n index of the smallest value of feature `j`.\n\n sample_mask : ndarray, shape (n_samples,), dtype=np.bool\n A mask for the samples to be considered. Only samples `j` for which\n sample_mask[j] != 0 are considered.\n\n n_samples : int\n The number of samples in the current sample_mask\n (i.e. `sample_mask.sum()`).\n\n min_leaf : int\n The minimum number of samples required to be at a leaf node.\n\n max_features : int\n The number of features to consider when looking for the best split.\n\n criterion : Criterion\n The criterion function to be minimized.\n\n random_state : RandomState\n The numpy random state to use.\n\n Returns\n -------\n best_i : int\n The split feature or -1 if criterion not smaller than\n `parent_split_error`.\n\n best_t : DTYPE_t\n The split threshold\n\n best_error : DTYPE_t\n The split error\n\n initial_error : DTYPE_t\n The initial error contained in the node.\n "; +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_4_find_best_split = {__Pyx_NAMESTR("_find_best_split"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_4_find_best_split, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_4_find_best_split)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_find_best_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_y = 0; PyArrayObject *__pyx_v_X_argsorted = 0; @@ -4916,17 +5385,75 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py int __pyx_v_max_features; struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; PyObject *__pyx_v_random_state = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__X_argsorted,&__pyx_n_s__sample_mask,&__pyx_n_s__n_samples,&__pyx_n_s__min_leaf,&__pyx_n_s__max_features,&__pyx_n_s__criterion,&__pyx_n_s__random_state,0}; - PyObject *__pyx_r = 0; + int __pyx_v_n_total_samples; + int __pyx_v_n_features; + int __pyx_v_i; + int __pyx_v_a; + int __pyx_v_b; + int __pyx_v_best_i; + Py_ssize_t __pyx_v_feature_idx; + int __pyx_v_n_left; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_t; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_initial_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; + int *__pyx_v_X_argsorted_i; + __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; + PyArrayObject *__pyx_v_features = 0; + int __pyx_v_X_elem_stride; + int __pyx_v_X_col_stride; + int __pyx_v_X_stride; + int __pyx_v_X_argsorted_elem_stride; + int __pyx_v_X_argsorted_col_stride; + int __pyx_v_X_argsorted_stride; + Py_buffer __pyx_bstruct_features; + Py_ssize_t __pyx_bstride_0_features = 0; + Py_ssize_t __pyx_bshape_0_features = 0; + Py_buffer __pyx_bstruct_X; + Py_ssize_t __pyx_bstride_0_X = 0; + Py_ssize_t __pyx_bstride_1_X = 0; + Py_ssize_t __pyx_bshape_0_X = 0; + Py_ssize_t __pyx_bshape_1_X = 0; + Py_buffer __pyx_bstruct_X_argsorted; + Py_ssize_t __pyx_bstride_0_X_argsorted = 0; + Py_ssize_t __pyx_bstride_1_X_argsorted = 0; + Py_ssize_t __pyx_bshape_0_X_argsorted = 0; + Py_ssize_t __pyx_bshape_1_X_argsorted = 0; + Py_buffer __pyx_bstruct_y; + Py_ssize_t __pyx_bstride_0_y = 0; + Py_ssize_t __pyx_bshape_0_y = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_find_best_split (wrapper)", 0); + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; + PyArrayObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_16; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__X_argsorted,&__pyx_n_s__sample_mask,&__pyx_n_s__n_samples,&__pyx_n_s__min_leaf,&__pyx_n_s__max_features,&__pyx_n_s__criterion,&__pyx_n_s__random_state,0}; + __Pyx_RefNannySetupContext("_find_best_split"); __pyx_self = __pyx_self; { PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); @@ -4940,7 +5467,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X); if (likely(values[0])) kw_args--; @@ -4949,195 +5476,114 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 6: - values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); - if (likely(values[6])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 7: - values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); - if (likely(values[7])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 8: - values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); - if (likely(values[8])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - values[7] = PyTuple_GET_ITEM(__pyx_args, 7); - values[8] = PyTuple_GET_ITEM(__pyx_args, 8); - } - __pyx_v_X = ((PyArrayObject *)values[0]); - __pyx_v_y = ((PyArrayObject *)values[1]); - __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); - __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); - __pyx_v_random_state = values[8]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":533 - * - * - * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, - * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, - */ - -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_X_argsorted, PyArrayObject *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_min_leaf, int __pyx_v_max_features, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, PyObject *__pyx_v_random_state) { - int __pyx_v_n_total_samples; - int __pyx_v_n_features; - int __pyx_v_i; - int __pyx_v_a; - int __pyx_v_b; - int __pyx_v_best_i; - Py_ssize_t __pyx_v_feature_idx; - int __pyx_v_n_left; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_initial_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; - int *__pyx_v_X_argsorted_i; - __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; - PyArrayObject *__pyx_v_features = 0; - int __pyx_v_X_elem_stride; - int __pyx_v_X_col_stride; - int __pyx_v_X_stride; - int __pyx_v_X_argsorted_elem_stride; - int __pyx_v_X_argsorted_col_stride; - int __pyx_v_X_argsorted_stride; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X; - __Pyx_Buffer __pyx_pybuffer_X; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X_argsorted; - __Pyx_Buffer __pyx_pybuffer_X_argsorted; - __Pyx_LocalBuf_ND __pyx_pybuffernd_features; - __Pyx_Buffer __pyx_pybuffer_features; - __Pyx_LocalBuf_ND __pyx_pybuffernd_y; - __Pyx_Buffer __pyx_pybuffer_y; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; - PyArrayObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_find_best_split", 0); - __pyx_pybuffer_features.pybuffer.buf = NULL; - __pyx_pybuffer_features.refcount = 0; - __pyx_pybuffernd_features.data = NULL; - __pyx_pybuffernd_features.rcbuffer = &__pyx_pybuffer_features; - __pyx_pybuffer_X.pybuffer.buf = NULL; - __pyx_pybuffer_X.refcount = 0; - __pyx_pybuffernd_X.data = NULL; - __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; - __pyx_pybuffer_y.pybuffer.buf = NULL; - __pyx_pybuffer_y.refcount = 0; - __pyx_pybuffernd_y.data = NULL; - __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; - __pyx_pybuffer_X_argsorted.pybuffer.buf = NULL; - __pyx_pybuffer_X_argsorted.refcount = 0; - __pyx_pybuffernd_X_argsorted.data = NULL; - __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; + else { + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 6: + values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); + if (likely(values[6])) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 7: + values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); + if (likely(values[7])) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 8: + values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); + if (likely(values[8])) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + } + __pyx_v_X = ((PyArrayObject *)values[0]); + __pyx_v_y = ((PyArrayObject *)values[1]); + __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); + __pyx_v_sample_mask = ((PyArrayObject *)values[3]); + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); + __pyx_v_random_state = values[8]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_bstruct_features.buf = NULL; + __pyx_bstruct_X.buf = NULL; + __pyx_bstruct_y.buf = NULL; + __pyx_bstruct_X_argsorted.buf = NULL; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __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]; + __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; + __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_y = __pyx_bstruct_y.strides[0]; + __pyx_bshape_0_y = __pyx_bstruct_y.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X_argsorted, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_X_argsorted = __pyx_bstruct_X_argsorted.strides[0]; __pyx_bstride_1_X_argsorted = __pyx_bstruct_X_argsorted.strides[1]; + __pyx_bshape_0_X_argsorted = __pyx_bstruct_X_argsorted.shape[0]; __pyx_bshape_1_X_argsorted = __pyx_bstruct_X_argsorted.shape[1]; - /* "sklearn/tree/_tree.pyx":592 + /* "sklearn/tree/_tree.pyx":646 * """ * # Variables declarations * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -5146,7 +5592,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":593 + /* "sklearn/tree/_tree.pyx":647 * # Variables declarations * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -5155,7 +5601,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":594 + /* "sklearn/tree/_tree.pyx":648 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 # <<<<<<<<<<<<<< @@ -5164,7 +5610,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":595 + /* "sklearn/tree/_tree.pyx":649 * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 * cdef Py_ssize_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -5173,7 +5619,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":596 + /* "sklearn/tree/_tree.pyx":650 * cdef int i, a, b, best_i = -1 * cdef Py_ssize_t feature_idx = -1 * cdef int n_left = 0 # <<<<<<<<<<<<<< @@ -5182,31 +5628,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = 0; - /* "sklearn/tree/_tree.pyx":598 + /* "sklearn/tree/_tree.pyx":652 * cdef int n_left = 0 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":599 + /* "sklearn/tree/_tree.pyx":653 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< @@ -5215,7 +5661,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":600 + /* "sklearn/tree/_tree.pyx":654 * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL # <<<<<<<<<<<<<< @@ -5224,7 +5670,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":601 + /* "sklearn/tree/_tree.pyx":655 * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL * cdef int *X_argsorted_i = NULL # <<<<<<<<<<<<<< @@ -5233,7 +5679,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":602 + /* "sklearn/tree/_tree.pyx":656 * cdef DTYPE_t *X_i = NULL * cdef int *X_argsorted_i = NULL * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -5242,7 +5688,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":603 + /* "sklearn/tree/_tree.pyx":657 * cdef int *X_argsorted_i = NULL * cdef BOOL_t *sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int64_t, ndim=1, mode='c'] features = None # <<<<<<<<<<<<<< @@ -5252,17 +5698,18 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_4 = ((PyArrayObject *)Py_None); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_features.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; } } __pyx_t_4 = 0; __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":607 + /* "sklearn/tree/_tree.pyx":661 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -5271,7 +5718,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":608 + /* "sklearn/tree/_tree.pyx":662 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -5280,7 +5727,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":609 + /* "sklearn/tree/_tree.pyx":663 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -5289,7 +5736,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":610 + /* "sklearn/tree/_tree.pyx":664 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -5298,7 +5745,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":611 + /* "sklearn/tree/_tree.pyx":665 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -5307,7 +5754,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":612 + /* "sklearn/tree/_tree.pyx":666 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -5316,7 +5763,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":615 + /* "sklearn/tree/_tree.pyx":669 * * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -5325,7 +5772,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":616 + /* "sklearn/tree/_tree.pyx":670 * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -5334,7 +5781,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":617 + /* "sklearn/tree/_tree.pyx":671 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -5343,7 +5790,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":619 + /* "sklearn/tree/_tree.pyx":673 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -5353,7 +5800,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":620 + /* "sklearn/tree/_tree.pyx":674 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, initial_error, initial_error # <<<<<<<<<<<<<< @@ -5361,16 +5808,16 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); @@ -5386,11 +5833,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_r = ((PyObject *)__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L0; - goto __pyx_L3; + goto __pyx_L6; } - __pyx_L3:; + __pyx_L6:; - /* "sklearn/tree/_tree.pyx":622 + /* "sklearn/tree/_tree.pyx":676 * return best_i, best_t, initial_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -5399,7 +5846,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":625 + /* "sklearn/tree/_tree.pyx":679 * * # Features to consider * if max_features < 0 or max_features == n_features: # <<<<<<<<<<<<<< @@ -5415,53 +5862,54 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_10) { - /* "sklearn/tree/_tree.pyx":626 + /* "sklearn/tree/_tree.pyx":680 * # Features to consider * if max_features < 0 or max_features == n_features: * features = np.arange(n_features) # <<<<<<<<<<<<<< * max_features = n_features * else: */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_11 < 0)) { PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14); } } - __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; + if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_8); __pyx_t_8 = 0; - /* "sklearn/tree/_tree.pyx":627 + /* "sklearn/tree/_tree.pyx":681 * if max_features < 0 or max_features == n_features: * features = np.arange(n_features) * max_features = n_features # <<<<<<<<<<<<<< @@ -5469,59 +5917,60 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * features = random_state.permutation(n_features)[:max_features] */ __pyx_v_max_features = __pyx_v_n_features; - goto __pyx_L4; + goto __pyx_L7; } /*else*/ { - /* "sklearn/tree/_tree.pyx":629 + /* "sklearn/tree/_tree.pyx":683 * max_features = n_features * else: * features = random_state.permutation(n_features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best split */ - __pyx_t_8 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_7); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_11 < 0)) { PyErr_Fetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_14, __pyx_t_13, __pyx_t_12); } } - __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; + if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; } - __pyx_L4:; + __pyx_L7:; - /* "sklearn/tree/_tree.pyx":632 + /* "sklearn/tree/_tree.pyx":686 * * # Look for the best split * for feature_idx in range(max_features): # <<<<<<<<<<<<<< @@ -5532,7 +5981,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_11; __pyx_t_15+=1) { __pyx_v_feature_idx = __pyx_t_15; - /* "sklearn/tree/_tree.pyx":633 + /* "sklearn/tree/_tree.pyx":687 * # Look for the best split * for feature_idx in range(max_features): * i = features[feature_idx] # <<<<<<<<<<<<<< @@ -5540,9 +5989,9 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * X_i = (X.data) + X_stride * i */ __pyx_t_16 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_features.buf, __pyx_t_16, __pyx_bstride_0_features)); - /* "sklearn/tree/_tree.pyx":635 + /* "sklearn/tree/_tree.pyx":689 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -5551,7 +6000,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":636 + /* "sklearn/tree/_tree.pyx":690 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -5560,7 +6009,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":639 + /* "sklearn/tree/_tree.pyx":693 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -5569,7 +6018,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":642 + /* "sklearn/tree/_tree.pyx":696 * * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 # <<<<<<<<<<<<<< @@ -5578,7 +6027,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":643 + /* "sklearn/tree/_tree.pyx":697 * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -5589,7 +6038,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_10 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_10) break; - /* "sklearn/tree/_tree.pyx":644 + /* "sklearn/tree/_tree.pyx":698 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -5599,7 +6048,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":647 + /* "sklearn/tree/_tree.pyx":701 * * # Consider splits between two consecutive samples * while True: # <<<<<<<<<<<<<< @@ -5609,7 +6058,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":650 + /* "sklearn/tree/_tree.pyx":704 * # Find the following larger sample * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) # <<<<<<<<<<<<<< @@ -5618,7 +6067,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_b = __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(__pyx_v_a, __pyx_v_X_i, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":651 + /* "sklearn/tree/_tree.pyx":705 * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) * if b == -1: # <<<<<<<<<<<<<< @@ -5628,19 +6077,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_10 = (__pyx_v_b == -1); if (__pyx_t_10) { - /* "sklearn/tree/_tree.pyx":652 + /* "sklearn/tree/_tree.pyx":706 * sample_mask_ptr, n_total_samples) * if b == -1: * break # <<<<<<<<<<<<<< * * # Better split than the best so far? */ - goto __pyx_L10_break; - goto __pyx_L11; + goto __pyx_L13_break; + goto __pyx_L14; } - __pyx_L11:; + __pyx_L14:; - /* "sklearn/tree/_tree.pyx":655 + /* "sklearn/tree/_tree.pyx":709 * * # Better split than the best so far? * n_left = criterion.update(a, b, y_ptr, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -5649,7 +6098,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y_ptr, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":658 + /* "sklearn/tree/_tree.pyx":712 * * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -5665,7 +6114,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":659 + /* "sklearn/tree/_tree.pyx":713 * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b # <<<<<<<<<<<<<< @@ -5674,19 +6123,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = __pyx_v_b; - /* "sklearn/tree/_tree.pyx":660 + /* "sklearn/tree/_tree.pyx":714 * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b * continue # <<<<<<<<<<<<<< * * error = criterion.eval() */ - goto __pyx_L9_continue; - goto __pyx_L12; + goto __pyx_L12_continue; + goto __pyx_L15; } - __pyx_L12:; + __pyx_L15:; - /* "sklearn/tree/_tree.pyx":662 + /* "sklearn/tree/_tree.pyx":716 * continue * * error = criterion.eval() # <<<<<<<<<<<<<< @@ -5695,7 +6144,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":664 + /* "sklearn/tree/_tree.pyx":718 * error = criterion.eval() * * if error < best_error: # <<<<<<<<<<<<<< @@ -5705,7 +6154,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_9 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":666 + /* "sklearn/tree/_tree.pyx":720 * if error < best_error: * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) # <<<<<<<<<<<<<< @@ -5714,7 +6163,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_t = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) + (((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])) / 2.0)); - /* "sklearn/tree/_tree.pyx":667 + /* "sklearn/tree/_tree.pyx":721 * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -5724,7 +6173,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_9 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":668 + /* "sklearn/tree/_tree.pyx":722 * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -5732,11 +6181,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * best_t = t */ __pyx_v_t = (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]); - goto __pyx_L14; + goto __pyx_L17; } - __pyx_L14:; + __pyx_L17:; - /* "sklearn/tree/_tree.pyx":669 + /* "sklearn/tree/_tree.pyx":723 * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] * best_i = i # <<<<<<<<<<<<<< @@ -5745,7 +6194,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":670 + /* "sklearn/tree/_tree.pyx":724 * t = X_i[X_argsorted_i[a]] * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -5754,7 +6203,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":671 + /* "sklearn/tree/_tree.pyx":725 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -5762,11 +6211,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * # Proceed to the next interval */ __pyx_v_best_error = __pyx_v_error; - goto __pyx_L13; + goto __pyx_L16; } - __pyx_L13:; + __pyx_L16:; - /* "sklearn/tree/_tree.pyx":674 + /* "sklearn/tree/_tree.pyx":728 * * # Proceed to the next interval * a = b # <<<<<<<<<<<<<< @@ -5774,12 +6223,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * return best_i, best_t, best_error, initial_error */ __pyx_v_a = __pyx_v_b; - __pyx_L9_continue:; + __pyx_L12_continue:; } - __pyx_L10_break:; + __pyx_L13_break:; } - /* "sklearn/tree/_tree.pyx":676 + /* "sklearn/tree/_tree.pyx":730 * a = b * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -5787,16 +6236,16 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); @@ -5823,19 +6272,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_XDECREF(__pyx_t_8); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X_argsorted); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X_argsorted); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_features); __Pyx_XGIVEREF(__pyx_r); @@ -5843,11 +6292,18 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7sklearn_4tree_5_tree_10_find_best_random_split[] = "Find the best dimension and threshold that minimises the error.\n\n Parameters\n ----------\n X : ndarray, shape (n_total_samples, n_features), dtype=DTYPE_t\n The feature values.\n\n y : ndarray, shape (n_total_samples,), dtype=float\n The label to predict for each sample.\n\n X_argsorted : ndarray, shape (n_samples, n_features)\n Argsort of cols of `X`. `X_argsorted[0,j]` gives the example\n index of the smallest value of feature `j`.\n\n sample_mask : ndarray, shape (n_samples,), dtype=np.bool\n A mask for the samples to be considered. Only samples `j` for which\n sample_mask[j] != 0 are considered.\n\n n_samples : int\n The number of samples in the current sample_mask\n (i.e. `sample_mask.sum()`).\n\n min_leaf : int\n The minimum number of samples required to be at a leaf node.\n\n max_features : int\n The number of features to consider when looking for the best split.\n\n criterion : Criterion\n The criterion function to be minimized.\n\n random_state : RandomState\n The numpy random state to use.\n\n Returns\n -------\n best_i : int\n The split feature or -1 if criterion not smaller than\n `parent_split_error`.\n\n best_t : DTYPE_t\n The split threshold\n\n best_error : DTYPE_t\n The split error\n\n initial_error : DTYPE_t\n The initial error contained in the node.\n "; -static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split = {__Pyx_NAMESTR("_find_best_random_split"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_10_find_best_random_split)}; -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +/* "sklearn/tree/_tree.pyx":732 + * return best_i, best_t, best_error, initial_error + * + * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, + * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_5_find_best_random_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7sklearn_4tree_5_tree_5_find_best_random_split[] = "Find the best dimension and threshold that minimises the error.\n\n Parameters\n ----------\n X : ndarray, shape (n_total_samples, n_features), dtype=DTYPE_t\n The feature values.\n\n y : ndarray, shape (n_total_samples,), dtype=float\n The label to predict for each sample.\n\n X_argsorted : ndarray, shape (n_samples, n_features)\n Argsort of cols of `X`. `X_argsorted[0,j]` gives the example\n index of the smallest value of feature `j`.\n\n sample_mask : ndarray, shape (n_samples,), dtype=np.bool\n A mask for the samples to be considered. Only samples `j` for which\n sample_mask[j] != 0 are considered.\n\n n_samples : int\n The number of samples in the current sample_mask\n (i.e. `sample_mask.sum()`).\n\n min_leaf : int\n The minimum number of samples required to be at a leaf node.\n\n max_features : int\n The number of features to consider when looking for the best split.\n\n criterion : Criterion\n The criterion function to be minimized.\n\n random_state : RandomState\n The numpy random state to use.\n\n Returns\n -------\n best_i : int\n The split feature or -1 if criterion not smaller than\n `parent_split_error`.\n\n best_t : DTYPE_t\n The split threshold\n\n best_error : DTYPE_t\n The split error\n\n initial_error : DTYPE_t\n The initial error contained in the node.\n "; +static PyMethodDef __pyx_mdef_7sklearn_4tree_5_tree_5_find_best_random_split = {__Pyx_NAMESTR("_find_best_random_split"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_5_find_best_random_split, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_5_find_best_random_split)}; +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_5_find_best_random_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyArrayObject *__pyx_v_X = 0; PyArrayObject *__pyx_v_y = 0; PyArrayObject *__pyx_v_X_argsorted = 0; @@ -5857,17 +6313,76 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje int __pyx_v_max_features; struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion = 0; PyObject *__pyx_v_random_state = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__X_argsorted,&__pyx_n_s__sample_mask,&__pyx_n_s__n_samples,&__pyx_n_s__min_leaf,&__pyx_n_s__max_features,&__pyx_n_s__criterion,&__pyx_n_s__random_state,0}; - PyObject *__pyx_r = 0; + int __pyx_v_n_total_samples; + int __pyx_v_n_features; + int __pyx_v_i; + int __pyx_v_a; + int __pyx_v_b; + int __pyx_v_c; + int __pyx_v_n_left; + int __pyx_v_best_i; + Py_ssize_t __pyx_v_feature_idx; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_t; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_initial_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; + int *__pyx_v_X_argsorted_i; + __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; + PyArrayObject *__pyx_v_features = 0; + int __pyx_v_X_elem_stride; + int __pyx_v_X_col_stride; + int __pyx_v_X_stride; + int __pyx_v_X_argsorted_elem_stride; + int __pyx_v_X_argsorted_col_stride; + int __pyx_v_X_argsorted_stride; + Py_buffer __pyx_bstruct_features; + Py_ssize_t __pyx_bstride_0_features = 0; + Py_ssize_t __pyx_bshape_0_features = 0; + Py_buffer __pyx_bstruct_X; + Py_ssize_t __pyx_bstride_0_X = 0; + Py_ssize_t __pyx_bstride_1_X = 0; + Py_ssize_t __pyx_bshape_0_X = 0; + Py_ssize_t __pyx_bshape_1_X = 0; + Py_buffer __pyx_bstruct_X_argsorted; + Py_ssize_t __pyx_bstride_0_X_argsorted = 0; + Py_ssize_t __pyx_bstride_1_X_argsorted = 0; + Py_ssize_t __pyx_bshape_0_X_argsorted = 0; + Py_ssize_t __pyx_bshape_1_X_argsorted = 0; + Py_buffer __pyx_bstruct_y; + Py_ssize_t __pyx_bstride_0_y = 0; + Py_ssize_t __pyx_bshape_0_y = 0; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_find_best_random_split (wrapper)", 0); + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; + PyArrayObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + Py_ssize_t __pyx_t_13; + Py_ssize_t __pyx_t_14; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__y,&__pyx_n_s__X_argsorted,&__pyx_n_s__sample_mask,&__pyx_n_s__n_samples,&__pyx_n_s__min_leaf,&__pyx_n_s__max_features,&__pyx_n_s__criterion,&__pyx_n_s__random_state,0}; + __Pyx_RefNannySetupContext("_find_best_random_split"); __pyx_self = __pyx_self; { PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); @@ -5881,7 +6396,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { + switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X); if (likely(values[0])) kw_args--; @@ -5890,53 +6405,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -5955,131 +6470,49 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_random_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "sklearn/tree/_tree.pyx":678 - * return best_i, best_t, best_error, initial_error - * - * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, - * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, - */ - -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_X_argsorted, PyArrayObject *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_min_leaf, int __pyx_v_max_features, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, PyObject *__pyx_v_random_state) { - int __pyx_v_n_total_samples; - int __pyx_v_n_features; - int __pyx_v_i; - int __pyx_v_a; - int __pyx_v_b; - int __pyx_v_c; - int __pyx_v_n_left; - int __pyx_v_best_i; - Py_ssize_t __pyx_v_feature_idx; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_initial_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; - int *__pyx_v_X_argsorted_i; - __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; - PyArrayObject *__pyx_v_features = 0; - int __pyx_v_X_elem_stride; - int __pyx_v_X_col_stride; - int __pyx_v_X_stride; - int __pyx_v_X_argsorted_elem_stride; - int __pyx_v_X_argsorted_col_stride; - int __pyx_v_X_argsorted_stride; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X; - __Pyx_Buffer __pyx_pybuffer_X; - __Pyx_LocalBuf_ND __pyx_pybuffernd_X_argsorted; - __Pyx_Buffer __pyx_pybuffer_X_argsorted; - __Pyx_LocalBuf_ND __pyx_pybuffernd_features; - __Pyx_Buffer __pyx_pybuffer_features; - __Pyx_LocalBuf_ND __pyx_pybuffernd_y; - __Pyx_Buffer __pyx_pybuffer_y; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; - PyArrayObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - Py_ssize_t __pyx_t_13; - Py_ssize_t __pyx_t_14; - int __pyx_t_15; - int __pyx_t_16; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_find_best_random_split", 0); - __pyx_pybuffer_features.pybuffer.buf = NULL; - __pyx_pybuffer_features.refcount = 0; - __pyx_pybuffernd_features.data = NULL; - __pyx_pybuffernd_features.rcbuffer = &__pyx_pybuffer_features; - __pyx_pybuffer_X.pybuffer.buf = NULL; - __pyx_pybuffer_X.refcount = 0; - __pyx_pybuffernd_X.data = NULL; - __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X; - __pyx_pybuffer_y.pybuffer.buf = NULL; - __pyx_pybuffer_y.refcount = 0; - __pyx_pybuffernd_y.data = NULL; - __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; - __pyx_pybuffer_X_argsorted.pybuffer.buf = NULL; - __pyx_pybuffer_X_argsorted.refcount = 0; - __pyx_pybuffernd_X_argsorted.data = NULL; - __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; + __pyx_bstruct_features.buf = NULL; + __pyx_bstruct_X.buf = NULL; + __pyx_bstruct_y.buf = NULL; + __pyx_bstruct_X_argsorted.buf = NULL; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __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]; + __pyx_bstride_0_X = __pyx_bstruct_X.strides[0]; __pyx_bstride_1_X = __pyx_bstruct_X.strides[1]; + __pyx_bshape_0_X = __pyx_bstruct_X.shape[0]; __pyx_bshape_1_X = __pyx_bstruct_X.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + __pyx_bstride_0_y = __pyx_bstruct_y.strides[0]; + __pyx_bshape_0_y = __pyx_bstruct_y.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_X_argsorted, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; + __pyx_bstride_0_X_argsorted = __pyx_bstruct_X_argsorted.strides[0]; __pyx_bstride_1_X_argsorted = __pyx_bstruct_X_argsorted.strides[1]; + __pyx_bshape_0_X_argsorted = __pyx_bstruct_X_argsorted.shape[0]; __pyx_bshape_1_X_argsorted = __pyx_bstruct_X_argsorted.shape[1]; - /* "sklearn/tree/_tree.pyx":737 + /* "sklearn/tree/_tree.pyx":791 * """ * # Variables * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -6088,7 +6521,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":738 + /* "sklearn/tree/_tree.pyx":792 * # Variables * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -6097,7 +6530,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":739 + /* "sklearn/tree/_tree.pyx":793 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 # <<<<<<<<<<<<<< @@ -6106,7 +6539,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":740 + /* "sklearn/tree/_tree.pyx":794 * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 * cdef Py_ssize_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -6115,31 +6548,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":742 + /* "sklearn/tree/_tree.pyx":796 * cdef Py_ssize_t feature_idx = -1 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":743 + /* "sklearn/tree/_tree.pyx":797 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< @@ -6148,7 +6581,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":744 + /* "sklearn/tree/_tree.pyx":798 * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL # <<<<<<<<<<<<<< @@ -6157,7 +6590,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":745 + /* "sklearn/tree/_tree.pyx":799 * cdef DTYPE_t *y_ptr = y.data * cdef DTYPE_t *X_i = NULL * cdef int *X_argsorted_i = NULL # <<<<<<<<<<<<<< @@ -6166,7 +6599,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":746 + /* "sklearn/tree/_tree.pyx":800 * cdef DTYPE_t *X_i = NULL * cdef int *X_argsorted_i = NULL * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -6175,7 +6608,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":747 + /* "sklearn/tree/_tree.pyx":801 * cdef int *X_argsorted_i = NULL * cdef BOOL_t *sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int64_t, ndim=1, mode='c'] features = None # <<<<<<<<<<<<<< @@ -6185,17 +6618,18 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_4 = ((PyArrayObject *)Py_None); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_features.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; } } __pyx_t_4 = 0; __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":751 + /* "sklearn/tree/_tree.pyx":805 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -6204,7 +6638,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":752 + /* "sklearn/tree/_tree.pyx":806 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -6213,7 +6647,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":753 + /* "sklearn/tree/_tree.pyx":807 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -6222,7 +6656,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":754 + /* "sklearn/tree/_tree.pyx":808 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -6231,7 +6665,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":755 + /* "sklearn/tree/_tree.pyx":809 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -6240,7 +6674,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":756 + /* "sklearn/tree/_tree.pyx":810 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -6249,7 +6683,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":759 + /* "sklearn/tree/_tree.pyx":813 * * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -6258,7 +6692,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":760 + /* "sklearn/tree/_tree.pyx":814 * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -6267,7 +6701,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":761 + /* "sklearn/tree/_tree.pyx":815 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -6276,7 +6710,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":763 + /* "sklearn/tree/_tree.pyx":817 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -6286,7 +6720,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":764 + /* "sklearn/tree/_tree.pyx":818 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -6294,16 +6728,16 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_8)); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); @@ -6319,11 +6753,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_r = ((PyObject *)__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L0; - goto __pyx_L3; + goto __pyx_L6; } - __pyx_L3:; + __pyx_L6:; - /* "sklearn/tree/_tree.pyx":766 + /* "sklearn/tree/_tree.pyx":820 * return best_i, best_t, best_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -6332,7 +6766,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":769 + /* "sklearn/tree/_tree.pyx":823 * * # Features to consider * if max_features == n_features: # <<<<<<<<<<<<<< @@ -6342,53 +6776,54 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = (__pyx_v_max_features == __pyx_v_n_features); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":770 + /* "sklearn/tree/_tree.pyx":824 * # Features to consider * if max_features == n_features: * features = np.arange(n_features) # <<<<<<<<<<<<<< * max_features = n_features * else: */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_6)); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_9 < 0)) { PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); } } - __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_8); __pyx_t_8 = 0; - /* "sklearn/tree/_tree.pyx":771 + /* "sklearn/tree/_tree.pyx":825 * if max_features == n_features: * features = np.arange(n_features) * max_features = n_features # <<<<<<<<<<<<<< @@ -6396,59 +6831,60 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * features = random_state.permutation(n_features)[:max_features] */ __pyx_v_max_features = __pyx_v_n_features; - goto __pyx_L4; + goto __pyx_L7; } /*else*/ { - /* "sklearn/tree/_tree.pyx":773 + /* "sklearn/tree/_tree.pyx":827 * max_features = n_features * else: * features = random_state.permutation(n_features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best random split */ - __pyx_t_8 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_7); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_9 < 0)) { PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_features, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10); } } - __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_bstride_0_features = __pyx_bstruct_features.strides[0]; + __pyx_bshape_0_features = __pyx_bstruct_features.shape[0]; + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; } - __pyx_L4:; + __pyx_L7:; - /* "sklearn/tree/_tree.pyx":776 + /* "sklearn/tree/_tree.pyx":830 * * # Look for the best random split * for feature_idx in range(max_features): # <<<<<<<<<<<<<< @@ -6459,7 +6895,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_9; __pyx_t_13+=1) { __pyx_v_feature_idx = __pyx_t_13; - /* "sklearn/tree/_tree.pyx":777 + /* "sklearn/tree/_tree.pyx":831 * # Look for the best random split * for feature_idx in range(max_features): * i = features[feature_idx] # <<<<<<<<<<<<<< @@ -6467,9 +6903,9 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * X_i = (X.data) + X_stride * i */ __pyx_t_14 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int64_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_features.buf, __pyx_t_14, __pyx_bstride_0_features)); - /* "sklearn/tree/_tree.pyx":779 + /* "sklearn/tree/_tree.pyx":833 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -6478,7 +6914,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":780 + /* "sklearn/tree/_tree.pyx":834 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -6487,7 +6923,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":783 + /* "sklearn/tree/_tree.pyx":837 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -6496,7 +6932,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":786 + /* "sklearn/tree/_tree.pyx":840 * * # Find min and max * a = 0 # <<<<<<<<<<<<<< @@ -6505,7 +6941,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":787 + /* "sklearn/tree/_tree.pyx":841 * # Find min and max * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -6516,7 +6952,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_5) break; - /* "sklearn/tree/_tree.pyx":788 + /* "sklearn/tree/_tree.pyx":842 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -6526,7 +6962,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":790 + /* "sklearn/tree/_tree.pyx":844 * a = a + 1 * * b = n_total_samples - 1 # <<<<<<<<<<<<<< @@ -6535,7 +6971,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_b = (__pyx_v_n_total_samples - 1); - /* "sklearn/tree/_tree.pyx":791 + /* "sklearn/tree/_tree.pyx":845 * * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: # <<<<<<<<<<<<<< @@ -6546,7 +6982,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_b])]) == 0); if (!__pyx_t_5) break; - /* "sklearn/tree/_tree.pyx":792 + /* "sklearn/tree/_tree.pyx":846 * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: * b = b - 1 # <<<<<<<<<<<<<< @@ -6556,7 +6992,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_b = (__pyx_v_b - 1); } - /* "sklearn/tree/_tree.pyx":794 + /* "sklearn/tree/_tree.pyx":848 * b = b - 1 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -6572,55 +7008,55 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_16) { - /* "sklearn/tree/_tree.pyx":795 + /* "sklearn/tree/_tree.pyx":849 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: * continue # <<<<<<<<<<<<<< * * # Draw a random threshold in [a, b) */ - goto __pyx_L5_continue; - goto __pyx_L11; + goto __pyx_L8_continue; + goto __pyx_L14; } - __pyx_L11:; + __pyx_L14:; - /* "sklearn/tree/_tree.pyx":798 + /* "sklearn/tree/_tree.pyx":852 * * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * # <<<<<<<<<<<<<< * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: */ - __pyx_t_7 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":799 + /* "sklearn/tree/_tree.pyx":853 * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) # <<<<<<<<<<<<<< * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] */ - __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyNumber_Multiply(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Multiply(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":800 + /* "sklearn/tree/_tree.pyx":854 * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -6630,7 +7066,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_16 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_16) { - /* "sklearn/tree/_tree.pyx":801 + /* "sklearn/tree/_tree.pyx":855 * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -6638,11 +7074,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * # Find the sample just greater than t */ __pyx_v_t = (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]); - goto __pyx_L12; + goto __pyx_L15; } - __pyx_L12:; + __pyx_L15:; - /* "sklearn/tree/_tree.pyx":804 + /* "sklearn/tree/_tree.pyx":858 * * # Find the sample just greater than t * c = a + 1 # <<<<<<<<<<<<<< @@ -6651,7 +7087,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_c = (__pyx_v_a + 1); - /* "sklearn/tree/_tree.pyx":806 + /* "sklearn/tree/_tree.pyx":860 * c = a + 1 * * while True: # <<<<<<<<<<<<<< @@ -6661,7 +7097,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":807 + /* "sklearn/tree/_tree.pyx":861 * * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: # <<<<<<<<<<<<<< @@ -6671,7 +7107,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_16 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_c])]) != 0); if (__pyx_t_16) { - /* "sklearn/tree/_tree.pyx":808 + /* "sklearn/tree/_tree.pyx":862 * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: # <<<<<<<<<<<<<< @@ -6687,22 +7123,22 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_15) { - /* "sklearn/tree/_tree.pyx":809 + /* "sklearn/tree/_tree.pyx":863 * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: * break # <<<<<<<<<<<<<< * * c += 1 */ - goto __pyx_L14_break; - goto __pyx_L16; + goto __pyx_L17_break; + goto __pyx_L19; } - __pyx_L16:; - goto __pyx_L15; + __pyx_L19:; + goto __pyx_L18; } - __pyx_L15:; + __pyx_L18:; - /* "sklearn/tree/_tree.pyx":811 + /* "sklearn/tree/_tree.pyx":865 * break * * c += 1 # <<<<<<<<<<<<<< @@ -6711,9 +7147,9 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_c = (__pyx_v_c + 1); } - __pyx_L14_break:; + __pyx_L17_break:; - /* "sklearn/tree/_tree.pyx":814 + /* "sklearn/tree/_tree.pyx":868 * * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -6722,7 +7158,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, 0, __pyx_v_c, __pyx_v_y_ptr, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":815 + /* "sklearn/tree/_tree.pyx":869 * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, X_argsorted_i, sample_mask_ptr) * error = criterion.eval() # <<<<<<<<<<<<<< @@ -6731,7 +7167,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":817 + /* "sklearn/tree/_tree.pyx":871 * error = criterion.eval() * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -6747,19 +7183,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":818 + /* "sklearn/tree/_tree.pyx":872 * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * continue # <<<<<<<<<<<<<< * * if error < best_error: */ - goto __pyx_L5_continue; - goto __pyx_L17; + goto __pyx_L8_continue; + goto __pyx_L20; } - __pyx_L17:; + __pyx_L20:; - /* "sklearn/tree/_tree.pyx":820 + /* "sklearn/tree/_tree.pyx":874 * continue * * if error < best_error: # <<<<<<<<<<<<<< @@ -6769,7 +7205,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":821 + /* "sklearn/tree/_tree.pyx":875 * * if error < best_error: * best_i = i # <<<<<<<<<<<<<< @@ -6778,7 +7214,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":822 + /* "sklearn/tree/_tree.pyx":876 * if error < best_error: * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -6787,7 +7223,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":823 + /* "sklearn/tree/_tree.pyx":877 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -6795,28 +7231,28 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * return best_i, best_t, best_error, initial_error */ __pyx_v_best_error = __pyx_v_error; - goto __pyx_L18; + goto __pyx_L21; } - __pyx_L18:; - __pyx_L5_continue:; + __pyx_L21:; + __pyx_L8_continue:; } - /* "sklearn/tree/_tree.pyx":825 + /* "sklearn/tree/_tree.pyx":879 * best_error = error * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); @@ -6843,19 +7279,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_XDECREF(__pyx_t_8); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X_argsorted); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree._find_best_random_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_features); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_X_argsorted); + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_features); __Pyx_XGIVEREF(__pyx_r); @@ -6863,18 +7299,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "numpy.pxd":193 +/* "numpy.pxd":190 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -6882,7 +7307,8 @@ static int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_bu * # requirements, and does not yet fullfill the PEP. */ -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { +static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; @@ -6907,13 +7333,13 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__getbuffer__", 0); + __Pyx_RefNannySetupContext("__getbuffer__"); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } - /* "numpy.pxd":199 + /* "numpy.pxd":196 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< @@ -6924,11 +7350,11 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; - goto __pyx_L3; + goto __pyx_L5; } - __pyx_L3:; + __pyx_L5:; - /* "numpy.pxd":202 + /* "numpy.pxd":199 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -6937,7 +7363,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "numpy.pxd":203 + /* "numpy.pxd":200 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -6946,16 +7372,16 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "numpy.pxd":205 + /* "numpy.pxd":202 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ - __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self)); - /* "numpy.pxd":207 + /* "numpy.pxd":204 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -6965,7 +7391,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_1) { - /* "numpy.pxd":208 + /* "numpy.pxd":205 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -6973,11 +7399,11 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * copy_shape = 0 */ __pyx_v_copy_shape = 1; - goto __pyx_L4; + goto __pyx_L6; } /*else*/ { - /* "numpy.pxd":210 + /* "numpy.pxd":207 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -6986,9 +7412,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_copy_shape = 0; } - __pyx_L4:; + __pyx_L6:; - /* "numpy.pxd":212 + /* "numpy.pxd":209 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -6998,37 +7424,37 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS); if (__pyx_t_1) { - /* "numpy.pxd":213 + /* "numpy.pxd":210 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ - __pyx_t_2 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS)); + __pyx_t_2 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS)); __pyx_t_3 = __pyx_t_2; } else { __pyx_t_3 = __pyx_t_1; } if (__pyx_t_3) { - /* "numpy.pxd":214 + /* "numpy.pxd":211 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; } - __pyx_L5:; + __pyx_L7:; - /* "numpy.pxd":216 + /* "numpy.pxd":213 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -7038,46 +7464,46 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS); if (__pyx_t_3) { - /* "numpy.pxd":217 + /* "numpy.pxd":214 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ - __pyx_t_1 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS)); + __pyx_t_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS)); __pyx_t_2 = __pyx_t_1; } else { __pyx_t_2 = __pyx_t_3; } if (__pyx_t_2) { - /* "numpy.pxd":218 + /* "numpy.pxd":215 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; } - __pyx_L6:; + __pyx_L8:; - /* "numpy.pxd":220 + /* "numpy.pxd":217 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ - __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self)); - /* "numpy.pxd":221 + /* "numpy.pxd":218 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -7086,7 +7512,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "numpy.pxd":222 + /* "numpy.pxd":219 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -7095,7 +7521,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_v_copy_shape) { - /* "numpy.pxd":225 + /* "numpy.pxd":222 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -7104,7 +7530,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - /* "numpy.pxd":226 + /* "numpy.pxd":223 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -7113,7 +7539,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "numpy.pxd":227 + /* "numpy.pxd":224 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -7124,49 +7550,49 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "numpy.pxd":228 + /* "numpy.pxd":225 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ - (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); - /* "numpy.pxd":229 + /* "numpy.pxd":226 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ - (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]); } - goto __pyx_L7; + goto __pyx_L9; } /*else*/ { - /* "numpy.pxd":231 + /* "numpy.pxd":228 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ - __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))); - /* "numpy.pxd":232 + /* "numpy.pxd":229 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ - __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self))); } - __pyx_L7:; + __pyx_L9:; - /* "numpy.pxd":233 + /* "numpy.pxd":230 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -7175,25 +7601,25 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "numpy.pxd":234 + /* "numpy.pxd":231 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ - __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self)); - /* "numpy.pxd":235 + /* "numpy.pxd":232 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ - __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(__pyx_v_self)); + __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self))); - /* "numpy.pxd":238 + /* "numpy.pxd":235 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -7202,17 +7628,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "numpy.pxd":239 + /* "numpy.pxd":236 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef list stack * cdef int offset */ - __Pyx_INCREF(((PyObject *)__pyx_v_self->descr)); - __pyx_v_descr = __pyx_v_self->descr; + __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr)); + __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr; - /* "numpy.pxd":243 + /* "numpy.pxd":240 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -7221,7 +7647,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "numpy.pxd":245 + /* "numpy.pxd":242 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -7237,7 +7663,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } if (__pyx_t_1) { - /* "numpy.pxd":247 + /* "numpy.pxd":244 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -7249,26 +7675,26 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; - goto __pyx_L10; + goto __pyx_L12; } /*else*/ { - /* "numpy.pxd":250 + /* "numpy.pxd":247 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_INCREF(__pyx_v_self); + __Pyx_GIVEREF(__pyx_v_self); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + __pyx_v_info->obj = __pyx_v_self; } - __pyx_L10:; + __pyx_L12:; - /* "numpy.pxd":252 + /* "numpy.pxd":249 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -7278,7 +7704,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (!__pyx_v_hasfields); if (__pyx_t_1) { - /* "numpy.pxd":253 + /* "numpy.pxd":250 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -7287,7 +7713,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_t = __pyx_v_descr->type_num; - /* "numpy.pxd":254 + /* "numpy.pxd":251 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -7302,7 +7728,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } if (!__pyx_t_2) { - /* "numpy.pxd":255 + /* "numpy.pxd":252 * t = descr.type_num * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -7322,23 +7748,23 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } if (__pyx_t_1) { - /* "numpy.pxd":256 + /* "numpy.pxd":253 * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L12; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L14; } - __pyx_L12:; + __pyx_L14:; - /* "numpy.pxd":257 + /* "numpy.pxd":254 * (descr.byteorder == '<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -7348,10 +7774,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_BYTE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__b; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":258 + /* "numpy.pxd":255 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -7361,10 +7787,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_UBYTE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__B; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":259 + /* "numpy.pxd":256 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -7374,10 +7800,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_SHORT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__h; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":260 + /* "numpy.pxd":257 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -7387,10 +7813,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_USHORT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__H; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":261 + /* "numpy.pxd":258 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -7400,10 +7826,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_INT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__i; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":262 + /* "numpy.pxd":259 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -7413,10 +7839,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_UINT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__I; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":263 + /* "numpy.pxd":260 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -7426,10 +7852,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_LONG); if (__pyx_t_1) { __pyx_v_f = __pyx_k__l; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":264 + /* "numpy.pxd":261 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -7439,10 +7865,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_ULONG); if (__pyx_t_1) { __pyx_v_f = __pyx_k__L; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":265 + /* "numpy.pxd":262 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -7452,10 +7878,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG); if (__pyx_t_1) { __pyx_v_f = __pyx_k__q; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":266 + /* "numpy.pxd":263 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -7465,10 +7891,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG); if (__pyx_t_1) { __pyx_v_f = __pyx_k__Q; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":267 + /* "numpy.pxd":264 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -7478,10 +7904,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_FLOAT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__f; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":268 + /* "numpy.pxd":265 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -7491,10 +7917,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__d; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":269 + /* "numpy.pxd":266 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -7504,10 +7930,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__g; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":270 + /* "numpy.pxd":267 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -7517,10 +7943,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__Zf; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":271 + /* "numpy.pxd":268 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -7530,10 +7956,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__Zd; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":272 + /* "numpy.pxd":269 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -7543,10 +7969,10 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE); if (__pyx_t_1) { __pyx_v_f = __pyx_k__Zg; - goto __pyx_L13; + goto __pyx_L15; } - /* "numpy.pxd":273 + /* "numpy.pxd":270 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -7556,37 +7982,37 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_t == NPY_OBJECT); if (__pyx_t_1) { __pyx_v_f = __pyx_k__O; - goto __pyx_L13; + goto __pyx_L15; } /*else*/ { - /* "numpy.pxd":275 + /* "numpy.pxd":272 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8)); __Pyx_GIVEREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L13:; + __pyx_L15:; - /* "numpy.pxd":276 + /* "numpy.pxd":273 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -7595,7 +8021,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "numpy.pxd":277 + /* "numpy.pxd":274 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -7604,11 +8030,11 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_r = 0; goto __pyx_L0; - goto __pyx_L11; + goto __pyx_L13; } /*else*/ { - /* "numpy.pxd":279 + /* "numpy.pxd":276 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -7617,7 +8043,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = ((char *)malloc(255)); - /* "numpy.pxd":280 + /* "numpy.pxd":277 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -7626,7 +8052,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "numpy.pxd":281 + /* "numpy.pxd":278 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = '^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -7635,17 +8061,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "numpy.pxd":284 + /* "numpy.pxd":281 * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, * &offset) # <<<<<<<<<<<<<< * f[0] = 0 # Terminate format string * */ - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; - /* "numpy.pxd":285 + /* "numpy.pxd":282 * info.format + _buffer_format_string_len, * &offset) * f[0] = 0 # Terminate format string # <<<<<<<<<<<<<< @@ -7654,7 +8080,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_f[0]) = 0; } - __pyx_L11:; + __pyx_L13:; __pyx_r = 0; goto __pyx_L0; @@ -7679,16 +8105,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* Python wrapper */ -static void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); - __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); - __Pyx_RefNannyFinishContext(); -} - -/* "numpy.pxd":287 +/* "numpy.pxd":284 * f[0] = 0 # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -7696,22 +8113,23 @@ static void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, * stdlib.free(info.format) */ -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { +static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pf_5numpy_7ndarray_1__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("__releasebuffer__", 0); + __Pyx_RefNannySetupContext("__releasebuffer__"); - /* "numpy.pxd":288 + /* "numpy.pxd":285 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ - __pyx_t_1 = PyArray_HASFIELDS(__pyx_v_self); + __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self)); if (__pyx_t_1) { - /* "numpy.pxd":289 + /* "numpy.pxd":286 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -7719,11 +8137,11 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s * stdlib.free(info.strides) */ free(__pyx_v_info->format); - goto __pyx_L3; + goto __pyx_L5; } - __pyx_L3:; + __pyx_L5:; - /* "numpy.pxd":290 + /* "numpy.pxd":287 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -7733,7 +8151,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t))); if (__pyx_t_1) { - /* "numpy.pxd":291 + /* "numpy.pxd":288 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -7741,14 +8159,14 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s * */ free(__pyx_v_info->strides); - goto __pyx_L4; + goto __pyx_L6; } - __pyx_L4:; + __pyx_L6:; __Pyx_RefNannyFinishContext(); } -/* "numpy.pxd":767 +/* "numpy.pxd":764 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -7763,9 +8181,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1"); - /* "numpy.pxd":768 + /* "numpy.pxd":765 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -7773,7 +8191,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7791,7 +8209,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "numpy.pxd":770 +/* "numpy.pxd":767 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -7806,9 +8224,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2"); - /* "numpy.pxd":771 + /* "numpy.pxd":768 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -7816,7 +8234,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7834,7 +8252,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "numpy.pxd":773 +/* "numpy.pxd":770 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -7849,9 +8267,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3"); - /* "numpy.pxd":774 + /* "numpy.pxd":771 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -7859,7 +8277,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7877,7 +8295,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "numpy.pxd":776 +/* "numpy.pxd":773 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -7892,9 +8310,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4"); - /* "numpy.pxd":777 + /* "numpy.pxd":774 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -7902,7 +8320,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7920,7 +8338,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "numpy.pxd":779 +/* "numpy.pxd":776 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -7935,9 +8353,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5"); - /* "numpy.pxd":780 + /* "numpy.pxd":777 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -7945,7 +8363,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7963,7 +8381,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "numpy.pxd":782 +/* "numpy.pxd":779 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -7995,9 +8413,9 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_util_dtypestring", 0); + __Pyx_RefNannySetupContext("_util_dtypestring"); - /* "numpy.pxd":789 + /* "numpy.pxd":786 * cdef int delta_offset * cdef tuple i * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -8006,7 +8424,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "numpy.pxd":790 + /* "numpy.pxd":787 * cdef tuple i * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -8015,7 +8433,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "numpy.pxd":793 + /* "numpy.pxd":790 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -8023,7 +8441,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * child, new_offset = fields */ if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { @@ -8033,21 +8451,21 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_v_childname = __pyx_t_3; __pyx_t_3 = 0; - /* "numpy.pxd":794 + /* "numpy.pxd":791 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ - __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF(((PyObject *)__pyx_v_fields)); __pyx_v_fields = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "numpy.pxd":795 + /* "numpy.pxd":792 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -8059,7 +8477,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) { if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2); else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence)); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); @@ -8067,9 +8485,9 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_INCREF(__pyx_t_4); } else { __Pyx_UnpackTupleError(((PyObject *)__pyx_v_fields), 2); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF(((PyObject *)__pyx_v_child)); __pyx_v_child = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; @@ -8077,48 +8495,48 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_v_new_offset = __pyx_t_4; __pyx_t_4 = 0; - /* "numpy.pxd":797 + /* "numpy.pxd":794 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ - __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { - /* "numpy.pxd":798 + /* "numpy.pxd":795 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == '>' and little_endian) or */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "numpy.pxd":800 + /* "numpy.pxd":797 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == '>' and little_endian) or # <<<<<<<<<<<<<< @@ -8133,7 +8551,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } if (!__pyx_t_7) { - /* "numpy.pxd":801 + /* "numpy.pxd":798 * * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): # <<<<<<<<<<<<<< @@ -8153,23 +8571,23 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } if (__pyx_t_6) { - /* "numpy.pxd":802 + /* "numpy.pxd":799 * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "numpy.pxd":812 + /* "numpy.pxd":809 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -8177,16 +8595,16 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 */ while (1) { - __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_6) break; - /* "numpy.pxd":813 + /* "numpy.pxd":810 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -8195,7 +8613,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 120; - /* "numpy.pxd":814 + /* "numpy.pxd":811 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -8204,7 +8622,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "numpy.pxd":815 + /* "numpy.pxd":812 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -8215,7 +8633,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + 1); } - /* "numpy.pxd":817 + /* "numpy.pxd":814 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -8225,7 +8643,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_10 = 0; (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + __pyx_v_child->elsize); - /* "numpy.pxd":819 + /* "numpy.pxd":816 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -8235,20 +8653,20 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (!PyDataType_HASFIELDS(__pyx_v_child)); if (__pyx_t_6) { - /* "numpy.pxd":820 + /* "numpy.pxd":817 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ - __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_v_t); __pyx_v_t = __pyx_t_3; __pyx_t_3 = 0; - /* "numpy.pxd":821 + /* "numpy.pxd":818 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -8258,282 +8676,282 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((__pyx_v_end - __pyx_v_f) < 5); if (__pyx_t_6) { - /* "numpy.pxd":822 + /* "numpy.pxd":819 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L10; } __pyx_L10:; - /* "numpy.pxd":825 + /* "numpy.pxd":822 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ - __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L11; } - /* "numpy.pxd":826 + /* "numpy.pxd":823 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ - __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L11; } - /* "numpy.pxd":827 + /* "numpy.pxd":824 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ - __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 104; goto __pyx_L11; } - /* "numpy.pxd":828 + /* "numpy.pxd":825 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ - __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L11; } - /* "numpy.pxd":829 + /* "numpy.pxd":826 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ - __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 105; goto __pyx_L11; } - /* "numpy.pxd":830 + /* "numpy.pxd":827 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ - __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L11; } - /* "numpy.pxd":831 + /* "numpy.pxd":828 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ - __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 108; goto __pyx_L11; } - /* "numpy.pxd":832 + /* "numpy.pxd":829 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ - __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L11; } - /* "numpy.pxd":833 + /* "numpy.pxd":830 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ - __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 113; goto __pyx_L11; } - /* "numpy.pxd":834 + /* "numpy.pxd":831 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ - __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L11; } - /* "numpy.pxd":835 + /* "numpy.pxd":832 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ - __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 102; goto __pyx_L11; } - /* "numpy.pxd":836 + /* "numpy.pxd":833 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ - __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 100; goto __pyx_L11; } - /* "numpy.pxd":837 + /* "numpy.pxd":834 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ - __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 103; goto __pyx_L11; } - /* "numpy.pxd":838 + /* "numpy.pxd":835 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ - __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -8542,19 +8960,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L11; } - /* "numpy.pxd":839 + /* "numpy.pxd":836 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ - __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -8563,19 +8981,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L11; } - /* "numpy.pxd":840 + /* "numpy.pxd":837 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ - __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -8584,19 +9002,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L11; } - /* "numpy.pxd":841 + /* "numpy.pxd":838 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; @@ -8604,30 +9022,30 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } /*else*/ { - /* "numpy.pxd":843 + /* "numpy.pxd":840 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L11:; - /* "numpy.pxd":844 + /* "numpy.pxd":841 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -8639,21 +9057,21 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } /*else*/ { - /* "numpy.pxd":848 + /* "numpy.pxd":845 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ - __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_11; } __pyx_L9:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "numpy.pxd":849 + /* "numpy.pxd":846 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -8682,7 +9100,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "numpy.pxd":964 +/* "numpy.pxd":961 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -8694,9 +9112,9 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("set_array_base", 0); + __Pyx_RefNannySetupContext("set_array_base"); - /* "numpy.pxd":966 + /* "numpy.pxd":963 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -8706,7 +9124,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __pyx_t_1 = (__pyx_v_base == Py_None); if (__pyx_t_1) { - /* "numpy.pxd":967 + /* "numpy.pxd":964 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< @@ -8718,7 +9136,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } /*else*/ { - /* "numpy.pxd":969 + /* "numpy.pxd":966 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< @@ -8727,7 +9145,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "numpy.pxd":970 + /* "numpy.pxd":967 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< @@ -8738,7 +9156,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } __pyx_L3:; - /* "numpy.pxd":971 + /* "numpy.pxd":968 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< @@ -8747,7 +9165,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_XDECREF(__pyx_v_arr->base); - /* "numpy.pxd":972 + /* "numpy.pxd":969 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< @@ -8759,7 +9177,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "numpy.pxd":974 +/* "numpy.pxd":971 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -8771,9 +9189,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); + __Pyx_RefNannySetupContext("get_array_base"); - /* "numpy.pxd":975 + /* "numpy.pxd":972 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -8783,7 +9201,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = (__pyx_v_arr->base == NULL); if (__pyx_t_1) { - /* "numpy.pxd":976 + /* "numpy.pxd":973 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< @@ -8798,7 +9216,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py } /*else*/ { - /* "numpy.pxd":978 + /* "numpy.pxd":975 * return None * else: * return arr.base # <<<<<<<<<<<<<< @@ -8832,7 +9250,7 @@ static void __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion(PyObject *o) { } static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_Criterion[] = { - {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_9Criterion_init_value)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_7sklearn_4tree_5_tree_9Criterion_init_value)}, {0, 0, 0, 0} }; @@ -9048,7 +9466,7 @@ static int __pyx_tp_clear_7sklearn_4tree_5_tree_ClassificationCriterion(PyObject } static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_ClassificationCriterion[] = { - {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_1init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -9190,7 +9608,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__, /*tp_init*/ + __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_new*/ 0, /*tp_free*/ @@ -9553,7 +9971,7 @@ static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_RegressionCriterion(PyTypeOb } static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_RegressionCriterion[] = { - {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_1init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -9695,7 +10113,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__, /*tp_init*/ + __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_new*/ 0, /*tp_free*/ @@ -9712,20 +10130,190 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion = { }; static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE __pyx_vtable_7sklearn_4tree_5_tree_MSE; -static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_MSE(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_7sklearn_4tree_5_tree_MSE *p; +static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_MSE(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_4tree_5_tree_MSE *p; + PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_Criterion(t, a, k); + if (!o) return 0; + p = ((struct __pyx_obj_7sklearn_4tree_5_tree_MSE *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_MSE; + return o; +} + +static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_MSE[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_MSE = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_divide*/ + #endif + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_coerce*/ + #endif + 0, /*nb_int*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_long*/ + #else + 0, /*reserved*/ + #endif + 0, /*nb_float*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_oct*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*nb_hex*/ + #endif + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_inplace_divide*/ + #endif + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ + #if PY_VERSION_HEX >= 0x02050000 + 0, /*nb_index*/ + #endif +}; + +static PySequenceMethods __pyx_tp_as_sequence_MSE = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_MSE = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_MSE = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_getbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_releasebuffer*/ + #endif +}; + +static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("sklearn.tree._tree.MSE"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_MSE), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + &__pyx_tp_as_number_MSE, /*tp_as_number*/ + &__pyx_tp_as_sequence_MSE, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_MSE, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_MSE, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + __Pyx_DOCSTR("Mean squared error impurity criterion.\n\n MSE = var_left + var_right\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7sklearn_4tree_5_tree_MSE, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7sklearn_4tree_5_tree_MSE, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MultiOuputCriterion __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion; + +static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_MultiOuputCriterion(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *p; PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_Criterion(t, a, k); if (!o) return 0; - p = ((struct __pyx_obj_7sklearn_4tree_5_tree_MSE *)o); - p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_MSE; + p = ((struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_MultiOuputCriterion; return o; } -static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_MSE[] = { +static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_MultiOuputCriterion[] = { + {__Pyx_NAMESTR("add_criterion"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_1add_criterion, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion_2init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_MSE = { +static PyNumberMethods __pyx_tp_as_number_MultiOuputCriterion = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -9783,7 +10371,7 @@ static PyNumberMethods __pyx_tp_as_number_MSE = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_MSE = { +static PySequenceMethods __pyx_tp_as_sequence_MultiOuputCriterion = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -9796,13 +10384,13 @@ static PySequenceMethods __pyx_tp_as_sequence_MSE = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_MSE = { +static PyMappingMethods __pyx_tp_as_mapping_MultiOuputCriterion = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_MSE = { +static PyBufferProcs __pyx_tp_as_buffer_MultiOuputCriterion = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -9823,10 +10411,10 @@ static PyBufferProcs __pyx_tp_as_buffer_MSE = { #endif }; -static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { +static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("sklearn.tree._tree.MSE"), /*tp_name*/ - sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_MSE), /*tp_basicsize*/ + __Pyx_NAMESTR("sklearn.tree._tree.MultiOuputCriterion"), /*tp_name*/ + sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_MultiOuputCriterion), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ @@ -9838,24 +10426,24 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_MSE, /*tp_as_number*/ - &__pyx_tp_as_sequence_MSE, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_MSE, /*tp_as_mapping*/ + &__pyx_tp_as_number_MultiOuputCriterion, /*tp_as_number*/ + &__pyx_tp_as_sequence_MultiOuputCriterion, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_MultiOuputCriterion, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_MSE, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_MultiOuputCriterion, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - __Pyx_DOCSTR("Mean squared error impurity criterion.\n\n MSE = var_left + var_right\n "), /*tp_doc*/ + 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_7sklearn_4tree_5_tree_MSE, /*tp_methods*/ + __pyx_methods_7sklearn_4tree_5_tree_MultiOuputCriterion, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -9863,9 +10451,9 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pf_7sklearn_4tree_5_tree_19MultiOuputCriterion___init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_7sklearn_4tree_5_tree_MSE, /*tp_new*/ + __pyx_tp_new_7sklearn_4tree_5_tree_MultiOuputCriterion, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -9900,28 +10488,18 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 1, 0, 0}, {&__pyx_kp_u_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 1, 0, 0}, - {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0}, - {&__pyx_n_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 1}, - {&__pyx_n_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 1}, - {&__pyx_n_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 1}, - {&__pyx_n_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 1}, + {&__pyx_n_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 1}, + {&__pyx_n_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 1}, {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0}, {&__pyx_kp_u_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 1, 0, 0}, {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0}, {&__pyx_kp_u_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 1, 0, 0}, {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1}, {&__pyx_n_s__DTYPE, __pyx_k__DTYPE, sizeof(__pyx_k__DTYPE), 0, 0, 1, 1}, - {&__pyx_n_s__K, __pyx_k__K, sizeof(__pyx_k__K), 0, 0, 1, 1}, {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1}, {&__pyx_n_s__X_argsorted, __pyx_k__X_argsorted, sizeof(__pyx_k__X_argsorted), 0, 0, 1, 1}, - {&__pyx_n_s__X_argsorted_i, __pyx_k__X_argsorted_i, sizeof(__pyx_k__X_argsorted_i), 0, 0, 1, 1}, - {&__pyx_n_s__X_argsorted_stride, __pyx_k__X_argsorted_stride, sizeof(__pyx_k__X_argsorted_stride), 0, 0, 1, 1}, - {&__pyx_n_s__X_col_stride, __pyx_k__X_col_stride, sizeof(__pyx_k__X_col_stride), 0, 0, 1, 1}, - {&__pyx_n_s__X_elem_stride, __pyx_k__X_elem_stride, sizeof(__pyx_k__X_elem_stride), 0, 0, 1, 1}, - {&__pyx_n_s__X_i, __pyx_k__X_i, sizeof(__pyx_k__X_i), 0, 0, 1, 1}, - {&__pyx_n_s__X_stride, __pyx_k__X_stride, sizeof(__pyx_k__X_stride), 0, 0, 1, 1}, {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, {&__pyx_n_s___apply_tree, __pyx_k___apply_tree, sizeof(__pyx_k___apply_tree), 0, 0, 1, 1}, @@ -9929,42 +10507,27 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s___find_best_split, __pyx_k___find_best_split, sizeof(__pyx_k___find_best_split), 0, 0, 1, 1}, {&__pyx_n_s___predict_tree, __pyx_k___predict_tree, sizeof(__pyx_k___predict_tree), 0, 0, 1, 1}, {&__pyx_n_s___random_sample_mask, __pyx_k___random_sample_mask, sizeof(__pyx_k___random_sample_mask), 0, 0, 1, 1}, - {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1}, {&__pyx_n_s__arange, __pyx_k__arange, sizeof(__pyx_k__arange), 0, 0, 1, 1}, {&__pyx_n_s__asarray, __pyx_k__asarray, sizeof(__pyx_k__asarray), 0, 0, 1, 1}, {&__pyx_n_s__astype, __pyx_k__astype, sizeof(__pyx_k__astype), 0, 0, 1, 1}, - {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1}, - {&__pyx_n_s__best_error, __pyx_k__best_error, sizeof(__pyx_k__best_error), 0, 0, 1, 1}, - {&__pyx_n_s__best_i, __pyx_k__best_i, sizeof(__pyx_k__best_i), 0, 0, 1, 1}, - {&__pyx_n_s__best_t, __pyx_k__best_t, sizeof(__pyx_k__best_t), 0, 0, 1, 1}, {&__pyx_n_s__bool, __pyx_k__bool, sizeof(__pyx_k__bool), 0, 0, 1, 1}, - {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1}, {&__pyx_n_s__children, __pyx_k__children, sizeof(__pyx_k__children), 0, 0, 1, 1}, + {&__pyx_n_s__criteria, __pyx_k__criteria, sizeof(__pyx_k__criteria), 0, 0, 1, 1}, {&__pyx_n_s__criterion, __pyx_k__criterion, sizeof(__pyx_k__criterion), 0, 0, 1, 1}, {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1}, - {&__pyx_n_s__error, __pyx_k__error, sizeof(__pyx_k__error), 0, 0, 1, 1}, {&__pyx_n_s__feature, __pyx_k__feature, sizeof(__pyx_k__feature), 0, 0, 1, 1}, - {&__pyx_n_s__feature_idx, __pyx_k__feature_idx, sizeof(__pyx_k__feature_idx), 0, 0, 1, 1}, - {&__pyx_n_s__features, __pyx_k__features, sizeof(__pyx_k__features), 0, 0, 1, 1}, {&__pyx_n_s__float32, __pyx_k__float32, sizeof(__pyx_k__float32), 0, 0, 1, 1}, - {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1}, + {&__pyx_n_s__hstack, __pyx_k__hstack, sizeof(__pyx_k__hstack), 0, 0, 1, 1}, {&__pyx_n_s__inf, __pyx_k__inf, sizeof(__pyx_k__inf), 0, 0, 1, 1}, {&__pyx_n_s__init_value, __pyx_k__init_value, sizeof(__pyx_k__init_value), 0, 0, 1, 1}, - {&__pyx_n_s__initial_error, __pyx_k__initial_error, sizeof(__pyx_k__initial_error), 0, 0, 1, 1}, {&__pyx_n_s__int32, __pyx_k__int32, sizeof(__pyx_k__int32), 0, 0, 1, 1}, {&__pyx_n_s__int8, __pyx_k__int8, sizeof(__pyx_k__int8), 0, 0, 1, 1}, - {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1}, {&__pyx_n_s__max_features, __pyx_k__max_features, sizeof(__pyx_k__max_features), 0, 0, 1, 1}, {&__pyx_n_s__min_leaf, __pyx_k__min_leaf, sizeof(__pyx_k__min_leaf), 0, 0, 1, 1}, - {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1}, - {&__pyx_n_s__n_bagged, __pyx_k__n_bagged, sizeof(__pyx_k__n_bagged), 0, 0, 1, 1}, {&__pyx_n_s__n_classes, __pyx_k__n_classes, sizeof(__pyx_k__n_classes), 0, 0, 1, 1}, - {&__pyx_n_s__n_features, __pyx_k__n_features, sizeof(__pyx_k__n_features), 0, 0, 1, 1}, - {&__pyx_n_s__n_left, __pyx_k__n_left, sizeof(__pyx_k__n_left), 0, 0, 1, 1}, {&__pyx_n_s__n_samples, __pyx_k__n_samples, sizeof(__pyx_k__n_samples), 0, 0, 1, 1}, {&__pyx_n_s__n_total_in_bag, __pyx_k__n_total_in_bag, sizeof(__pyx_k__n_total_in_bag), 0, 0, 1, 1}, {&__pyx_n_s__n_total_samples, __pyx_k__n_total_samples, sizeof(__pyx_k__n_total_samples), 0, 0, 1, 1}, - {&__pyx_n_s__node_id, __pyx_k__node_id, sizeof(__pyx_k__node_id), 0, 0, 1, 1}, {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1}, @@ -9975,25 +10538,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__random_state, __pyx_k__random_state, sizeof(__pyx_k__random_state), 0, 0, 1, 1}, {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, {&__pyx_n_s__sample_mask, __pyx_k__sample_mask, sizeof(__pyx_k__sample_mask), 0, 0, 1, 1}, - {&__pyx_n_s__sample_mask_ptr, __pyx_k__sample_mask_ptr, sizeof(__pyx_k__sample_mask_ptr), 0, 0, 1, 1}, - {&__pyx_n_s__t, __pyx_k__t, sizeof(__pyx_k__t), 0, 0, 1, 1}, {&__pyx_n_s__threshold, __pyx_k__threshold, sizeof(__pyx_k__threshold), 0, 0, 1, 1}, {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1}, {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1}, {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, - {&__pyx_n_s__y_ptr, __pyx_k__y_ptr, sizeof(__pyx_k__y_ptr), 0, 0, 1, 1}, {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION >= 3 - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -10001,463 +10561,91 @@ static int __Pyx_InitCachedBuiltins(void) { static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants"); - /* "numpy.pxd":214 + /* "numpy.pxd":211 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_2); + __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_1)); PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_u_1)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_1)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); - /* "numpy.pxd":218 + /* "numpy.pxd":215 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_4); + __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_3)); PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_u_3)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_3)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); - /* "numpy.pxd":256 + /* "numpy.pxd":253 * if ((descr.byteorder == '>' and little_endian) or * (descr.byteorder == '<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_6); + __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_5)); PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_u_5)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_5)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "numpy.pxd":798 + /* "numpy.pxd":795 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == '>' and little_endian) or */ - __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_9); + __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_8)); PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_u_8)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_8)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9)); - /* "numpy.pxd":802 + /* "numpy.pxd":799 * if ((child.byteorder == '>' and little_endian) or * (child.byteorder == '<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_10); + __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_5)); PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_u_5)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_5)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); - /* "numpy.pxd":822 + /* "numpy.pxd":819 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_12); + __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_12)); __Pyx_INCREF(((PyObject *)__pyx_kp_u_11)); PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_u_11)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_11)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); - - /* "sklearn/tree/_tree.pyx":409 - * - * - * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< - * """Create a random sample mask where ``n_total_in_bag`` elements are set. - * - */ - __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_13); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_in_bag)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 1, ((PyObject *)__pyx_n_s__n_total_in_bag)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_in_bag)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 2, ((PyObject *)__pyx_n_s__random_state)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__rand)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 3, ((PyObject *)__pyx_n_s__rand)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rand)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 4, ((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_bagged)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 5, ((PyObject *)__pyx_n_s__n_bagged)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_bagged)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 6, ((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); - __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 409, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "sklearn/tree/_tree.pyx":442 - * - * - * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< - * np.ndarray[np.int32_t, ndim=2] children, - * np.ndarray[np.int32_t, ndim=1] feature, - */ - __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_17); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__X)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__children)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 1, ((PyObject *)__pyx_n_s__children)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__children)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__feature)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 2, ((PyObject *)__pyx_n_s__feature)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__threshold)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 3, ((PyObject *)__pyx_n_s__threshold)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__threshold)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__out)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 4, ((PyObject *)__pyx_n_s__out)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__out)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 5, ((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 6, ((PyObject *)__pyx_n_s__n)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__node_id)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 7, ((PyObject *)__pyx_n_s__node_id)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); - __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 442, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "sklearn/tree/_tree.pyx":463 - * - * - * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< - * np.ndarray[np.int32_t, ndim=2] children, - * np.ndarray[np.int32_t, ndim=1] feature, - */ - __pyx_k_tuple_19 = PyTuple_New(11); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_19); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_n_s__X)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__children)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 1, ((PyObject *)__pyx_n_s__children)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__children)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__feature)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 2, ((PyObject *)__pyx_n_s__feature)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__threshold)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 3, ((PyObject *)__pyx_n_s__threshold)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__threshold)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__values)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 4, ((PyObject *)__pyx_n_s__values)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__values)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__pred)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 5, ((PyObject *)__pyx_n_s__pred)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pred)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 6, ((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 7, ((PyObject *)__pyx_n_s__n)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__node_id)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 8, ((PyObject *)__pyx_n_s__node_id)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__K)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 9, ((PyObject *)__pyx_n_s__K)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__K)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__k)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 10, ((PyObject *)__pyx_n_s__k)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 463, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "sklearn/tree/_tree.pyx":486 - * - * - * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< - * np.ndarray sample_mask, Criterion criterion, - * int n_samples): - */ - __pyx_k_tuple_21 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_21); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__y)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 1, ((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 2, ((PyObject *)__pyx_n_s__criterion)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 3, ((PyObject *)__pyx_n_s__n_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 4, ((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 5, ((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 6, ((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 486, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "sklearn/tree/_tree.pyx":533 - * - * - * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, - * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, - */ - __pyx_k_tuple_25 = PyTuple_New(33); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_25); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__X)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 1, ((PyObject *)__pyx_n_s__y)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 2, ((PyObject *)__pyx_n_s__X_argsorted)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 3, ((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 4, ((PyObject *)__pyx_n_s__n_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__min_leaf)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 5, ((PyObject *)__pyx_n_s__min_leaf)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__min_leaf)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__max_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 6, ((PyObject *)__pyx_n_s__max_features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 7, ((PyObject *)__pyx_n_s__criterion)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 8, ((PyObject *)__pyx_n_s__random_state)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 9, ((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 10, ((PyObject *)__pyx_n_s__n_features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 11, ((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__a)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 12, ((PyObject *)__pyx_n_s__a)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__b)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 13, ((PyObject *)__pyx_n_s__b)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 14, ((PyObject *)__pyx_n_s__best_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__feature_idx)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 15, ((PyObject *)__pyx_n_s__feature_idx)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature_idx)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_left)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 16, ((PyObject *)__pyx_n_s__n_left)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_left)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 17, ((PyObject *)__pyx_n_s__t)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__initial_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 18, ((PyObject *)__pyx_n_s__initial_error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__initial_error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__error)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 19, ((PyObject *)__pyx_n_s__error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 20, ((PyObject *)__pyx_n_s__best_error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_t)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 21, ((PyObject *)__pyx_n_s__best_t)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 22, ((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 23, ((PyObject *)__pyx_n_s__X_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 24, ((PyObject *)__pyx_n_s__X_argsorted_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 25, ((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__features)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 26, ((PyObject *)__pyx_n_s__features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_elem_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 27, ((PyObject *)__pyx_n_s__X_elem_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_elem_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_col_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 28, ((PyObject *)__pyx_n_s__X_col_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_col_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 29, ((PyObject *)__pyx_n_s__X_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_23)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 30, ((PyObject *)__pyx_n_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_23)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 31, ((PyObject *)__pyx_n_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_24)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 32, ((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); - __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 533, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "sklearn/tree/_tree.pyx":678 - * return best_i, best_t, best_error, initial_error - * - * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, - * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, - */ - __pyx_k_tuple_27 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_27); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__X)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 1, ((PyObject *)__pyx_n_s__y)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 2, ((PyObject *)__pyx_n_s__X_argsorted)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 3, ((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 4, ((PyObject *)__pyx_n_s__n_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__min_leaf)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 5, ((PyObject *)__pyx_n_s__min_leaf)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__min_leaf)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__max_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 6, ((PyObject *)__pyx_n_s__max_features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 7, ((PyObject *)__pyx_n_s__criterion)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 8, ((PyObject *)__pyx_n_s__random_state)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 9, ((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 10, ((PyObject *)__pyx_n_s__n_features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 11, ((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__a)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 12, ((PyObject *)__pyx_n_s__a)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__b)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 13, ((PyObject *)__pyx_n_s__b)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__c)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 14, ((PyObject *)__pyx_n_s__c)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_left)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 15, ((PyObject *)__pyx_n_s__n_left)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_left)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 16, ((PyObject *)__pyx_n_s__best_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__feature_idx)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 17, ((PyObject *)__pyx_n_s__feature_idx)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature_idx)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 18, ((PyObject *)__pyx_n_s__t)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__initial_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 19, ((PyObject *)__pyx_n_s__initial_error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__initial_error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__error)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 20, ((PyObject *)__pyx_n_s__error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 21, ((PyObject *)__pyx_n_s__best_error)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_error)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__best_t)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 22, ((PyObject *)__pyx_n_s__best_t)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 23, ((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 24, ((PyObject *)__pyx_n_s__X_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 25, ((PyObject *)__pyx_n_s__X_argsorted_i)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 26, ((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__features)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 27, ((PyObject *)__pyx_n_s__features)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__features)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_elem_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 28, ((PyObject *)__pyx_n_s__X_elem_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_elem_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_col_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 29, ((PyObject *)__pyx_n_s__X_col_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_col_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 30, ((PyObject *)__pyx_n_s__X_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_stride)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_23)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 31, ((PyObject *)__pyx_n_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_23)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 32, ((PyObject *)__pyx_n_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_24)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 33, ((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); - __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 678, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -10493,18 +10681,12 @@ PyMODINIT_FUNC PyInit__tree(void) Py_FatalError("failed to import 'refnanny' module"); } #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__tree(void)", 0); + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__tree(void)"); if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #ifdef __Pyx_CyFunction_USED - if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __pyx_binding_PyCFunctionType_USED + if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ @@ -10597,12 +10779,24 @@ PyMODINIT_FUNC PyInit__tree(void) if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_MSE = &__pyx_type_7sklearn_4tree_5_tree_MSE; + __pyx_vtabptr_7sklearn_4tree_5_tree_MultiOuputCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_init; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base.reset = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_reset; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_update; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_eval; + __pyx_vtable_7sklearn_4tree_5_tree_MultiOuputCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_19MultiOuputCriterion_init_value; + __pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MultiOuputCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "MultiOuputCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_7sklearn_4tree_5_tree_MultiOuputCriterion = &__pyx_type_7sklearn_4tree_5_tree_MultiOuputCriterion; /*--- Type import code ---*/ - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ @@ -10634,76 +10828,76 @@ PyMODINIT_FUNC PyInit__tree(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":409 + /* "sklearn/tree/_tree.pyx":463 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree__random_sample_mask, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":442 + /* "sklearn/tree/_tree.pyx":496 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_apply_tree, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":463 + /* "sklearn/tree/_tree.pyx":517 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_2_predict_tree, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":486 + /* "sklearn/tree/_tree.pyx":540 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< * np.ndarray sample_mask, Criterion criterion, * int n_samples): */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_error_at_leaf, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":533 + /* "sklearn/tree/_tree.pyx":587 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_4_find_best_split, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":678 + /* "sklearn/tree/_tree.pyx":732 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=1, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_find_best_random_split, NULL, __pyx_n_s_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_14, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "sklearn/tree/_tree.pyx":1 @@ -10716,7 +10910,7 @@ PyMODINIT_FUNC PyInit__tree(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - /* "numpy.pxd":974 + /* "numpy.pxd":971 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -10743,6 +10937,7 @@ PyMODINIT_FUNC PyInit__tree(void) } /* Runtime support code */ + #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; @@ -10811,6 +11006,7 @@ static int __Pyx_ParseOptionalKeywords( Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; @@ -10820,7 +11016,7 @@ static int __Pyx_ParseOptionalKeywords( #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { #else - if (unlikely(!PyUnicode_Check(key))) { + if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { #endif goto invalid_keyword_type; } else { @@ -10836,6 +11032,7 @@ static int __Pyx_ParseOptionalKeywords( if (*name) { values[name-argnames] = value; } else { + /* unexpected keyword found */ for (name=argnames; name != first_kw_arg; name++) { if (**name == key) goto arg_passed_twice; #if PY_MAJOR_VERSION >= 3 @@ -10885,6 +11082,7 @@ static void __Pyx_RaiseArgtupleInvalid( { Py_ssize_t num_expected; const char *more_or_less; + if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; @@ -10905,6 +11103,18 @@ static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; } + +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; +} __Pyx_BufFmt_Context; + static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type) { @@ -10923,8 +11133,6 @@ static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, ctx->enc_count = 0; ctx->enc_type = 0; ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; while (type->typegroup == 'S') { ++ctx->head; ctx->head->field = type->fields; @@ -10932,6 +11140,7 @@ static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, type = type->fields->type; } } + static int __Pyx_BufFmt_ParseNumber(const char** ts) { int count; const char* t = *ts; @@ -10947,17 +11156,12 @@ static int __Pyx_BufFmt_ParseNumber(const char** ts) { *ts = t; return count; } -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) /* First char was not a digit */ - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} + static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%c'", ch); } + static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { switch (ch) { case 'b': return "'char'"; @@ -10976,14 +11180,14 @@ static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { case 'T': return "a struct"; case 'O': return "Python object"; case 'P': return "a pointer"; - case 's': case 'p': return "a string"; case 0: return "end"; default: return "unparseable format string"; } } + static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case '?': case 'c': case 'b': case 'B': return 1; case 'h': case 'H': return 2; case 'i': case 'I': case 'l': case 'L': return 4; case 'q': case 'Q': return 8; @@ -10999,9 +11203,10 @@ static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { return 0; } } + static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { switch (ch) { - case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'c': case 'b': case 'B': return 1; case 'h': case 'H': return sizeof(short); case 'i': case 'I': return sizeof(int); case 'l': case 'L': return sizeof(long); @@ -11018,6 +11223,7 @@ static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { } } } + typedef struct { char c; short x; } __Pyx_st_short; typedef struct { char c; int x; } __Pyx_st_int; typedef struct { char c; long x; } __Pyx_st_long; @@ -11028,9 +11234,10 @@ typedef struct { char c; void *x; } __Pyx_st_void_p; #ifdef HAVE_LONG_LONG typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif + static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) { switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case '?': case 'c': case 'b': case 'B': return 1; case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); @@ -11046,57 +11253,21 @@ static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) { return 0; } } -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} + static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { switch (ch) { - case 'c': case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; + case 'c': case 'b': case 'h': case 'i': case 'l': case 'q': return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U'; + case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R'); + case 'O': return 'O'; + case 'P': return 'P'; default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } + static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { if (ctx->head == NULL || ctx->head->field == &ctx->root) { const char* expected; @@ -11121,37 +11292,16 @@ static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { parent->type->name, field->name); } } + static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { char group; - size_t size, offset, arraysize = 1; + size_t size, offset; if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); do { __Pyx_StructField* field = ctx->head->field; __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { @@ -11163,21 +11313,22 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { if (align_at == 0) return -1; align_mod_offset = ctx->fmt_offset % align_at; if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); } + if (type->size != size || type->typegroup != group) { if (type->typegroup == 'C' && type->fields != NULL) { + /* special case -- treat as struct rather than complex number */ size_t parent_offset = ctx->head->parent_offset + field->offset; ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = parent_offset; continue; } + __Pyx_BufFmt_RaiseExpected(ctx); return -1; } + offset = ctx->head->parent_offset + field->offset; if (ctx->fmt_offset != offset) { PyErr_Format(PyExc_ValueError, @@ -11185,10 +11336,12 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); return -1; } + ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; /* Consume from buffer string */ + + /* Done checking, move to next field, pushing or popping struct stack if needed */ while (1) { if (field == &ctx->root) { ctx->head = NULL; @@ -11220,48 +11373,7 @@ static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { ctx->is_complex = 0; return 0; } -static CYTHON_INLINE PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number; - int ndim = ctx->head->field->type->ndim; -; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - while (*ts && *ts != ')') { - if (isspace(*ts)) - continue; - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} + static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; while (1) { @@ -11276,7 +11388,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } - return ts; + return ts; case ' ': case 10: case 13: @@ -11308,17 +11420,12 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha { const char* ts_after_sub; size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; ctx->new_count = 1; ++ts; if (*ts != '{') { PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); return NULL; } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; /* Erase processed last struct element */ - ctx->enc_count = 0; - ctx->struct_alignment = 0; ++ts; ts_after_sub = ts; for (i = 0; i != struct_count; ++i) { @@ -11326,19 +11433,10 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha if (!ts_after_sub) return NULL; } ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; } break; case '}': /* end of substruct; either repeat or move on */ - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; /* Erase processed last struct element */ - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } + ++ts; return ts; case 'x': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; @@ -11359,11 +11457,13 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': - case 'O': case 's': case 'p': + case 'O': if (ctx->enc_type == *ts && got_Z == ctx->is_complex && ctx->enc_packmode == ctx->new_packmode) { + /* Continue pooling same type */ ctx->enc_count += ctx->new_count; } else { + /* New type */ if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; ctx->enc_packmode = ctx->new_packmode; @@ -11379,18 +11479,20 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha while(*ts != ':') ++ts; ++ts; break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; default: { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; + int number = __Pyx_BufFmt_ParseNumber(&ts); + if (number == -1) { /* First char was not a digit */ + PyErr_Format(PyExc_ValueError, + "Does not understand character buffer dtype format string ('%c')", *ts); + return NULL; + } + ctx->new_count = (size_t)number; } } } } + static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; @@ -11398,10 +11500,8 @@ static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } -static CYTHON_INLINE int __Pyx_GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None || obj == NULL) { __Pyx_ZeroBuffer(buf); return 0; @@ -11432,6 +11532,7 @@ fail:; __Pyx_ZeroBuffer(buf); return -1; } + static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; @@ -11439,9 +11540,9 @@ static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; @@ -11451,24 +11552,20 @@ static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyOb Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); -#else - PyErr_Restore(type, value, tb); -#endif } + static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; -#else - PyErr_Fetch(type, value, tb); -#endif } + static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, @@ -11480,7 +11577,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #else - if (unlikely(!PyUnicode_Check(key))) + if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) #endif goto invalid_keyword_type; } @@ -11528,12 +11625,14 @@ static void __Pyx_RaiseBufferFallbackError(void) { "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); } + #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + /* cause is unused */ Py_XINCREF(type); Py_XINCREF(value); Py_XINCREF(tb); + /* First, check the traceback argument, replacing None with NULL. */ if (tb == Py_None) { Py_DECREF(tb); tb = 0; @@ -11543,6 +11642,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, "raise: arg 3 must be a traceback or None"); goto raise_error; } + /* Next, replace a missing value with None */ if (value == NULL) { value = Py_None; Py_INCREF(value); @@ -11553,11 +11653,13 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, if (!PyType_Check(type)) #endif { + /* Raising an instance. The value should be a dummy. */ if (value != Py_None) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } + /* Normalize to raise , */ Py_DECREF(value); value = type; #if PY_VERSION_HEX < 0x02050000 @@ -11581,6 +11683,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, } #endif } + __Pyx_ErrRestore(type, value, tb); return; raise_error: @@ -11589,7 +11692,9 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, Py_XDECREF(tb); return; } + #else /* Python 3+ */ + static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { if (tb == Py_None) { tb = 0; @@ -11600,6 +11705,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } if (value == Py_None) value = 0; + if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, @@ -11613,6 +11719,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } + if (cause) { PyObject *fixed_cause; if (PyExceptionClass_Check(cause)) { @@ -11635,7 +11742,9 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } PyException_SetCause(value, fixed_cause); } + PyErr_SetObject(type, value); + if (tb) { PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; @@ -11645,6 +11754,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject Py_XDECREF(tmp_tb); } } + bad: return; } @@ -11677,98 +11787,31 @@ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { #if PY_MAJOR_VERSION < 3 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - PyObject *getbuffer_cobj; - #if PY_VERSION_HEX >= 0x02060000 - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); #endif - - if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); - - #if PY_VERSION_HEX < 0x02060000 - if (obj->ob_type->tp_dict && - (getbuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict, - "__pyx_getbuffer"))) { - getbufferproc func; - - #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) - func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)"); - #else - func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj); - #endif - Py_DECREF(getbuffer_cobj); - if (!func) - goto fail; - - return func(obj, view, flags); - } else { - PyErr_Clear(); + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags); + else { + PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; } - #endif - - PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - -#if PY_VERSION_HEX < 0x02060000 -fail: -#endif - - return -1; } static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - PyObject *releasebuffer_cobj; - - if (!obj) return; - - #if PY_VERSION_HEX >= 0x02060000 - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - #endif - - if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } - - #if PY_VERSION_HEX < 0x02060000 - if (obj->ob_type->tp_dict && - (releasebuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict, - "__pyx_releasebuffer"))) { - releasebufferproc func; - - #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0) - func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)"); - #else - func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj); - #endif - - Py_DECREF(releasebuffer_cobj); - - if (!func) - goto fail; - - func(obj, view); - return; - } else { - PyErr_Clear(); - } - #endif - - goto nofail; - -#if PY_VERSION_HEX < 0x02060000 -fail: -#endif - PyErr_WriteUnraisable(obj); - -nofail: + PyObject* obj = view->obj; + if (obj) { + #if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(obj)) {PyBuffer_Release(view); return;} + #endif + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pf_5numpy_7ndarray_1__releasebuffer__(obj, view); Py_DECREF(obj); view->obj = NULL; + } } -#endif /* PY_MAJOR_VERSION < 3 */ +#endif - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { PyObject *py_import = 0; PyObject *empty_list = 0; PyObject *module = 0; @@ -11794,33 +11837,12 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { goto bad; #if PY_VERSION_HEX >= 0x02050000 { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - /* try package relative import first */ - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; /* try absolute import on failure */ - } - #endif - if (!module) { - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - } + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); } #else if (level>0) { @@ -12477,6 +12499,25 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); @@ -12522,10 +12563,15 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class PyObject *result = 0; PyObject *py_name = 0; char warning[200]; + py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; - py_name = __Pyx_PyIdentifier_FromString(class_name); + #if PY_MAJOR_VERSION < 3 + py_name = PyString_FromString(class_name); + #else + py_name = PyUnicode_FromString(class_name); + #endif if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); @@ -12541,7 +12587,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class module_name, class_name); goto bad; } - if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) { + if (!strict && ((PyTypeObject *)result)->tp_basicsize > (Py_ssize_t)size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility", module_name, class_name); @@ -12551,7 +12597,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; #endif } - else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) { + else if (((PyTypeObject *)result)->tp_basicsize != (Py_ssize_t)size) { PyErr_Format(PyExc_ValueError, "%s.%s has the wrong size, try recompiling", module_name, class_name); @@ -12570,7 +12616,12 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; - py_name = __Pyx_PyIdentifier_FromString(name); + + #if PY_MAJOR_VERSION < 3 + py_name = PyString_FromString(name); + #else + py_name = PyUnicode_FromString(name); + #endif if (!py_name) goto bad; py_module = PyImport_Import(py_name); @@ -12582,105 +12633,29 @@ static PyObject *__Pyx_ImportModule(const char *name) { } #endif -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = (start + end) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - #include "compile.h" #include "frameobject.h" #include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; + +static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, + int __pyx_lineno, const char *__pyx_filename) { PyObject *py_srcfile = 0; PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); + py_srcfile = PyString_FromString(__pyx_filename); #else - py_srcfile = PyUnicode_FromString(filename); + py_srcfile = PyUnicode_FromString(__pyx_filename); #endif if (!py_srcfile) goto bad; - if (c_line) { + if (__pyx_clineno) { #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); #endif } else { @@ -12691,45 +12666,28 @@ static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( #endif } if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + py_code = PyCode_New( 0, /*int argcount,*/ + #if PY_MAJOR_VERSION >= 3 0, /*int kwonlyargcount,*/ + #endif 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ - py_line, /*int firstlineno,*/ + __pyx_lineno, /*int firstlineno,*/ __pyx_empty_bytes /*PyObject *lnotab*/ ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_globals = 0; - PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); - } - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; + if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ @@ -12737,9 +12695,11 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; - py_frame->f_lineno = py_line; + py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); Py_XDECREF(py_code); Py_XDECREF(py_frame); } @@ -12774,7 +12734,6 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { return 0; } - /* Type Conversion Functions */ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index c8b1765d84cb4..b718179159aad 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -401,6 +401,60 @@ cdef class MSE(RegressionCriterion): return self.var_left + self.var_right +cdef class MultiOuputCriterion(Criterion): + cdef int n_outputs + cdef int y_stride + + def __init__(self): + self.criteria = [] + + self.n_outputs = 0 + self.y_stride = -1 + + def add_criterion(self, criterion): + self.criteria.append(criterion) + self.n_outputs += 1 + + cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, int n_total_samples): + cdef Criterion criterion + self.y_stride = n_total_samples + + for criterion in self.criteria: + criterion.init(y, sample_mask, n_samples, n_total_samples) + y += self.y_stride + + cdef void reset(self): + cdef Criterion criterion + + for criterion in self.criteria: + criterion.reset() + + cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, BOOL_t *sample_mask): + cdef Criterion criterion + + for criterion in self.criteria: + n_left = criterion.update(a, b, y, X_argsorted_i, sample_mask) + y += self.y_stride + + cdef double eval(self): + cdef Criterion criterion + cdef double value = 0.0 + + for criterion in self.criteria: + value += criterion.eval() + + return value / self.n_outputs + + cpdef np.ndarray init_value(self): + cdef Criterion criterion + values = [] + + for criterion in self.criteria: + values.append(criterion.init_value()) + + return np.hstack(values) + + ################################################################################ # Tree util functions # diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index ecbceaeef2d6b..702cf419eff20 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -471,7 +471,7 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): self.n_classes_ = 1 criterion = REGRESSION[self.criterion]() - y = np.ascontiguousarray(y, dtype=DTYPE) + y = np.asarray(y, dtype=DTYPE) # Check parameters max_depth = np.inf if self.max_depth is None else self.max_depth From eac35cc47fb7bdcdfae7bdcad704fb0e063a7c35 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Thu, 28 Jun 2012 10:09:21 +0200 Subject: [PATCH 02/33] ENH: Multi-output decision trees ENH: MultiOuputTree (wip) ENH: MultiOutputTree (wip) ENH: MultiOutputTree (wip) ENH: MultiOutputTree (wip) ENH: MultiOutputTree (wip) ENH: MultiOutputTree (wip) --- sklearn/tree/_tree.c | 5899 ++++++++++++++++--------------- sklearn/tree/_tree.pyx | 521 +-- sklearn/tree/tests/test_tree.py | 102 +- sklearn/tree/tree.py | 86 +- 4 files changed, 3444 insertions(+), 3164 deletions(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index a8b9fc19b0951..40c2656c1ebcd 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Wed Jun 27 11:14:59 2012 */ +/* Generated by Cython 0.16 on Fri Jun 29 11:44:42 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -621,7 +621,7 @@ typedef __pyx_t_5numpy_float32_t __pyx_t_7sklearn_4tree_5_tree_DTYPE_t; * ctypedef np.float32_t DTYPE_t * ctypedef np.int8_t BOOL_t # <<<<<<<<<<<<<< * - * cdef extern from "math.h": + * cdef extern from "stdlib.h": */ typedef __pyx_t_5numpy_int8_t __pyx_t_7sklearn_4tree_5_tree_BOOL_t; #if CYTHON_CCOMPLEX @@ -689,7 +689,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; */ typedef npy_cdouble __pyx_t_5numpy_complex_t; -/* "sklearn/tree/_tree.pyx":40 +/* "sklearn/tree/_tree.pyx":45 * # be the proportion of class k observations in node m * * cdef class Criterion: # <<<<<<<<<<<<<< @@ -702,7 +702,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Criterion { }; -/* "sklearn/tree/_tree.pyx":72 +/* "sklearn/tree/_tree.pyx":79 * * * cdef class ClassificationCriterion(Criterion): # <<<<<<<<<<<<<< @@ -711,24 +711,20 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Criterion { */ struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion { struct __pyx_obj_7sklearn_4tree_5_tree_Criterion __pyx_base; - int y_stride; int n_outputs; int *n_classes; - int count_stride; int n_samples; + int label_count_stride; int *label_count_left; int *label_count_right; int *label_count_init; int n_left; int n_right; - PyObject *ndarray_label_count_left; - PyObject *ndarray_label_count_right; - PyObject *ndarray_label_count_init; }; -/* "sklearn/tree/_tree.pyx":221 - * +/* "sklearn/tree/_tree.pyx":252 + * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< * """Gini Index splitting criteria. @@ -739,7 +735,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Gini { }; -/* "sklearn/tree/_tree.pyx":265 +/* "sklearn/tree/_tree.pyx":303 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -751,7 +747,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Entropy { }; -/* "sklearn/tree/_tree.pyx":302 +/* "sklearn/tree/_tree.pyx":345 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -760,31 +756,22 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Entropy { */ struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion { struct __pyx_obj_7sklearn_4tree_5_tree_Criterion __pyx_base; - int y_stride; int n_outputs; int n_samples; + double *mean_left; + double *mean_right; + double *mean_init; + double *sq_sum_left; + double *sq_sum_right; + double *sq_sum_init; + double *var_left; + double *var_right; int n_right; int n_left; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *mean_left; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *mean_right; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *mean_init; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *sq_sum_left; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *sq_sum_right; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *sq_sum_init; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *var_left; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *var_right; - PyObject *ndarray_mean_left; - PyObject *ndarray_mean_right; - PyObject *ndarray_mean_init; - PyObject *ndarray_sq_sum_left; - PyObject *ndarray_sq_sum_right; - PyObject *ndarray_sq_sum_init; - PyObject *ndarray_var_left; - PyObject *ndarray_var_right; }; -/* "sklearn/tree/_tree.pyx":491 +/* "sklearn/tree/_tree.pyx":573 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -797,7 +784,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_MSE { -/* "sklearn/tree/_tree.pyx":40 +/* "sklearn/tree/_tree.pyx":45 * # be the proportion of class k observations in node m * * cdef class Criterion: # <<<<<<<<<<<<<< @@ -806,16 +793,16 @@ struct __pyx_obj_7sklearn_4tree_5_tree_MSE { */ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion { - void (*init)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int); + void (*init)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int); void (*reset)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *); - int (*update)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *); + int (*update)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *); double (*eval)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *); PyArrayObject *(*init_value)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; -/* "sklearn/tree/_tree.pyx":302 +/* "sklearn/tree/_tree.pyx":345 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -829,7 +816,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; -/* "sklearn/tree/_tree.pyx":491 +/* "sklearn/tree/_tree.pyx":573 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -843,7 +830,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE *__pyx_vtabptr_7sklearn_4tree_5_tree_MSE; -/* "sklearn/tree/_tree.pyx":72 +/* "sklearn/tree/_tree.pyx":79 * * * cdef class ClassificationCriterion(Criterion): # <<<<<<<<<<<<<< @@ -857,8 +844,8 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; -/* "sklearn/tree/_tree.pyx":221 - * +/* "sklearn/tree/_tree.pyx":252 + * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< * """Gini Index splitting criteria. @@ -871,7 +858,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini *__pyx_vtabptr_7sklearn_4tree_5_tree_Gini; -/* "sklearn/tree/_tree.pyx":265 +/* "sklearn/tree/_tree.pyx":303 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -941,28 +928,101 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ const char* function_name); /*proto*/ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ - -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); /*proto*/ +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_List_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) { + if (likely(o != Py_None)) { + if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) { + PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i); + Py_INCREF(r); + return r; + } + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} +#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) { + if (likely(o != Py_None)) { + if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) { + PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i); + Py_INCREF(r); + return r; + } + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} +#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ + __Pyx_GetItemInt_Fast(o, i) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i))) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) { + if (PyList_CheckExact(o)) { + Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (likely(i >= 0)) { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + return m->sq_item(o, i); + } + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -#define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0) #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +#define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0) +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); /*proto*/ + +#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) +#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2) static void __Pyx_RaiseBufferFallbackError(void); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ @@ -1001,8 +1061,6 @@ static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ -static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject *); - #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) @@ -1203,9 +1261,9 @@ static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_MSE = 0; static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t = { "BOOL_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_BOOL_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_7sklearn_4tree_5_tree_BOOL_t), 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), { 0 }, 0, 'I', IS_UNSIGNED(__pyx_t_5numpy_int32_t), 0 }; #define __Pyx_MODULE_NAME "sklearn.tree._tree" int __pyx_module_is_main_sklearn__tree___tree = 0; @@ -1215,10 +1273,12 @@ static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self); /* proto */ -static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, PyArrayObject *__pyx_v_y); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self); /* proto */ -static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, PyArrayObject *__pyx_v_y); /* proto */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_n_outputs, PyObject *__pyx_v_n_classes); /* proto */ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self); /* proto */ +static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_v_n_outputs); /* proto */ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n_total_samples, int __pyx_v_n_total_in_bag, PyObject *__pyx_v_random_state); /* proto */ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_out); /* proto */ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_pred); /* proto */ @@ -1227,22 +1287,20 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_X_argsorted, PyArrayObject *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_min_leaf, int __pyx_v_max_features, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, PyObject *__pyx_v_random_state); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static char __pyx_k_2[] = "ndarray is not C contiguous"; -static char __pyx_k_4[] = "ndarray is not Fortran contiguous"; -static char __pyx_k_6[] = "Non-native byte order not supported"; -static char __pyx_k_8[] = "unknown dtype code in numpy.pxd (%d)"; -static char __pyx_k_9[] = "Format string allocated too short, see comment in numpy.pxd"; -static char __pyx_k_12[] = "Format string allocated too short."; -static char __pyx_k_16[] = "/home/gilles/Sources/scikit-learn/sklearn/tree/_tree.pyx"; -static char __pyx_k_17[] = "sklearn.tree._tree"; -static char __pyx_k_24[] = "X_argsorted_elem_stride"; -static char __pyx_k_25[] = "X_argsorted_col_stride"; -static char __pyx_k_30[] = "_find_best_random_split"; +static char __pyx_k_1[] = "ndarray is not C contiguous"; +static char __pyx_k_3[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_5[] = "Non-native byte order not supported"; +static char __pyx_k_7[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_8[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_11[] = "Format string allocated too short."; +static char __pyx_k_15[] = "/home/gilles/Sources/scikit-learn/sklearn/tree/_tree.pyx"; +static char __pyx_k_16[] = "sklearn.tree._tree"; +static char __pyx_k_23[] = "X_argsorted_elem_stride"; +static char __pyx_k_24[] = "X_argsorted_col_stride"; +static char __pyx_k_29[] = "_find_best_random_split"; static char __pyx_k__B[] = "B"; -static char __pyx_k__C[] = "C"; static char __pyx_k__H[] = "H"; static char __pyx_k__I[] = "I"; -static char __pyx_k__K[] = "K"; static char __pyx_k__L[] = "L"; static char __pyx_k__O[] = "O"; static char __pyx_k__Q[] = "Q"; @@ -1267,7 +1325,6 @@ static char __pyx_k__Zg[] = "Zg"; static char __pyx_k__np[] = "np"; static char __pyx_k__X_i[] = "X_i"; static char __pyx_k__inf[] = "inf"; -static char __pyx_k__max[] = "max"; static char __pyx_k__out[] = "out"; static char __pyx_k__bool[] = "bool"; static char __pyx_k__int8[] = "int8"; @@ -1278,7 +1335,6 @@ static char __pyx_k__dtype[] = "dtype"; static char __pyx_k__error[] = "error"; static char __pyx_k__int32[] = "int32"; static char __pyx_k__numpy[] = "numpy"; -static char __pyx_k__order[] = "order"; static char __pyx_k__range[] = "range"; static char __pyx_k__y_ptr[] = "y_ptr"; static char __pyx_k__zeros[] = "zeros"; @@ -1287,7 +1343,6 @@ static char __pyx_k__astype[] = "astype"; static char __pyx_k__best_i[] = "best_i"; static char __pyx_k__best_t[] = "best_t"; static char __pyx_k__n_left[] = "n_left"; -static char __pyx_k__unique[] = "unique"; static char __pyx_k__values[] = "values"; static char __pyx_k__xrange[] = "xrange"; static char __pyx_k__feature[] = "feature"; @@ -1300,7 +1355,10 @@ static char __pyx_k__children[] = "children"; static char __pyx_k__features[] = "features"; static char __pyx_k__min_leaf[] = "min_leaf"; static char __pyx_k__n_bagged[] = "n_bagged"; +static char __pyx_k__y_stride[] = "y_stride"; static char __pyx_k__criterion[] = "criterion"; +static char __pyx_k__n_classes[] = "n_classes"; +static char __pyx_k__n_outputs[] = "n_outputs"; static char __pyx_k__n_samples[] = "n_samples"; static char __pyx_k__threshold[] = "threshold"; static char __pyx_k__ValueError[] = "ValueError"; @@ -1327,20 +1385,18 @@ static char __pyx_k__sample_mask_ptr[] = "sample_mask_ptr"; static char __pyx_k___find_best_split[] = "_find_best_split"; static char __pyx_k__X_argsorted_stride[] = "X_argsorted_stride"; static char __pyx_k___random_sample_mask[] = "_random_sample_mask"; -static PyObject *__pyx_kp_u_12; -static PyObject *__pyx_kp_s_16; -static PyObject *__pyx_n_s_17; -static PyObject *__pyx_kp_u_2; +static PyObject *__pyx_kp_u_1; +static PyObject *__pyx_kp_u_11; +static PyObject *__pyx_kp_s_15; +static PyObject *__pyx_n_s_16; +static PyObject *__pyx_n_s_23; static PyObject *__pyx_n_s_24; -static PyObject *__pyx_n_s_25; -static PyObject *__pyx_n_s_30; -static PyObject *__pyx_kp_u_4; -static PyObject *__pyx_kp_u_6; +static PyObject *__pyx_n_s_29; +static PyObject *__pyx_kp_u_3; +static PyObject *__pyx_kp_u_5; +static PyObject *__pyx_kp_u_7; static PyObject *__pyx_kp_u_8; -static PyObject *__pyx_kp_u_9; -static PyObject *__pyx_n_s__C; static PyObject *__pyx_n_s__DTYPE; -static PyObject *__pyx_n_s__K; static PyObject *__pyx_n_s__RuntimeError; static PyObject *__pyx_n_s__ValueError; static PyObject *__pyx_n_s__X; @@ -1382,20 +1438,20 @@ static PyObject *__pyx_n_s__initial_error; static PyObject *__pyx_n_s__int32; static PyObject *__pyx_n_s__int8; static PyObject *__pyx_n_s__k; -static PyObject *__pyx_n_s__max; static PyObject *__pyx_n_s__max_features; static PyObject *__pyx_n_s__min_leaf; static PyObject *__pyx_n_s__n; static PyObject *__pyx_n_s__n_bagged; +static PyObject *__pyx_n_s__n_classes; static PyObject *__pyx_n_s__n_features; static PyObject *__pyx_n_s__n_left; +static PyObject *__pyx_n_s__n_outputs; static PyObject *__pyx_n_s__n_samples; static PyObject *__pyx_n_s__n_total_in_bag; static PyObject *__pyx_n_s__n_total_samples; static PyObject *__pyx_n_s__node_id; static PyObject *__pyx_n_s__np; static PyObject *__pyx_n_s__numpy; -static PyObject *__pyx_n_s__order; static PyObject *__pyx_n_s__out; static PyObject *__pyx_n_s__permutation; static PyObject *__pyx_n_s__pred; @@ -1406,49 +1462,49 @@ static PyObject *__pyx_n_s__sample_mask; static PyObject *__pyx_n_s__sample_mask_ptr; static PyObject *__pyx_n_s__t; static PyObject *__pyx_n_s__threshold; -static PyObject *__pyx_n_s__unique; static PyObject *__pyx_n_s__values; static PyObject *__pyx_n_s__xrange; static PyObject *__pyx_n_s__y; static PyObject *__pyx_n_s__y_ptr; +static PyObject *__pyx_n_s__y_stride; static PyObject *__pyx_n_s__zeros; +static PyObject *__pyx_int_1; static PyObject *__pyx_int_15; -static PyObject *__pyx_k_slice_1; -static PyObject *__pyx_k_tuple_3; -static PyObject *__pyx_k_tuple_5; -static PyObject *__pyx_k_tuple_7; +static PyObject *__pyx_k_tuple_2; +static PyObject *__pyx_k_tuple_4; +static PyObject *__pyx_k_tuple_6; +static PyObject *__pyx_k_tuple_9; static PyObject *__pyx_k_tuple_10; -static PyObject *__pyx_k_tuple_11; +static PyObject *__pyx_k_tuple_12; static PyObject *__pyx_k_tuple_13; -static PyObject *__pyx_k_tuple_14; -static PyObject *__pyx_k_tuple_18; -static PyObject *__pyx_k_tuple_20; -static PyObject *__pyx_k_tuple_22; -static PyObject *__pyx_k_tuple_26; -static PyObject *__pyx_k_tuple_28; -static PyObject *__pyx_k_codeobj_15; -static PyObject *__pyx_k_codeobj_19; -static PyObject *__pyx_k_codeobj_21; -static PyObject *__pyx_k_codeobj_23; -static PyObject *__pyx_k_codeobj_27; -static PyObject *__pyx_k_codeobj_29; - -/* "sklearn/tree/_tree.pyx":43 +static PyObject *__pyx_k_tuple_17; +static PyObject *__pyx_k_tuple_19; +static PyObject *__pyx_k_tuple_21; +static PyObject *__pyx_k_tuple_25; +static PyObject *__pyx_k_tuple_27; +static PyObject *__pyx_k_codeobj_14; +static PyObject *__pyx_k_codeobj_18; +static PyObject *__pyx_k_codeobj_20; +static PyObject *__pyx_k_codeobj_22; +static PyObject *__pyx_k_codeobj_26; +static PyObject *__pyx_k_codeobj_28; + +/* "sklearn/tree/_tree.pyx":48 * """Interface for splitting criteria (regression and classification)""" * - * cdef void init(self, DTYPE_t *y, # <<<<<<<<<<<<<< - * BOOL_t *sample_mask, - * int n_samples, + * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< + * int y_stride, + * BOOL_t* sample_mask, */ -static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, CYTHON_UNUSED int __pyx_v_n_samples, CYTHON_UNUSED int __pyx_v_n_total_samples) { +static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED int __pyx_v_y_stride, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, CYTHON_UNUSED int __pyx_v_n_samples, CYTHON_UNUSED int __pyx_v_n_total_samples) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init", 0); __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":50 +/* "sklearn/tree/_tree.pyx":56 * pass * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -1463,15 +1519,15 @@ static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_reset(CYTHON_UNUSED struct __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":54 +/* "sklearn/tree/_tree.pyx":60 * pass * * cdef int update(self, int a, # <<<<<<<<<<<<<< * int b, - * DTYPE_t *y, + * DTYPE_t* y, */ -static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED int __pyx_v_a, CYTHON_UNUSED int __pyx_v_b, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED int *__pyx_v_X_argsorted_i, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { +static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self, CYTHON_UNUSED int __pyx_v_a, CYTHON_UNUSED int __pyx_v_b, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, CYTHON_UNUSED int __pyx_v_y_stride, CYTHON_UNUSED int *__pyx_v_X_argsorted_i, CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update", 0); @@ -1481,7 +1537,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":63 +/* "sklearn/tree/_tree.pyx":70 * pass * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -1499,7 +1555,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_9Criterion_eval(CYTHON_UNUSED struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":67 +/* "sklearn/tree/_tree.pyx":74 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -1521,13 +1577,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1536,7 +1592,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":69 + /* "sklearn/tree/_tree.pyx":76 * cpdef np.ndarray init_value(self): * """Get the init value of the criterion - `init` must be called before.""" * pass # <<<<<<<<<<<<<< @@ -1569,7 +1625,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject return __pyx_r; } -/* "sklearn/tree/_tree.pyx":67 +/* "sklearn/tree/_tree.pyx":74 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -1586,7 +1642,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self->__pyx_vtab)->init_value(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self->__pyx_vtab)->init_value(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1607,17 +1663,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __p /* Python wrapper */ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_y = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,0}; + int __pyx_v_n_outputs; + PyObject *__pyx_v_n_classes = 0; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_outputs,&__pyx_n_s__n_classes,0}; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - PyObject* values[1] = {0}; + PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; @@ -1625,522 +1683,198 @@ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(Py kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); + values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_outputs); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; + case 1: + values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_classes); + if (likely(values[1])) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_y = ((PyArrayObject *)values[0]); + __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_classes = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree.ClassificationCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self), __pyx_v_y); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self), __pyx_v_n_outputs, __pyx_v_n_classes); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":116 - * cdef ndarray_label_count_init +/* "sklearn/tree/_tree.pyx":118 + * cdef int n_right * - * def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): # <<<<<<<<<<<<<< + * def __init__(self, int n_outputs, object n_classes): # <<<<<<<<<<<<<< * cdef int k = 0 * */ -static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, PyArrayObject *__pyx_v_y) { +static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_n_outputs, PyObject *__pyx_v_n_classes) { int __pyx_v_k; - PyArrayObject *__pyx_v_n_classes = 0; - PyArrayObject *__pyx_v_ndarray_label_count_left = 0; - PyArrayObject *__pyx_v_ndarray_label_count_right = 0; - PyArrayObject *__pyx_v_ndarray_label_count_init = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_n_classes; - __Pyx_Buffer __pyx_pybuffer_n_classes; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_init; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_init; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_left; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_left; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_label_count_right; - __Pyx_Buffer __pyx_pybuffer_ndarray_label_count_right; - __Pyx_LocalBuf_ND __pyx_pybuffernd_y; - __Pyx_Buffer __pyx_pybuffer_y; + int __pyx_v_label_count_stride; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; + int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyArrayObject *__pyx_t_7 = NULL; - int __pyx_t_8; - Py_ssize_t __pyx_t_9; - int __pyx_t_10; - long __pyx_t_11; - PyArrayObject *__pyx_t_12 = NULL; - PyArrayObject *__pyx_t_13 = NULL; - PyArrayObject *__pyx_t_14 = NULL; + int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - __pyx_pybuffer_n_classes.pybuffer.buf = NULL; - __pyx_pybuffer_n_classes.refcount = 0; - __pyx_pybuffernd_n_classes.data = NULL; - __pyx_pybuffernd_n_classes.rcbuffer = &__pyx_pybuffer_n_classes; - __pyx_pybuffer_ndarray_label_count_left.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_left.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_left.data = NULL; - __pyx_pybuffernd_ndarray_label_count_left.rcbuffer = &__pyx_pybuffer_ndarray_label_count_left; - __pyx_pybuffer_ndarray_label_count_right.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_right.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_right.data = NULL; - __pyx_pybuffernd_ndarray_label_count_right.rcbuffer = &__pyx_pybuffer_ndarray_label_count_right; - __pyx_pybuffer_ndarray_label_count_init.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_label_count_init.refcount = 0; - __pyx_pybuffernd_ndarray_label_count_init.data = NULL; - __pyx_pybuffernd_ndarray_label_count_init.rcbuffer = &__pyx_pybuffer_ndarray_label_count_init; - __pyx_pybuffer_y.pybuffer.buf = NULL; - __pyx_pybuffer_y.refcount = 0; - __pyx_pybuffernd_y.data = NULL; - __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; - /* "sklearn/tree/_tree.pyx":117 + /* "sklearn/tree/_tree.pyx":119 * - * def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): + * def __init__(self, int n_outputs, object n_classes): * cdef int k = 0 # <<<<<<<<<<<<<< * - * if y.ndim == 2: + * self.n_outputs = n_outputs */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":119 + /* "sklearn/tree/_tree.pyx":121 * cdef int k = 0 * - * if y.ndim == 2: # <<<<<<<<<<<<<< - * self.y_stride = y.strides[1] / y.strides[0] - * self.n_outputs = y.shape[1] + * self.n_outputs = n_outputs # <<<<<<<<<<<<<< + * self.n_classes = calloc(n_outputs, sizeof(int)) + * cdef int label_count_stride = -1 */ - __pyx_t_1 = (__pyx_v_y->nd == 2); - if (__pyx_t_1) { + __pyx_v_self->n_outputs = __pyx_v_n_outputs; - /* "sklearn/tree/_tree.pyx":120 + /* "sklearn/tree/_tree.pyx":122 * - * if y.ndim == 2: - * self.y_stride = y.strides[1] / y.strides[0] # <<<<<<<<<<<<<< - * self.n_outputs = y.shape[1] - * else: - */ - __pyx_v_self->y_stride = ((__pyx_v_y->strides[1]) / (__pyx_v_y->strides[0])); - - /* "sklearn/tree/_tree.pyx":121 - * if y.ndim == 2: - * self.y_stride = y.strides[1] / y.strides[0] - * self.n_outputs = y.shape[1] # <<<<<<<<<<<<<< - * else: - * self.y_stride = 1 - */ - __pyx_v_self->n_outputs = (__pyx_v_y->dimensions[1]); - goto __pyx_L3; - } - /*else*/ { - - /* "sklearn/tree/_tree.pyx":123 - * self.n_outputs = y.shape[1] - * else: - * self.y_stride = 1 # <<<<<<<<<<<<<< - * self.n_outputs = 1 + * self.n_outputs = n_outputs + * self.n_classes = calloc(n_outputs, sizeof(int)) # <<<<<<<<<<<<<< + * cdef int label_count_stride = -1 * */ - __pyx_v_self->y_stride = 1; + __pyx_v_self->n_classes = ((int *)calloc(__pyx_v_n_outputs, (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":124 - * else: - * self.y_stride = 1 - * self.n_outputs = 1 # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":123 + * self.n_outputs = n_outputs + * self.n_classes = calloc(n_outputs, sizeof(int)) + * cdef int label_count_stride = -1 # <<<<<<<<<<<<<< * - * cdef np.ndarray[np.int32_t, ndim=1] n_classes = \ + * for k from 0 <= k < n_outputs: */ - __pyx_v_self->n_outputs = 1; - } - __pyx_L3:; + __pyx_v_label_count_stride = -1; - /* "sklearn/tree/_tree.pyx":127 + /* "sklearn/tree/_tree.pyx":125 + * cdef int label_count_stride = -1 * - * cdef np.ndarray[np.int32_t, ndim=1] n_classes = \ - * np.zeros((self.n_outputs,), dtype=np.int32, order="C") # <<<<<<<<<<<<<< + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * self.n_classes[k] = n_classes[k] * - * if y.ndim == 2: */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_GIVEREF(__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 = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int32); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_n_classes.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { - __pyx_v_n_classes = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_n_classes.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_n_classes.diminfo[0].strides = __pyx_pybuffernd_n_classes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_n_classes.diminfo[0].shape = __pyx_pybuffernd_n_classes.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_7 = 0; - __pyx_v_n_classes = ((PyArrayObject *)__pyx_t_6); - __pyx_t_6 = 0; + __pyx_t_1 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":129 - * np.zeros((self.n_outputs,), dtype=np.int32, order="C") + /* "sklearn/tree/_tree.pyx":126 * - * if y.ndim == 2: # <<<<<<<<<<<<<< - * for k from 0 <= k < self.n_outputs: - * n_classes[k] = len(np.unique(y[:, k])) - */ - __pyx_t_1 = (__pyx_v_y->nd == 2); - if (__pyx_t_1) { - - /* "sklearn/tree/_tree.pyx":130 + * for k from 0 <= k < n_outputs: + * self.n_classes[k] = n_classes[k] # <<<<<<<<<<<<<< * - * if y.ndim == 2: - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * n_classes[k] = len(np.unique(y[:, k])) - * else: + * if n_classes[k] > label_count_stride: */ - __pyx_t_8 = __pyx_v_self->n_outputs; - for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_8; __pyx_v_k++) { - - /* "sklearn/tree/_tree.pyx":131 - * if y.ndim == 2: - * for k from 0 <= k < self.n_outputs: - * n_classes[k] = len(np.unique(y[:, k])) # <<<<<<<<<<<<<< - * else: - * n_classes[0] = len(np.unique(y)) - */ - __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unique); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_k_slice_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_k_slice_1); - __Pyx_GIVEREF(__pyx_k_slice_1); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_y), ((PyObject *)__pyx_t_2)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(((PyObject *)__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 = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_9 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_10 = __pyx_v_k; - *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_n_classes.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_n_classes.diminfo[0].strides) = __pyx_t_9; - } - goto __pyx_L4; - } - /*else*/ { + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + (__pyx_v_self->n_classes[__pyx_v_k]) = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":133 - * n_classes[k] = len(np.unique(y[:, k])) - * else: - * n_classes[0] = len(np.unique(y)) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":128 + * self.n_classes[k] = n_classes[k] + * + * if n_classes[k] > label_count_stride: # <<<<<<<<<<<<<< + * label_count_stride = n_classes[k] * - * self.n_classes = n_classes.data */ - __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unique); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(((PyObject *)__pyx_v_y)); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_y)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_y)); - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_9 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_11 = 0; - *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_n_classes.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_n_classes.diminfo[0].strides) = __pyx_t_9; - } - __pyx_L4:; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_6) { - /* "sklearn/tree/_tree.pyx":135 - * n_classes[0] = len(np.unique(y)) + /* "sklearn/tree/_tree.pyx":129 * - * self.n_classes = n_classes.data # <<<<<<<<<<<<<< - * self.count_stride = np.max(n_classes) + * if n_classes[k] > label_count_stride: + * label_count_stride = n_classes[k] # <<<<<<<<<<<<<< * + * self.label_count_stride = label_count_stride */ - __pyx_v_self->n_classes = ((int *)__pyx_v_n_classes->data); + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_label_count_stride = __pyx_t_3; + goto __pyx_L5; + } + __pyx_L5:; + } - /* "sklearn/tree/_tree.pyx":136 - * - * self.n_classes = n_classes.data - * self.count_stride = np.max(n_classes) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":131 + * label_count_stride = n_classes[k] * - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_left \ + * self.label_count_stride = label_count_stride # <<<<<<<<<<<<<< + * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) + * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__max); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(((PyObject *)__pyx_v_n_classes)); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_n_classes)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_n_classes)); - __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_self->count_stride = __pyx_t_8; + __pyx_v_self->label_count_stride = __pyx_v_label_count_stride; - /* "sklearn/tree/_tree.pyx":139 + /* "sklearn/tree/_tree.pyx":132 * - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_left \ - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_right \ - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") + * self.label_count_stride = label_count_stride + * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< + * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) + * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyInt_FromLong(__pyx_v_self->count_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_2 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 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 = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_12 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_left.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_left.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ndarray_label_count_left.diminfo[1].strides = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ndarray_label_count_left.diminfo[1].shape = __pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer.shape[1]; - } - } - __pyx_t_12 = 0; - __pyx_v_ndarray_label_count_left = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_self->label_count_left = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":141 - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_right \ - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_init \ - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") + /* "sklearn/tree/_tree.pyx":133 + * self.label_count_stride = label_count_stride + * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) + * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< + * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) + * */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyInt_FromLong(__pyx_v_self->count_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_5 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __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_6)); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_13 = ((PyArrayObject *)__pyx_t_2); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_right.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_right.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ndarray_label_count_right.diminfo[1].strides = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ndarray_label_count_right.diminfo[1].shape = __pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer.shape[1]; - } - } - __pyx_t_13 = 0; - __pyx_v_ndarray_label_count_right = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_v_self->label_count_right = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":143 - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") - * cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_init \ - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":134 + * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) + * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) + * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< * * self.n_samples = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyInt_FromLong(__pyx_v_self->count_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_2 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 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 = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_14 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_label_count_init = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_label_count_init.diminfo[0].strides = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_label_count_init.diminfo[0].shape = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ndarray_label_count_init.diminfo[1].strides = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ndarray_label_count_init.diminfo[1].shape = __pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer.shape[1]; - } - } - __pyx_t_14 = 0; - __pyx_v_ndarray_label_count_init = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_self->label_count_init = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":145 - * = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") + /* "sklearn/tree/_tree.pyx":136 + * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) * * self.n_samples = 0 # <<<<<<<<<<<<<< * self.n_left = 0 @@ -2148,133 +1882,116 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->n_samples = 0; - /* "sklearn/tree/_tree.pyx":146 + /* "sklearn/tree/_tree.pyx":137 * * self.n_samples = 0 * self.n_left = 0 # <<<<<<<<<<<<<< * self.n_right = 0 - * self.label_count_left = ndarray_label_count_left.data + * */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":147 + /* "sklearn/tree/_tree.pyx":138 * self.n_samples = 0 * self.n_left = 0 * self.n_right = 0 # <<<<<<<<<<<<<< - * self.label_count_left = ndarray_label_count_left.data - * self.label_count_right = ndarray_label_count_right.data - */ - __pyx_v_self->n_right = 0; - - /* "sklearn/tree/_tree.pyx":148 - * self.n_left = 0 - * self.n_right = 0 - * self.label_count_left = ndarray_label_count_left.data # <<<<<<<<<<<<<< - * self.label_count_right = ndarray_label_count_right.data - * self.label_count_init = ndarray_label_count_init.data - */ - __pyx_v_self->label_count_left = ((int *)__pyx_v_ndarray_label_count_left->data); - - /* "sklearn/tree/_tree.pyx":149 - * self.n_right = 0 - * self.label_count_left = ndarray_label_count_left.data - * self.label_count_right = ndarray_label_count_right.data # <<<<<<<<<<<<<< - * self.label_count_init = ndarray_label_count_init.data - * self.ndarray_label_count_left = ndarray_label_count_left - */ - __pyx_v_self->label_count_right = ((int *)__pyx_v_ndarray_label_count_right->data); - - /* "sklearn/tree/_tree.pyx":150 - * self.label_count_left = ndarray_label_count_left.data - * self.label_count_right = ndarray_label_count_right.data - * self.label_count_init = ndarray_label_count_init.data # <<<<<<<<<<<<<< - * self.ndarray_label_count_left = ndarray_label_count_left - * self.ndarray_label_count_right = ndarray_label_count_right - */ - __pyx_v_self->label_count_init = ((int *)__pyx_v_ndarray_label_count_init->data); - - /* "sklearn/tree/_tree.pyx":151 - * self.label_count_right = ndarray_label_count_right.data - * self.label_count_init = ndarray_label_count_init.data - * self.ndarray_label_count_left = ndarray_label_count_left # <<<<<<<<<<<<<< - * self.ndarray_label_count_right = ndarray_label_count_right - * self.ndarray_label_count_init = ndarray_label_count_init - */ - __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_left)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_left)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_left); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_left); - __pyx_v_self->ndarray_label_count_left = ((PyObject *)__pyx_v_ndarray_label_count_left); - - /* "sklearn/tree/_tree.pyx":152 - * self.label_count_init = ndarray_label_count_init.data - * self.ndarray_label_count_left = ndarray_label_count_left - * self.ndarray_label_count_right = ndarray_label_count_right # <<<<<<<<<<<<<< - * self.ndarray_label_count_init = ndarray_label_count_init * + * def __del__(self): */ - __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_right)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_right)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_right); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_right); - __pyx_v_self->ndarray_label_count_right = ((PyObject *)__pyx_v_ndarray_label_count_right); - - /* "sklearn/tree/_tree.pyx":153 - * self.ndarray_label_count_left = ndarray_label_count_left - * self.ndarray_label_count_right = ndarray_label_count_right - * self.ndarray_label_count_init = ndarray_label_count_init # <<<<<<<<<<<<<< - * - * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, - */ - __Pyx_INCREF(((PyObject *)__pyx_v_ndarray_label_count_init)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ndarray_label_count_init)); - __Pyx_GOTREF(__pyx_v_self->ndarray_label_count_init); - __Pyx_DECREF(__pyx_v_self->ndarray_label_count_init); - __pyx_v_self->ndarray_label_count_init = ((PyObject *)__pyx_v_ndarray_label_count_init); + __pyx_v_self->n_right = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_n_classes.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree.ClassificationCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; - goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_n_classes.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_label_count_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_n_classes); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_label_count_left); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_label_count_right); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_label_count_init); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":155 - * self.ndarray_label_count_init = ndarray_label_count_init +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del__(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":140 + * self.n_right = 0 * - * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, # <<<<<<<<<<<<<< - * int n_total_samples): - * """Initialise the criterion class.""" + * def __del__(self): # <<<<<<<<<<<<<< + * free(self.n_classes) + * free(self.label_count_left) + */ + +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + + /* "sklearn/tree/_tree.pyx":141 + * + * def __del__(self): + * free(self.n_classes) # <<<<<<<<<<<<<< + * free(self.label_count_left) + * free(self.label_count_right) + */ + free(__pyx_v_self->n_classes); + + /* "sklearn/tree/_tree.pyx":142 + * def __del__(self): + * free(self.n_classes) + * free(self.label_count_left) # <<<<<<<<<<<<<< + * free(self.label_count_right) + * free(self.label_count_init) + */ + free(__pyx_v_self->label_count_left); + + /* "sklearn/tree/_tree.pyx":143 + * free(self.n_classes) + * free(self.label_count_left) + * free(self.label_count_right) # <<<<<<<<<<<<<< + * free(self.label_count_init) + * + */ + free(__pyx_v_self->label_count_right); + + /* "sklearn/tree/_tree.pyx":144 + * free(self.label_count_left) + * free(self.label_count_right) + * free(self.label_count_init) # <<<<<<<<<<<<<< + * + * cdef void init(self, DTYPE_t* y, + */ + free(__pyx_v_self->label_count_init); + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "sklearn/tree/_tree.pyx":146 + * free(self.label_count_init) + * + * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< + * int y_stride, + * BOOL_t *sample_mask, */ -static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { +static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int __pyx_v_y_stride, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { + int __pyx_v_n_outputs; + int *__pyx_v_n_classes; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_init; int __pyx_v_k; int __pyx_v_c; int __pyx_v_j; @@ -2285,17 +2002,53 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct int __pyx_t_4; __Pyx_RefNannySetupContext("init", 0); - /* "sklearn/tree/_tree.pyx":158 - * int n_total_samples): + /* "sklearn/tree/_tree.pyx":152 + * int n_total_samples): + * """Initialise the criterion class.""" + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":153 * """Initialise the criterion class.""" + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init + */ + __pyx_v_n_classes = __pyx_v_self->n_classes; + + /* "sklearn/tree/_tree.pyx":154 + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_init = self.label_count_init + * + */ + __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; + + /* "sklearn/tree/_tree.pyx":155 + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< + * + * cdef int k = 0 + */ + __pyx_v_label_count_init = __pyx_v_self->label_count_init; + + /* "sklearn/tree/_tree.pyx":157 + * cdef int* label_count_init = self.label_count_init + * * cdef int k = 0 # <<<<<<<<<<<<<< * cdef int c = 0 * cdef int j = 0 */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":159 - * """Initialise the criterion class.""" + /* "sklearn/tree/_tree.pyx":158 + * * cdef int k = 0 * cdef int c = 0 # <<<<<<<<<<<<<< * cdef int j = 0 @@ -2303,7 +2056,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_c = 0; - /* "sklearn/tree/_tree.pyx":160 + /* "sklearn/tree/_tree.pyx":159 * cdef int k = 0 * cdef int c = 0 * cdef int j = 0 # <<<<<<<<<<<<<< @@ -2312,101 +2065,112 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_j = 0; - /* "sklearn/tree/_tree.pyx":162 + /* "sklearn/tree/_tree.pyx":161 * cdef int j = 0 * * self.n_samples = n_samples # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ __pyx_v_self->n_samples = __pyx_v_n_samples; - /* "sklearn/tree/_tree.pyx":164 + /* "sklearn/tree/_tree.pyx":163 * self.n_samples = n_samples * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * for c from 0 <= c < self.n_classes[k]: - * self.label_count_init[k * self.count_stride + c] = 0 + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes[k]: + * label_count_init[k * label_count_stride + c] = 0 */ - __pyx_t_1 = __pyx_v_self->n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":165 + /* "sklearn/tree/_tree.pyx":164 * - * for k from 0 <= k < self.n_outputs: - * for c from 0 <= c < self.n_classes[k]: # <<<<<<<<<<<<<< - * self.label_count_init[k * self.count_stride + c] = 0 + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * label_count_init[k * label_count_stride + c] = 0 * */ - __pyx_t_2 = (__pyx_v_self->n_classes[__pyx_v_k]); + __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":166 - * for k from 0 <= k < self.n_outputs: - * for c from 0 <= c < self.n_classes[k]: - * self.label_count_init[k * self.count_stride + c] = 0 # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":165 + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: + * label_count_init[k * label_count_stride + c] = 0 # <<<<<<<<<<<<<< * - * for j from 0 <= j < n_total_samples: + * for j from 0 <= j < n_total_samples: */ - (__pyx_v_self->label_count_init[((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c)]) = 0; + (__pyx_v_label_count_init[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) = 0; } + } + + /* "sklearn/tree/_tree.pyx":167 + * label_count_init[k * label_count_stride + c] = 0 + * + * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< + * if sample_mask[j] == 0: + * continue + */ + __pyx_t_1 = __pyx_v_n_total_samples; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_1; __pyx_v_j++) { /* "sklearn/tree/_tree.pyx":168 - * self.label_count_init[k * self.count_stride + c] = 0 * - * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< - * if sample_mask[j] == 0: - * continue + * for j from 0 <= j < n_total_samples: + * if sample_mask[j] == 0: # <<<<<<<<<<<<<< + * continue + * */ - __pyx_t_2 = __pyx_v_n_total_samples; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_2; __pyx_v_j++) { + __pyx_t_3 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); + if (__pyx_t_3) { /* "sklearn/tree/_tree.pyx":169 + * for j from 0 <= j < n_total_samples: + * if sample_mask[j] == 0: + * continue # <<<<<<<<<<<<<< * - * for j from 0 <= j < n_total_samples: - * if sample_mask[j] == 0: # <<<<<<<<<<<<<< - * continue - * + * for k from 0 <= k < n_outputs: */ - __pyx_t_3 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); - if (__pyx_t_3) { + goto __pyx_L7_continue; + goto __pyx_L9; + } + __pyx_L9:; - /* "sklearn/tree/_tree.pyx":170 - * for j from 0 <= j < n_total_samples: - * if sample_mask[j] == 0: - * continue # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":171 + * continue * - * c = (y[k * self.y_stride + j]) + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * c = y[j * y_stride + k] + * label_count_init[k * label_count_stride + c] += 1 */ - goto __pyx_L7_continue; - goto __pyx_L9; - } - __pyx_L9:; + __pyx_t_2 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) { /* "sklearn/tree/_tree.pyx":172 - * continue * - * c = (y[k * self.y_stride + j]) # <<<<<<<<<<<<<< - * self.label_count_init[k * self.count_stride + c] += 1 + * for k from 0 <= k < n_outputs: + * c = y[j * y_stride + k] # <<<<<<<<<<<<<< + * label_count_init[k * label_count_stride + c] += 1 * */ - __pyx_v_c = ((int)(__pyx_v_y[((__pyx_v_k * __pyx_v_self->y_stride) + __pyx_v_j)])); + __pyx_v_c = ((int)(__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)])); /* "sklearn/tree/_tree.pyx":173 - * - * c = (y[k * self.y_stride + j]) - * self.label_count_init[k * self.count_stride + c] += 1 # <<<<<<<<<<<<<< + * for k from 0 <= k < n_outputs: + * c = y[j * y_stride + k] + * label_count_init[k * label_count_stride + c] += 1 # <<<<<<<<<<<<<< * * self.reset() */ - __pyx_t_4 = ((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c); - (__pyx_v_self->label_count_init[__pyx_t_4]) = ((__pyx_v_self->label_count_init[__pyx_t_4]) + 1); - __pyx_L7_continue:; + __pyx_t_4 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); + (__pyx_v_label_count_init[__pyx_t_4]) = ((__pyx_v_label_count_init[__pyx_t_4]) + 1); } + __pyx_L7_continue:; } /* "sklearn/tree/_tree.pyx":175 - * self.label_count_init[k * self.count_stride + c] += 1 + * label_count_init[k * label_count_stride + c] += 1 * * self.reset() # <<<<<<<<<<<<<< * @@ -2426,6 +2190,12 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { + int __pyx_v_n_outputs; + int *__pyx_v_n_classes; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_init; + int *__pyx_v_label_count_left; + int *__pyx_v_label_count_right; int __pyx_v_k; int __pyx_v_c; __Pyx_RefNannyDeclarations @@ -2436,14 +2206,68 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct /* "sklearn/tree/_tree.pyx":180 * """Reset label_counts by setting `label_count_left to zero * and copying the init array into the right.""" + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":181 + * and copying the init array into the right.""" + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init + */ + __pyx_v_n_classes = __pyx_v_self->n_classes; + + /* "sklearn/tree/_tree.pyx":182 + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_init = self.label_count_init + * cdef int* label_count_left = self.label_count_left + */ + __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; + + /* "sklearn/tree/_tree.pyx":183 + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right + */ + __pyx_v_label_count_init = __pyx_v_self->label_count_init; + + /* "sklearn/tree/_tree.pyx":184 + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init + * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< + * cdef int* label_count_right = self.label_count_right + * + */ + __pyx_v_label_count_left = __pyx_v_self->label_count_left; + + /* "sklearn/tree/_tree.pyx":185 + * cdef int* label_count_init = self.label_count_init + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< + * + * cdef int k = 0 + */ + __pyx_v_label_count_right = __pyx_v_self->label_count_right; + + /* "sklearn/tree/_tree.pyx":187 + * cdef int* label_count_right = self.label_count_right + * * cdef int k = 0 # <<<<<<<<<<<<<< * cdef int c = 0 * self.n_left = 0 */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":181 - * and copying the init array into the right.""" + /* "sklearn/tree/_tree.pyx":188 + * * cdef int k = 0 * cdef int c = 0 # <<<<<<<<<<<<<< * self.n_left = 0 @@ -2451,7 +2275,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_c = 0; - /* "sklearn/tree/_tree.pyx":182 + /* "sklearn/tree/_tree.pyx":189 * cdef int k = 0 * cdef int c = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -2460,67 +2284,73 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":183 + /* "sklearn/tree/_tree.pyx":190 * cdef int c = 0 * self.n_left = 0 * self.n_right = self.n_samples # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ __pyx_v_self->n_right = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":185 + /* "sklearn/tree/_tree.pyx":192 * self.n_right = self.n_samples * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * for c from 0 <= c < self.n_classes[k]: - * self.label_count_left[k * self.count_stride + c] = 0 + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes[k]: + * label_count_left[k * label_count_stride + c] = 0 */ - __pyx_t_1 = __pyx_v_self->n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":186 + /* "sklearn/tree/_tree.pyx":193 * - * for k from 0 <= k < self.n_outputs: - * for c from 0 <= c < self.n_classes[k]: # <<<<<<<<<<<<<< - * self.label_count_left[k * self.count_stride + c] = 0 - * self.label_count_right[k * self.count_stride + c] = self.label_count_init[k * self.count_stride + c] + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * label_count_left[k * label_count_stride + c] = 0 + * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] */ - __pyx_t_2 = (__pyx_v_self->n_classes[__pyx_v_k]); + __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":187 - * for k from 0 <= k < self.n_outputs: - * for c from 0 <= c < self.n_classes[k]: - * self.label_count_left[k * self.count_stride + c] = 0 # <<<<<<<<<<<<<< - * self.label_count_right[k * self.count_stride + c] = self.label_count_init[k * self.count_stride + c] + /* "sklearn/tree/_tree.pyx":194 + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: + * label_count_left[k * label_count_stride + c] = 0 # <<<<<<<<<<<<<< + * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] * */ - (__pyx_v_self->label_count_left[((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c)]) = 0; + (__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) = 0; - /* "sklearn/tree/_tree.pyx":188 - * for c from 0 <= c < self.n_classes[k]: - * self.label_count_left[k * self.count_stride + c] = 0 - * self.label_count_right[k * self.count_stride + c] = self.label_count_init[k * self.count_stride + c] # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":195 + * for c from 0 <= c < n_classes[k]: + * label_count_left[k * label_count_stride + c] = 0 + * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] # <<<<<<<<<<<<<< * - * cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, + * cdef int update(self, int a, */ - (__pyx_v_self->label_count_right[((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c)]) = (__pyx_v_self->label_count_init[((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c)]); + (__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) = (__pyx_v_label_count_init[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); } } __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":190 - * self.label_count_right[k * self.count_stride + c] = self.label_count_init[k * self.count_stride + c] +/* "sklearn/tree/_tree.pyx":197 + * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] * - * cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, # <<<<<<<<<<<<<< - * BOOL_t *sample_mask): - * """Update the criteria for each value in interval [a,b) (where a and b + * cdef int update(self, int a, # <<<<<<<<<<<<<< + * int b, + * DTYPE_t* y, */ -static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { +static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int __pyx_v_y_stride, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { + int __pyx_v_n_outputs; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_left; + int *__pyx_v_label_count_right; + int __pyx_v_n_left; + int __pyx_v_n_right; int __pyx_v_k; int __pyx_v_c; int __pyx_v_idx; @@ -2533,13 +2363,68 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("update", 0); - /* "sklearn/tree/_tree.pyx":198 + /* "sklearn/tree/_tree.pyx":205 + * """Update the criteria for each value in interval [a,b) (where a and b + * are indices in `X_argsorted_i`).""" + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":206 + * are indices in `X_argsorted_i`).""" + * cdef int n_outputs = self.n_outputs + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right + */ + __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; + + /* "sklearn/tree/_tree.pyx":207 + * cdef int n_outputs = self.n_outputs + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< + * cdef int* label_count_right = self.label_count_right + * cdef int n_left = self.n_left + */ + __pyx_v_label_count_left = __pyx_v_self->label_count_left; + + /* "sklearn/tree/_tree.pyx":208 + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< + * cdef int n_left = self.n_left + * cdef int n_right = self.n_right + */ + __pyx_v_label_count_right = __pyx_v_self->label_count_right; + + /* "sklearn/tree/_tree.pyx":209 + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right + * cdef int n_left = self.n_left # <<<<<<<<<<<<<< + * cdef int n_right = self.n_right + * + */ + __pyx_v_n_left = __pyx_v_self->n_left; + + /* "sklearn/tree/_tree.pyx":210 + * cdef int* label_count_right = self.label_count_right + * cdef int n_left = self.n_left + * cdef int n_right = self.n_right # <<<<<<<<<<<<<< + * + * cdef int k + */ + __pyx_v_n_right = __pyx_v_self->n_right; + + /* "sklearn/tree/_tree.pyx":216 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -2549,117 +2434,141 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":199 + /* "sklearn/tree/_tree.pyx":217 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * s = X_argsorted_i[idx] # <<<<<<<<<<<<<< * * if sample_mask[s] == 0: */ - __pyx_t_2 = PyInt_FromLong((__pyx_v_X_argsorted_i[__pyx_v_idx])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_X_argsorted_i[__pyx_v_idx])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF(__pyx_v_s); __pyx_v_s = __pyx_t_2; __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":201 + /* "sklearn/tree/_tree.pyx":219 * s = X_argsorted_i[idx] * * if sample_mask[s] == 0: # <<<<<<<<<<<<<< * continue * */ - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_s); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_s); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((__pyx_v_sample_mask[__pyx_t_3]) == 0); if (__pyx_t_4) { - /* "sklearn/tree/_tree.pyx":202 + /* "sklearn/tree/_tree.pyx":220 * * if sample_mask[s] == 0: * continue # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ goto __pyx_L3_continue; goto __pyx_L5; } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":204 + /* "sklearn/tree/_tree.pyx":222 * continue * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * c = (y[k * self.y_stride + s]) - * self.label_count_right[k * self.count_stride + c] -= 1 + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * c = y[s * y_stride + k] + * label_count_right[k * label_count_stride + c] -= 1 */ - __pyx_t_5 = __pyx_v_self->n_outputs; + __pyx_t_5 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":205 + /* "sklearn/tree/_tree.pyx":223 * - * for k from 0 <= k < self.n_outputs: - * c = (y[k * self.y_stride + s]) # <<<<<<<<<<<<<< - * self.label_count_right[k * self.count_stride + c] -= 1 - * self.label_count_left[k * self.count_stride + c] += 1 + * for k from 0 <= k < n_outputs: + * c = y[s * y_stride + k] # <<<<<<<<<<<<<< + * label_count_right[k * label_count_stride + c] -= 1 + * label_count_left[k * label_count_stride + c] += 1 */ - __pyx_t_2 = PyInt_FromLong((__pyx_v_k * __pyx_v_self->y_stride)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_y_stride); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Multiply(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_c = ((int)(__pyx_v_y[__pyx_t_3])); - /* "sklearn/tree/_tree.pyx":206 - * for k from 0 <= k < self.n_outputs: - * c = (y[k * self.y_stride + s]) - * self.label_count_right[k * self.count_stride + c] -= 1 # <<<<<<<<<<<<<< - * self.label_count_left[k * self.count_stride + c] += 1 + /* "sklearn/tree/_tree.pyx":224 + * for k from 0 <= k < n_outputs: + * c = y[s * y_stride + k] + * label_count_right[k * label_count_stride + c] -= 1 # <<<<<<<<<<<<<< + * label_count_left[k * label_count_stride + c] += 1 * */ - __pyx_t_7 = ((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c); - (__pyx_v_self->label_count_right[__pyx_t_7]) = ((__pyx_v_self->label_count_right[__pyx_t_7]) - 1); + __pyx_t_8 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); + (__pyx_v_label_count_right[__pyx_t_8]) = ((__pyx_v_label_count_right[__pyx_t_8]) - 1); - /* "sklearn/tree/_tree.pyx":207 - * c = (y[k * self.y_stride + s]) - * self.label_count_right[k * self.count_stride + c] -= 1 - * self.label_count_left[k * self.count_stride + c] += 1 # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":225 + * c = y[s * y_stride + k] + * label_count_right[k * label_count_stride + c] -= 1 + * label_count_left[k * label_count_stride + c] += 1 # <<<<<<<<<<<<<< * - * self.n_right -= 1 + * n_left += 1 */ - __pyx_t_7 = ((__pyx_v_k * __pyx_v_self->count_stride) + __pyx_v_c); - (__pyx_v_self->label_count_left[__pyx_t_7]) = ((__pyx_v_self->label_count_left[__pyx_t_7]) + 1); + __pyx_t_8 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); + (__pyx_v_label_count_left[__pyx_t_8]) = ((__pyx_v_label_count_left[__pyx_t_8]) + 1); } - /* "sklearn/tree/_tree.pyx":209 - * self.label_count_left[k * self.count_stride + c] += 1 + /* "sklearn/tree/_tree.pyx":227 + * label_count_left[k * label_count_stride + c] += 1 * - * self.n_right -= 1 # <<<<<<<<<<<<<< - * self.n_left += 1 + * n_left += 1 # <<<<<<<<<<<<<< + * n_right -=1 * */ - __pyx_v_self->n_right = (__pyx_v_self->n_right - 1); + __pyx_v_n_left = (__pyx_v_n_left + 1); - /* "sklearn/tree/_tree.pyx":210 + /* "sklearn/tree/_tree.pyx":228 * - * self.n_right -= 1 - * self.n_left += 1 # <<<<<<<<<<<<<< + * n_left += 1 + * n_right -=1 # <<<<<<<<<<<<<< * - * return self.n_left + * self.n_left = n_left */ - __pyx_v_self->n_left = (__pyx_v_self->n_left + 1); + __pyx_v_n_right = (__pyx_v_n_right - 1); __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":212 - * self.n_left += 1 + /* "sklearn/tree/_tree.pyx":230 + * n_right -=1 + * + * self.n_left = n_left # <<<<<<<<<<<<<< + * self.n_right = n_right + * + */ + __pyx_v_self->n_left = __pyx_v_n_left; + + /* "sklearn/tree/_tree.pyx":231 + * + * self.n_left = n_left + * self.n_right = n_right # <<<<<<<<<<<<<< + * + * return n_left + */ + __pyx_v_self->n_right = __pyx_v_n_right; + + /* "sklearn/tree/_tree.pyx":233 + * self.n_right = n_right * - * return self.n_left # <<<<<<<<<<<<<< + * return n_left # <<<<<<<<<<<<<< * * cdef double eval(self): */ - __pyx_r = __pyx_v_self->n_left; + __pyx_r = __pyx_v_n_left; goto __pyx_L0; __pyx_r = 0; @@ -2667,6 +2576,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); __Pyx_WriteUnraisable("sklearn.tree._tree.ClassificationCriterion.update", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -2675,8 +2585,8 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":214 - * return self.n_left +/* "sklearn/tree/_tree.pyx":235 + * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< * pass @@ -2693,35 +2603,56 @@ static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(CYTHO return __pyx_r; } -/* "sklearn/tree/_tree.pyx":217 +/* "sklearn/tree/_tree.pyx":238 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< - * return self.ndarray_label_count_init - * + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_n_outputs; + int *__pyx_v_n_classes; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_init; + PyArrayObject *__pyx_v_value = 0; + PyObject *__pyx_v_k = NULL; + PyObject *__pyx_v_c = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_value; + __Pyx_Buffer __pyx_pybuffer_value; PyArrayObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + int __pyx_t_6; + long __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + long __pyx_t_10; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); + __pyx_pybuffer_value.pybuffer.buf = NULL; + __pyx_pybuffer_value.refcount = 0; + __pyx_pybuffernd_value.data = NULL; + __pyx_pybuffernd_value.rcbuffer = &__pyx_pybuffer_value; /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2730,17 +2661,198 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":218 + /* "sklearn/tree/_tree.pyx":239 * * cpdef np.ndarray init_value(self): - * return self.ndarray_label_count_init # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":240 + * cpdef np.ndarray init_value(self): + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init + */ + __pyx_v_n_classes = __pyx_v_self->n_classes; + + /* "sklearn/tree/_tree.pyx":241 + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_init = self.label_count_init + * + */ + __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; + + /* "sklearn/tree/_tree.pyx":242 + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + */ + __pyx_v_label_count_init = __pyx_v_self->label_count_init; + + /* "sklearn/tree/_tree.pyx":244 + * cdef int* label_count_init = self.label_count_init + * + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) # <<<<<<<<<<<<<< + * + * for k from 0 <= k < n_outputs: + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __pyx_t_4 = 0; + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __pyx_v_value = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":246 + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes[k]: + * value[k, c] = (label_count_init[k * label_count_stride + c]) + */ + __pyx_t_6 = __pyx_v_n_outputs; + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7++) { + __pyx_t_1 = PyInt_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_k); + __pyx_v_k = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":247 + * + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * value[k, c] = (label_count_init[k * label_count_stride + c]) + * + */ + __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = (__pyx_v_n_classes[__pyx_t_8]); + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10++) { + __pyx_t_1 = PyInt_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_c); + __pyx_v_c = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":248 + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: + * value[k, c] = (label_count_init[k * label_count_stride + c]) # <<<<<<<<<<<<<< + * + * return value + */ + __pyx_t_1 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyNumber_Multiply(__pyx_v_k, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyFloat_FromDouble(((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_label_count_init[__pyx_t_8]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_k); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_k); + __Pyx_GIVEREF(__pyx_v_k); + __Pyx_INCREF(__pyx_v_c); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_c); + __Pyx_GIVEREF(__pyx_v_c); + if (PyObject_SetItem(((PyObject *)__pyx_v_value), ((PyObject *)__pyx_t_4), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_10 = __Pyx_PyInt_AsLong(__pyx_v_c); if (unlikely((__pyx_t_10 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "sklearn/tree/_tree.pyx":247 + * + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * value[k, c] = (label_count_init[k * label_count_stride + c]) + * + */ + __pyx_t_1 = PyInt_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_c); + __pyx_v_c = __pyx_t_1; + __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyInt_AsLong(__pyx_v_k); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "sklearn/tree/_tree.pyx":246 + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes[k]: + * value[k, c] = (label_count_init[k * label_count_stride + c]) + */ + __pyx_t_1 = PyInt_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_k); + __pyx_v_k = __pyx_t_1; + __pyx_t_1 = 0; + + /* "sklearn/tree/_tree.pyx":250 + * value[k, c] = (label_count_init[k * label_count_stride + c]) * + * return value # <<<<<<<<<<<<<< * + * cdef class Gini(ClassificationCriterion): */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - if (!(likely(((__pyx_v_self->ndarray_label_count_init) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self->ndarray_label_count_init, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_INCREF(__pyx_v_self->ndarray_label_count_init); - __pyx_r = ((PyArrayObject *)__pyx_v_self->ndarray_label_count_init); + __Pyx_INCREF(((PyObject *)__pyx_v_value)); + __pyx_r = ((PyArrayObject *)__pyx_v_value); goto __pyx_L0; __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); @@ -2748,34 +2860,46 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_value.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree.ClassificationCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; + goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_value.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_value); + __Pyx_XDECREF(__pyx_v_k); + __Pyx_XDECREF(__pyx_v_c); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_value (wrapper)", 0); - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)); + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":217 +/* "sklearn/tree/_tree.pyx":238 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< - * return self.ndarray_label_count_init - * + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_value(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2784,7 +2908,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2802,18 +2926,24 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2init_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":228 +/* "sklearn/tree/_tree.pyx":259 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< * """Returns Gini index of left branch + Gini index of right branch. """ - * cdef double total = 0.0 + * cdef int n_samples = self.n_samples */ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn_4tree_5_tree_Gini *__pyx_v_self) { - double __pyx_v_total; + int __pyx_v_n_samples; + int __pyx_v_n_outputs; + int *__pyx_v_n_classes; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_left; + int *__pyx_v_label_count_right; double __pyx_v_n_left; double __pyx_v_n_right; + double __pyx_v_total; double __pyx_v_H_left; double __pyx_v_H_right; int __pyx_v_k; @@ -2827,83 +2957,137 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":230 + /* "sklearn/tree/_tree.pyx":261 * cdef double eval(self): * """Returns Gini index of left branch + Gini index of right branch. """ - * cdef double total = 0.0 # <<<<<<<<<<<<<< + * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + */ + __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; + + /* "sklearn/tree/_tree.pyx":262 + * """Returns Gini index of left branch + Gini index of right branch. """ + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + */ + __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; + + /* "sklearn/tree/_tree.pyx":263 + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + */ + __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; + + /* "sklearn/tree/_tree.pyx":264 + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right + */ + __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; + + /* "sklearn/tree/_tree.pyx":265 + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< + * cdef int* label_count_right = self.label_count_right + * cdef double n_left = self.n_left + */ + __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; + + /* "sklearn/tree/_tree.pyx":266 + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< * cdef double n_left = self.n_left * cdef double n_right = self.n_right */ - __pyx_v_total = 0.0; + __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; - /* "sklearn/tree/_tree.pyx":231 - * """Returns Gini index of left branch + Gini index of right branch. """ - * cdef double total = 0.0 + /* "sklearn/tree/_tree.pyx":267 + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< * cdef double n_right = self.n_right - * cdef double H_left + * */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":232 - * cdef double total = 0.0 + /* "sklearn/tree/_tree.pyx":268 + * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< + * + * cdef double total = 0.0 + */ + __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); + + /* "sklearn/tree/_tree.pyx":270 + * cdef double n_right = self.n_right + * + * cdef double total = 0.0 # <<<<<<<<<<<<<< * cdef double H_left * cdef double H_right */ - __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); + __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":237 + /* "sklearn/tree/_tree.pyx":275 * cdef int k, c, count_left, count_right * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< * H_left = n_left * n_left * H_right = n_right * n_right */ - __pyx_t_1 = __pyx_v_self->__pyx_base.n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":238 + /* "sklearn/tree/_tree.pyx":276 * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: * H_left = n_left * n_left # <<<<<<<<<<<<<< * H_right = n_right * n_right * */ __pyx_v_H_left = (__pyx_v_n_left * __pyx_v_n_left); - /* "sklearn/tree/_tree.pyx":239 - * for k from 0 <= k < self.n_outputs: + /* "sklearn/tree/_tree.pyx":277 + * for k from 0 <= k < n_outputs: * H_left = n_left * n_left * H_right = n_right * n_right # <<<<<<<<<<<<<< * - * for c from 0 <= c < self.n_classes[k]: + * for c from 0 <= c < n_classes[k]: */ __pyx_v_H_right = (__pyx_v_n_right * __pyx_v_n_right); - /* "sklearn/tree/_tree.pyx":241 + /* "sklearn/tree/_tree.pyx":279 * H_right = n_right * n_right * - * for c from 0 <= c < self.n_classes[k]: # <<<<<<<<<<<<<< - * count_left = self.label_count_left[k * self.count_stride + c] + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: */ - __pyx_t_2 = (__pyx_v_self->__pyx_base.n_classes[__pyx_v_k]); + __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":242 + /* "sklearn/tree/_tree.pyx":280 * - * for c from 0 <= c < self.n_classes[k]: - * count_left = self.label_count_left[k * self.count_stride + c] # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes[k]: + * count_left = label_count_left[k * label_count_stride + c] # <<<<<<<<<<<<<< * if count_left > 0: * H_left -= (count_left * count_left) */ - __pyx_v_count_left = (__pyx_v_self->__pyx_base.label_count_left[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]); + __pyx_v_count_left = (__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":243 - * for c from 0 <= c < self.n_classes[k]: - * count_left = self.label_count_left[k * self.count_stride + c] + /* "sklearn/tree/_tree.pyx":281 + * for c from 0 <= c < n_classes[k]: + * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: # <<<<<<<<<<<<<< * H_left -= (count_left * count_left) * @@ -2911,30 +3095,30 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_left > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":244 - * count_left = self.label_count_left[k * self.count_stride + c] + /* "sklearn/tree/_tree.pyx":282 + * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: * H_left -= (count_left * count_left) # <<<<<<<<<<<<<< * - * count_right = self.label_count_right[k * self.count_stride + c] + * count_right = label_count_right[k * label_count_stride + c] */ __pyx_v_H_left = (__pyx_v_H_left - (__pyx_v_count_left * __pyx_v_count_left)); goto __pyx_L7; } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":246 + /* "sklearn/tree/_tree.pyx":284 * H_left -= (count_left * count_left) * - * count_right = self.label_count_right[k * self.count_stride + c] # <<<<<<<<<<<<<< + * count_right = label_count_right[k * label_count_stride + c] # <<<<<<<<<<<<<< * if count_right > 0: * H_right -= (count_right * count_right) */ - __pyx_v_count_right = (__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]); + __pyx_v_count_right = (__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":247 + /* "sklearn/tree/_tree.pyx":285 * - * count_right = self.label_count_right[k * self.count_stride + c] + * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: # <<<<<<<<<<<<<< * H_right -= (count_right * count_right) * @@ -2942,8 +3126,8 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_right > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":248 - * count_right = self.label_count_right[k * self.count_stride + c] + /* "sklearn/tree/_tree.pyx":286 + * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: * H_right -= (count_right * count_right) # <<<<<<<<<<<<<< * @@ -2955,7 +3139,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":250 + /* "sklearn/tree/_tree.pyx":288 * H_right -= (count_right * count_right) * * if n_left == 0: # <<<<<<<<<<<<<< @@ -2965,7 +3149,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_left == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":251 + /* "sklearn/tree/_tree.pyx":289 * * if n_left == 0: * H_left = 0 # <<<<<<<<<<<<<< @@ -2977,7 +3161,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":253 + /* "sklearn/tree/_tree.pyx":291 * H_left = 0 * else: * H_left /= n_left # <<<<<<<<<<<<<< @@ -2988,7 +3172,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L9:; - /* "sklearn/tree/_tree.pyx":255 + /* "sklearn/tree/_tree.pyx":293 * H_left /= n_left * * if n_right == 0: # <<<<<<<<<<<<<< @@ -2998,7 +3182,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_right == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":256 + /* "sklearn/tree/_tree.pyx":294 * * if n_right == 0: * H_right = 0 # <<<<<<<<<<<<<< @@ -3010,7 +3194,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":258 + /* "sklearn/tree/_tree.pyx":296 * H_right = 0 * else: * H_right /= n_right # <<<<<<<<<<<<<< @@ -3021,24 +3205,24 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L10:; - /* "sklearn/tree/_tree.pyx":260 + /* "sklearn/tree/_tree.pyx":298 * H_right /= n_right * * total += (H_left + H_right) # <<<<<<<<<<<<<< * - * return total / (self.n_samples * self.n_outputs) + * return total / (n_samples * n_outputs) */ __pyx_v_total = (__pyx_v_total + (__pyx_v_H_left + __pyx_v_H_right)); } - /* "sklearn/tree/_tree.pyx":262 + /* "sklearn/tree/_tree.pyx":300 * total += (H_left + H_right) * - * return total / (self.n_samples * self.n_outputs) # <<<<<<<<<<<<<< + * return total / (n_samples * n_outputs) # <<<<<<<<<<<<<< * * */ - __pyx_r = (__pyx_v_total / (__pyx_v_self->__pyx_base.n_samples * __pyx_v_self->__pyx_base.n_outputs)); + __pyx_r = (__pyx_v_total / (__pyx_v_n_samples * __pyx_v_n_outputs)); goto __pyx_L0; __pyx_r = 0; @@ -3047,15 +3231,23 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn return __pyx_r; } -/* "sklearn/tree/_tree.pyx":271 +/* "sklearn/tree/_tree.pyx":309 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< * """Returns Entropy of left branch + Entropy index of right branch. """ - * cdef double total = 0.0 + * cdef int n_samples = self.n_samples */ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7sklearn_4tree_5_tree_Entropy *__pyx_v_self) { + int __pyx_v_n_samples; + int __pyx_v_n_outputs; + int *__pyx_v_n_classes; + int __pyx_v_label_count_stride; + int *__pyx_v_label_count_left; + int *__pyx_v_label_count_right; + double __pyx_v_n_left; + double __pyx_v_n_right; double __pyx_v_total; double __pyx_v_H_left; double __pyx_v_H_right; @@ -3063,8 +3255,6 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle int __pyx_v_c; double __pyx_v_e1; double __pyx_v_e2; - double __pyx_v_n_left; - double __pyx_v_n_right; double __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -3072,152 +3262,206 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":273 + /* "sklearn/tree/_tree.pyx":311 * cdef double eval(self): * """Returns Entropy of left branch + Entropy index of right branch. """ - * cdef double total = 0.0 # <<<<<<<<<<<<<< - * cdef double H_left - * cdef double H_right + * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes */ - __pyx_v_total = 0.0; + __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; - /* "sklearn/tree/_tree.pyx":278 - * cdef int k, c - * cdef double e1, e2 + /* "sklearn/tree/_tree.pyx":312 + * """Returns Entropy of left branch + Entropy index of right branch. """ + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + */ + __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; + + /* "sklearn/tree/_tree.pyx":313 + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + */ + __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; + + /* "sklearn/tree/_tree.pyx":314 + * cdef int n_outputs = self.n_outputs + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right + */ + __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; + + /* "sklearn/tree/_tree.pyx":315 + * cdef int* n_classes = self.n_classes + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< + * cdef int* label_count_right = self.label_count_right + * cdef double n_left = self.n_left + */ + __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; + + /* "sklearn/tree/_tree.pyx":316 + * cdef int label_count_stride = self.label_count_stride + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< + * cdef double n_left = self.n_left + * cdef double n_right = self.n_right + */ + __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; + + /* "sklearn/tree/_tree.pyx":317 + * cdef int* label_count_left = self.label_count_left + * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< * cdef double n_right = self.n_right * */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":279 - * cdef double e1, e2 + /* "sklearn/tree/_tree.pyx":318 + * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * cdef double total = 0.0 */ __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); - /* "sklearn/tree/_tree.pyx":281 + /* "sklearn/tree/_tree.pyx":320 * cdef double n_right = self.n_right * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< + * cdef double total = 0.0 # <<<<<<<<<<<<<< + * cdef double H_left + * cdef double H_right + */ + __pyx_v_total = 0.0; + + /* "sklearn/tree/_tree.pyx":326 + * cdef double e1, e2 + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< * H_left = 0.0 * H_right = 0.0 */ - __pyx_t_1 = __pyx_v_self->__pyx_base.n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":282 + /* "sklearn/tree/_tree.pyx":327 * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: * H_left = 0.0 # <<<<<<<<<<<<<< * H_right = 0.0 * */ __pyx_v_H_left = 0.0; - /* "sklearn/tree/_tree.pyx":283 - * for k from 0 <= k < self.n_outputs: + /* "sklearn/tree/_tree.pyx":328 + * for k from 0 <= k < n_outputs: * H_left = 0.0 * H_right = 0.0 # <<<<<<<<<<<<<< * - * for c from 0 <= c < self.n_classes[k]: + * for c from 0 <= c < n_classes[k]: */ __pyx_v_H_right = 0.0; - /* "sklearn/tree/_tree.pyx":285 + /* "sklearn/tree/_tree.pyx":330 * H_right = 0.0 * - * for c from 0 <= c < self.n_classes[k]: # <<<<<<<<<<<<<< - * if self.label_count_left[k * self.count_stride + c] > 0: - * H_left -= ((self.label_count_left[k * self.count_stride + c] / n_left) + * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< + * if label_count_left[k * label_count_stride + c] > 0: + * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) */ - __pyx_t_2 = (__pyx_v_self->__pyx_base.n_classes[__pyx_v_k]); + __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":286 + /* "sklearn/tree/_tree.pyx":331 + * + * for c from 0 <= c < n_classes[k]: + * if label_count_left[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< + * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) * - * for c from 0 <= c < self.n_classes[k]: - * if self.label_count_left[k * self.count_stride + c] > 0: # <<<<<<<<<<<<<< - * H_left -= ((self.label_count_left[k * self.count_stride + c] / n_left) - * * log(self.label_count_left[k * self.count_stride + c] / n_left)) */ - __pyx_t_3 = ((__pyx_v_self->__pyx_base.label_count_left[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) > 0); + __pyx_t_3 = ((__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":288 - * if self.label_count_left[k * self.count_stride + c] > 0: - * H_left -= ((self.label_count_left[k * self.count_stride + c] / n_left) - * * log(self.label_count_left[k * self.count_stride + c] / n_left)) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":332 + * for c from 0 <= c < n_classes[k]: + * if label_count_left[k * label_count_stride + c] > 0: + * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) # <<<<<<<<<<<<<< * - * if self.label_count_right[k * self.count_stride + c] > 0: + * if self.label_count_right[k * label_count_stride + c] > 0: */ - __pyx_v_H_left = (__pyx_v_H_left - (((__pyx_v_self->__pyx_base.label_count_left[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) / __pyx_v_n_left) * log(((__pyx_v_self->__pyx_base.label_count_left[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) / __pyx_v_n_left)))); + __pyx_v_H_left = (__pyx_v_H_left - (((__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) / __pyx_v_n_left) * log(((__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) / __pyx_v_n_left)))); goto __pyx_L7; } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":290 - * * log(self.label_count_left[k * self.count_stride + c] / n_left)) + /* "sklearn/tree/_tree.pyx":334 + * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) + * + * if self.label_count_right[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< + * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) * - * if self.label_count_right[k * self.count_stride + c] > 0: # <<<<<<<<<<<<<< - * H_right -= ((self.label_count_right[k * self.count_stride + c] / n_right) - * * log(self.label_count_right[k * self.count_stride + c] / n_right)) */ - __pyx_t_3 = ((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) > 0); + __pyx_t_3 = ((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":292 - * if self.label_count_right[k * self.count_stride + c] > 0: - * H_right -= ((self.label_count_right[k * self.count_stride + c] / n_right) - * * log(self.label_count_right[k * self.count_stride + c] / n_right)) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":335 * - * e1 = (n_left / self.n_samples) * H_left + * if self.label_count_right[k * label_count_stride + c] > 0: + * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) # <<<<<<<<<<<<<< + * + * e1 = (n_left / n_samples) * H_left */ - __pyx_v_H_right = (__pyx_v_H_right - (((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) / __pyx_v_n_right) * log(((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_self->__pyx_base.count_stride) + __pyx_v_c)]) / __pyx_v_n_right)))); + __pyx_v_H_right = (__pyx_v_H_right - (((__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) / __pyx_v_n_right) * log(((__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) / __pyx_v_n_right)))); goto __pyx_L8; } __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":294 - * * log(self.label_count_right[k * self.count_stride + c] / n_right)) + /* "sklearn/tree/_tree.pyx":337 + * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) * - * e1 = (n_left / self.n_samples) * H_left # <<<<<<<<<<<<<< - * e2 = (n_right / self.n_samples) * H_right + * e1 = (n_left / n_samples) * H_left # <<<<<<<<<<<<<< + * e2 = (n_right / n_samples) * H_right * */ - __pyx_v_e1 = ((__pyx_v_n_left / __pyx_v_self->__pyx_base.n_samples) * __pyx_v_H_left); + __pyx_v_e1 = ((__pyx_v_n_left / __pyx_v_n_samples) * __pyx_v_H_left); - /* "sklearn/tree/_tree.pyx":295 + /* "sklearn/tree/_tree.pyx":338 * - * e1 = (n_left / self.n_samples) * H_left - * e2 = (n_right / self.n_samples) * H_right # <<<<<<<<<<<<<< + * e1 = (n_left / n_samples) * H_left + * e2 = (n_right / n_samples) * H_right # <<<<<<<<<<<<<< * * total += e1 + e2 */ - __pyx_v_e2 = ((__pyx_v_n_right / __pyx_v_self->__pyx_base.n_samples) * __pyx_v_H_right); + __pyx_v_e2 = ((__pyx_v_n_right / __pyx_v_n_samples) * __pyx_v_H_right); - /* "sklearn/tree/_tree.pyx":297 - * e2 = (n_right / self.n_samples) * H_right + /* "sklearn/tree/_tree.pyx":340 + * e2 = (n_right / n_samples) * H_right * * total += e1 + e2 # <<<<<<<<<<<<<< * - * return total / self.n_outputs + * return total / n_outputs */ __pyx_v_total = (__pyx_v_total + (__pyx_v_e1 + __pyx_v_e2)); } - /* "sklearn/tree/_tree.pyx":299 + /* "sklearn/tree/_tree.pyx":342 * total += e1 + e2 * - * return total / self.n_outputs # <<<<<<<<<<<<<< + * return total / n_outputs # <<<<<<<<<<<<<< * * */ - __pyx_r = (__pyx_v_total / __pyx_v_self->__pyx_base.n_outputs); + __pyx_r = (__pyx_v_total / __pyx_v_n_outputs); goto __pyx_L0; __pyx_r = 0; @@ -3229,8 +3473,8 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle /* Python wrapper */ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_y = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,0}; + int __pyx_v_n_outputs; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__n_outputs,0}; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); @@ -3247,197 +3491,67 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); + values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_outputs); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_y = ((PyArrayObject *)values[0]); + __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self), __pyx_v_y); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self), __pyx_v_n_outputs); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":367 - * cdef ndarray_var_right +/* "sklearn/tree/_tree.pyx":399 + * cdef int n_left * - * def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): # <<<<<<<<<<<<<< + * def __init__(self, int n_outputs): # <<<<<<<<<<<<<< * cdef int k = 0 * */ -static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, PyArrayObject *__pyx_v_y) { +static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_v_n_outputs) { CYTHON_UNUSED int __pyx_v_k; - PyArrayObject *__pyx_v_ndarray_mean_left = 0; - CYTHON_UNUSED PyArrayObject *__pyx_v_ndarray_mean_right = 0; - PyArrayObject *__pyx_v_ndarray_mean_init = 0; - PyArrayObject *__pyx_v_ndarray_sq_sum_left = 0; - PyArrayObject *__pyx_v_ndarray_sq_sum_right = 0; - PyArrayObject *__pyx_v_ndarray_sq_sum_init = 0; - PyArrayObject *__pyx_v_ndarray_var_left = 0; - CYTHON_UNUSED PyArrayObject *__pyx_v_ndarray_var_right = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_mean_init; - __Pyx_Buffer __pyx_pybuffer_ndarray_mean_init; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_mean_left; - __Pyx_Buffer __pyx_pybuffer_ndarray_mean_left; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_mean_right; - __Pyx_Buffer __pyx_pybuffer_ndarray_mean_right; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_sq_sum_init; - __Pyx_Buffer __pyx_pybuffer_ndarray_sq_sum_init; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_sq_sum_left; - __Pyx_Buffer __pyx_pybuffer_ndarray_sq_sum_left; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_sq_sum_right; - __Pyx_Buffer __pyx_pybuffer_ndarray_sq_sum_right; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_var_left; - __Pyx_Buffer __pyx_pybuffer_ndarray_var_left; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ndarray_var_right; - __Pyx_Buffer __pyx_pybuffer_ndarray_var_right; - __Pyx_LocalBuf_ND __pyx_pybuffernd_y; - __Pyx_Buffer __pyx_pybuffer_y; int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyArrayObject *__pyx_t_6 = NULL; - PyArrayObject *__pyx_t_7 = NULL; - PyArrayObject *__pyx_t_8 = NULL; - PyArrayObject *__pyx_t_9 = NULL; - PyArrayObject *__pyx_t_10 = NULL; - PyArrayObject *__pyx_t_11 = NULL; - PyArrayObject *__pyx_t_12 = NULL; - PyArrayObject *__pyx_t_13 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - __pyx_pybuffer_ndarray_mean_left.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_mean_left.refcount = 0; - __pyx_pybuffernd_ndarray_mean_left.data = NULL; - __pyx_pybuffernd_ndarray_mean_left.rcbuffer = &__pyx_pybuffer_ndarray_mean_left; - __pyx_pybuffer_ndarray_mean_right.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_mean_right.refcount = 0; - __pyx_pybuffernd_ndarray_mean_right.data = NULL; - __pyx_pybuffernd_ndarray_mean_right.rcbuffer = &__pyx_pybuffer_ndarray_mean_right; - __pyx_pybuffer_ndarray_mean_init.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_mean_init.refcount = 0; - __pyx_pybuffernd_ndarray_mean_init.data = NULL; - __pyx_pybuffernd_ndarray_mean_init.rcbuffer = &__pyx_pybuffer_ndarray_mean_init; - __pyx_pybuffer_ndarray_sq_sum_left.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_sq_sum_left.refcount = 0; - __pyx_pybuffernd_ndarray_sq_sum_left.data = NULL; - __pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer = &__pyx_pybuffer_ndarray_sq_sum_left; - __pyx_pybuffer_ndarray_sq_sum_right.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_sq_sum_right.refcount = 0; - __pyx_pybuffernd_ndarray_sq_sum_right.data = NULL; - __pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer = &__pyx_pybuffer_ndarray_sq_sum_right; - __pyx_pybuffer_ndarray_sq_sum_init.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_sq_sum_init.refcount = 0; - __pyx_pybuffernd_ndarray_sq_sum_init.data = NULL; - __pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer = &__pyx_pybuffer_ndarray_sq_sum_init; - __pyx_pybuffer_ndarray_var_left.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_var_left.refcount = 0; - __pyx_pybuffernd_ndarray_var_left.data = NULL; - __pyx_pybuffernd_ndarray_var_left.rcbuffer = &__pyx_pybuffer_ndarray_var_left; - __pyx_pybuffer_ndarray_var_right.pybuffer.buf = NULL; - __pyx_pybuffer_ndarray_var_right.refcount = 0; - __pyx_pybuffernd_ndarray_var_right.data = NULL; - __pyx_pybuffernd_ndarray_var_right.rcbuffer = &__pyx_pybuffer_ndarray_var_right; - __pyx_pybuffer_y.pybuffer.buf = NULL; - __pyx_pybuffer_y.refcount = 0; - __pyx_pybuffernd_y.data = NULL; - __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; - /* "sklearn/tree/_tree.pyx":368 + /* "sklearn/tree/_tree.pyx":400 * - * def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): + * def __init__(self, int n_outputs): * cdef int k = 0 # <<<<<<<<<<<<<< * - * if y.ndim == 2: + * self.n_outputs = n_outputs */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":370 + /* "sklearn/tree/_tree.pyx":402 * cdef int k = 0 * - * if y.ndim == 2: # <<<<<<<<<<<<<< - * self.y_stride = y.strides[1] / y.strides[0] - * self.n_outputs = y.shape[1] - */ - __pyx_t_1 = (__pyx_v_y->nd == 2); - if (__pyx_t_1) { - - /* "sklearn/tree/_tree.pyx":371 - * - * if y.ndim == 2: - * self.y_stride = y.strides[1] / y.strides[0] # <<<<<<<<<<<<<< - * self.n_outputs = y.shape[1] - * else: - */ - __pyx_v_self->y_stride = ((__pyx_v_y->strides[1]) / (__pyx_v_y->strides[0])); - - /* "sklearn/tree/_tree.pyx":372 - * if y.ndim == 2: - * self.y_stride = y.strides[1] / y.strides[0] - * self.n_outputs = y.shape[1] # <<<<<<<<<<<<<< - * else: - * self.y_stride = 1 - */ - __pyx_v_self->n_outputs = (__pyx_v_y->dimensions[1]); - goto __pyx_L3; - } - /*else*/ { - - /* "sklearn/tree/_tree.pyx":374 - * self.n_outputs = y.shape[1] - * else: - * self.y_stride = 1 # <<<<<<<<<<<<<< - * self.n_outputs = 1 - * - */ - __pyx_v_self->y_stride = 1; - - /* "sklearn/tree/_tree.pyx":375 - * else: - * self.y_stride = 1 - * self.n_outputs = 1 # <<<<<<<<<<<<<< + * self.n_outputs = n_outputs # <<<<<<<<<<<<<< * * self.n_samples = 0 */ - __pyx_v_self->n_outputs = 1; - } - __pyx_L3:; + __pyx_v_self->n_outputs = __pyx_v_n_outputs; - /* "sklearn/tree/_tree.pyx":377 - * self.n_outputs = 1 + /* "sklearn/tree/_tree.pyx":404 + * self.n_outputs = n_outputs * * self.n_samples = 0 # <<<<<<<<<<<<<< * self.n_left = 0 @@ -3445,7 +3559,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_samples = 0; - /* "sklearn/tree/_tree.pyx":378 + /* "sklearn/tree/_tree.pyx":405 * * self.n_samples = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -3454,644 +3568,397 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":379 + /* "sklearn/tree/_tree.pyx":406 * self.n_samples = 0 * self.n_left = 0 * self.n_right = 0 # <<<<<<<<<<<<<< * - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + * self.mean_left = calloc(n_outputs, sizeof(double)) */ __pyx_v_self->n_right = 0; - /* "sklearn/tree/_tree.pyx":381 + /* "sklearn/tree/_tree.pyx":408 * self.n_right = 0 * - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + * self.mean_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.mean_right = calloc(n_outputs, sizeof(double)) + * self.mean_init = calloc(n_outputs, sizeof(double)) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_GIVEREF(__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 = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __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_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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 = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_mean_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_mean_left.diminfo[0].strides = __pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_mean_left.diminfo[0].shape = __pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_6 = 0; - __pyx_v_ndarray_mean_left = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_self->mean_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":382 + /* "sklearn/tree/_tree.pyx":409 * - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + * self.mean_left = calloc(n_outputs, sizeof(double)) + * self.mean_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.mean_init = calloc(n_outputs, sizeof(double)) + * self.sq_sum_left = calloc(n_outputs, sizeof(double)) */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); - __Pyx_GIVEREF(__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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_t_2 = 0; - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __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 = 382; __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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 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 = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = ((PyArrayObject *)__pyx_t_3); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_mean_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_mean_right.diminfo[0].strides = __pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_mean_right.diminfo[0].shape = __pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_7 = 0; - __pyx_v_ndarray_mean_right = ((PyArrayObject *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_v_self->mean_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":383 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + /* "sklearn/tree/_tree.pyx":410 + * self.mean_left = calloc(n_outputs, sizeof(double)) + * self.mean_right = calloc(n_outputs, sizeof(double)) + * self.mean_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.sq_sum_left = calloc(n_outputs, sizeof(double)) + * self.sq_sum_right = calloc(n_outputs, sizeof(double)) */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); - __Pyx_GIVEREF(__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 = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); - __pyx_t_5 = 0; - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = ((PyArrayObject *)__pyx_t_4); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_mean_init = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_mean_init.diminfo[0].strides = __pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_mean_init.diminfo[0].shape = __pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_8 = 0; - __pyx_v_ndarray_mean_init = ((PyArrayObject *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_v_self->mean_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":384 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + /* "sklearn/tree/_tree.pyx":411 + * self.mean_right = calloc(n_outputs, sizeof(double)) + * self.mean_init = calloc(n_outputs, sizeof(double)) + * self.sq_sum_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.sq_sum_right = calloc(n_outputs, sizeof(double)) + * self.sq_sum_init = calloc(n_outputs, sizeof(double)) */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __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 = 384; __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 = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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 = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = ((PyArrayObject *)__pyx_t_2); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_sq_sum_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_sq_sum_left.diminfo[0].strides = __pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_sq_sum_left.diminfo[0].shape = __pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_9 = 0; - __pyx_v_ndarray_sq_sum_left = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_v_self->sq_sum_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":385 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + /* "sklearn/tree/_tree.pyx":412 + * self.mean_init = calloc(n_outputs, sizeof(double)) + * self.sq_sum_left = calloc(n_outputs, sizeof(double)) + * self.sq_sum_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.sq_sum_init = calloc(n_outputs, sizeof(double)) + * self.var_left = calloc(n_outputs, sizeof(double)) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_GIVEREF(__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 = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__C)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __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_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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 = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_10 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_sq_sum_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_sq_sum_right.diminfo[0].strides = __pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_sq_sum_right.diminfo[0].shape = __pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_10 = 0; - __pyx_v_ndarray_sq_sum_right = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_self->sq_sum_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":386 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + /* "sklearn/tree/_tree.pyx":413 + * self.sq_sum_left = calloc(n_outputs, sizeof(double)) + * self.sq_sum_right = calloc(n_outputs, sizeof(double)) + * self.sq_sum_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.var_left = calloc(n_outputs, sizeof(double)) + * self.var_right = calloc(n_outputs, sizeof(double)) */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); - __Pyx_GIVEREF(__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 = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_t_2 = 0; - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __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 = 386; __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 = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 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 = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_11 = ((PyArrayObject *)__pyx_t_3); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_sq_sum_init = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_sq_sum_init.diminfo[0].strides = __pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_sq_sum_init.diminfo[0].shape = __pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_11 = 0; - __pyx_v_ndarray_sq_sum_init = ((PyArrayObject *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_v_self->sq_sum_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":387 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") + /* "sklearn/tree/_tree.pyx":414 + * self.sq_sum_right = calloc(n_outputs, sizeof(double)) + * self.sq_sum_init = calloc(n_outputs, sizeof(double)) + * self.var_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< + * self.var_right = calloc(n_outputs, sizeof(double)) * */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); - __Pyx_GIVEREF(__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 = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); - __pyx_t_5 = 0; - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_12 = ((PyArrayObject *)__pyx_t_4); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_var_left = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_var_left.diminfo[0].strides = __pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_var_left.diminfo[0].shape = __pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_12 = 0; - __pyx_v_ndarray_var_left = ((PyArrayObject *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_v_self->var_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":388 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":415 + * self.sq_sum_init = calloc(n_outputs, sizeof(double)) + * self.var_left = calloc(n_outputs, sizeof(double)) + * self.var_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< * - * self.mean_left = ndarray_mean_left.data + * def __del__(self): */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyInt_FromLong(__pyx_v_self->n_outputs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __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 = 388; __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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_13 = ((PyArrayObject *)__pyx_t_2); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ndarray_var_right = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_ndarray_var_right.diminfo[0].strides = __pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ndarray_var_right.diminfo[0].shape = __pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_13 = 0; - __pyx_v_ndarray_var_right = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_v_self->var_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "sklearn/tree/_tree.pyx":390 - * cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") +/* "sklearn/tree/_tree.pyx":417 + * self.var_right = calloc(n_outputs, sizeof(double)) * - * self.mean_left = ndarray_mean_left.data # <<<<<<<<<<<<<< - * self.mean_right = ndarray_mean_left.data - * self.mean_init = ndarray_mean_init.data + * def __del__(self): # <<<<<<<<<<<<<< + * free(self.mean_left) + * free(self.mean_right) */ - __pyx_v_self->mean_left = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_mean_left->data); - /* "sklearn/tree/_tree.pyx":391 +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__", 0); + + /* "sklearn/tree/_tree.pyx":418 * - * self.mean_left = ndarray_mean_left.data - * self.mean_right = ndarray_mean_left.data # <<<<<<<<<<<<<< - * self.mean_init = ndarray_mean_init.data - * self.sq_sum_right = ndarray_sq_sum_left.data + * def __del__(self): + * free(self.mean_left) # <<<<<<<<<<<<<< + * free(self.mean_right) + * free(self.mean_init) */ - __pyx_v_self->mean_right = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_mean_left->data); + free(__pyx_v_self->mean_left); - /* "sklearn/tree/_tree.pyx":392 - * self.mean_left = ndarray_mean_left.data - * self.mean_right = ndarray_mean_left.data - * self.mean_init = ndarray_mean_init.data # <<<<<<<<<<<<<< - * self.sq_sum_right = ndarray_sq_sum_left.data - * self.sq_sum_left = ndarray_sq_sum_right.data + /* "sklearn/tree/_tree.pyx":419 + * def __del__(self): + * free(self.mean_left) + * free(self.mean_right) # <<<<<<<<<<<<<< + * free(self.mean_init) + * free(self.sq_sum_left) */ - __pyx_v_self->mean_init = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_mean_init->data); + free(__pyx_v_self->mean_right); - /* "sklearn/tree/_tree.pyx":393 - * self.mean_right = ndarray_mean_left.data - * self.mean_init = ndarray_mean_init.data - * self.sq_sum_right = ndarray_sq_sum_left.data # <<<<<<<<<<<<<< - * self.sq_sum_left = ndarray_sq_sum_right.data - * self.sq_sum_init = ndarray_sq_sum_init.data + /* "sklearn/tree/_tree.pyx":420 + * free(self.mean_left) + * free(self.mean_right) + * free(self.mean_init) # <<<<<<<<<<<<<< + * free(self.sq_sum_left) + * free(self.sq_sum_right) */ - __pyx_v_self->sq_sum_right = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_sq_sum_left->data); + free(__pyx_v_self->mean_init); - /* "sklearn/tree/_tree.pyx":394 - * self.mean_init = ndarray_mean_init.data - * self.sq_sum_right = ndarray_sq_sum_left.data - * self.sq_sum_left = ndarray_sq_sum_right.data # <<<<<<<<<<<<<< - * self.sq_sum_init = ndarray_sq_sum_init.data - * self.var_left = ndarray_var_left.data + /* "sklearn/tree/_tree.pyx":421 + * free(self.mean_right) + * free(self.mean_init) + * free(self.sq_sum_left) # <<<<<<<<<<<<<< + * free(self.sq_sum_right) + * free(self.sq_sum_init) */ - __pyx_v_self->sq_sum_left = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_sq_sum_right->data); + free(__pyx_v_self->sq_sum_left); - /* "sklearn/tree/_tree.pyx":395 - * self.sq_sum_right = ndarray_sq_sum_left.data - * self.sq_sum_left = ndarray_sq_sum_right.data - * self.sq_sum_init = ndarray_sq_sum_init.data # <<<<<<<<<<<<<< - * self.var_left = ndarray_var_left.data - * self.var_right = ndarray_var_left.data + /* "sklearn/tree/_tree.pyx":422 + * free(self.mean_init) + * free(self.sq_sum_left) + * free(self.sq_sum_right) # <<<<<<<<<<<<<< + * free(self.sq_sum_init) + * free(self.var_left) */ - __pyx_v_self->sq_sum_init = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_sq_sum_init->data); + free(__pyx_v_self->sq_sum_right); - /* "sklearn/tree/_tree.pyx":396 - * self.sq_sum_left = ndarray_sq_sum_right.data - * self.sq_sum_init = ndarray_sq_sum_init.data - * self.var_left = ndarray_var_left.data # <<<<<<<<<<<<<< - * self.var_right = ndarray_var_left.data + /* "sklearn/tree/_tree.pyx":423 + * free(self.sq_sum_left) + * free(self.sq_sum_right) + * free(self.sq_sum_init) # <<<<<<<<<<<<<< + * free(self.var_left) + * free(self.var_right) + */ + free(__pyx_v_self->sq_sum_init); + + /* "sklearn/tree/_tree.pyx":424 + * free(self.sq_sum_right) + * free(self.sq_sum_init) + * free(self.var_left) # <<<<<<<<<<<<<< + * free(self.var_right) * */ - __pyx_v_self->var_left = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_var_left->data); + free(__pyx_v_self->var_left); - /* "sklearn/tree/_tree.pyx":397 - * self.sq_sum_init = ndarray_sq_sum_init.data - * self.var_left = ndarray_var_left.data - * self.var_right = ndarray_var_left.data # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":425 + * free(self.sq_sum_init) + * free(self.var_left) + * free(self.var_right) # <<<<<<<<<<<<<< * - * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, + * cdef void init(self, DTYPE_t* y, */ - __pyx_v_self->var_right = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_ndarray_var_left->data); + free(__pyx_v_self->var_right); - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_mean_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_init.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_sq_sum_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_var_left.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ndarray_var_right.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_mean_left); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_mean_right); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_mean_init); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_sq_sum_left); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_sq_sum_right); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_sq_sum_init); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_var_left); - __Pyx_XDECREF((PyObject *)__pyx_v_ndarray_var_right); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":399 - * self.var_right = ndarray_var_left.data +/* "sklearn/tree/_tree.pyx":427 + * free(self.var_right) + * + * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< + * int y_stride, + * BOOL_t* sample_mask, + */ + +static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int __pyx_v_y_stride, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { + double *__pyx_v_mean_left; + double *__pyx_v_mean_right; + double *__pyx_v_mean_init; + double *__pyx_v_sq_sum_left; + double *__pyx_v_sq_sum_right; + double *__pyx_v_sq_sum_init; + double *__pyx_v_var_left; + double *__pyx_v_var_right; + int __pyx_v_n_outputs; + int __pyx_v_k; + int __pyx_v_j; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_y_jk; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("init", 0); + + /* "sklearn/tree/_tree.pyx":435 + * are in the right branch and store the mean and squared + * sum in `self.mean_init` and `self.sq_sum_init`. """ + * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init + */ + __pyx_v_mean_left = __pyx_v_self->mean_left; + + /* "sklearn/tree/_tree.pyx":436 + * sum in `self.mean_init` and `self.sq_sum_init`. """ + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left + */ + __pyx_v_mean_right = __pyx_v_self->mean_right; + + /* "sklearn/tree/_tree.pyx":437 + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + */ + __pyx_v_mean_init = __pyx_v_self->mean_init; + + /* "sklearn/tree/_tree.pyx":438 + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init + */ + __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; + + /* "sklearn/tree/_tree.pyx":439 + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left + */ + __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; + + /* "sklearn/tree/_tree.pyx":440 + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right + */ + __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; + + /* "sklearn/tree/_tree.pyx":441 + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< + * cdef double* var_right = self.var_right + * cdef int n_outputs = self.n_outputs + */ + __pyx_v_var_left = __pyx_v_self->var_left; + + /* "sklearn/tree/_tree.pyx":442 + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs * - * cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, # <<<<<<<<<<<<<< - * int n_total_samples): - * """Initialise the criterion class; assume all samples */ + __pyx_v_var_right = __pyx_v_self->var_right; -static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask, int __pyx_v_n_samples, int __pyx_v_n_total_samples) { - int __pyx_v_k; - int __pyx_v_j; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - __Pyx_RefNannySetupContext("init", 0); + /* "sklearn/tree/_tree.pyx":443 + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * + * cdef int k = 0 + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":404 - * are in the right branch and store the mean and squared - * sum in `self.mean_init` and `self.sq_sum_init`. """ + /* "sklearn/tree/_tree.pyx":445 + * cdef int n_outputs = self.n_outputs + * * cdef int k = 0 # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":406 + /* "sklearn/tree/_tree.pyx":447 * cdef int k = 0 * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * self.mean_left[k] = 0.0 - * self.mean_right[k] = 0.0 + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * mean_left[k] = 0.0 + * mean_right[k] = 0.0 */ - __pyx_t_1 = __pyx_v_self->n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":407 + /* "sklearn/tree/_tree.pyx":448 * - * for k from 0 <= k < self.n_outputs: - * self.mean_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.mean_right[k] = 0.0 - * self.mean_init[k] = 0.0 + * for k from 0 <= k < n_outputs: + * mean_left[k] = 0.0 # <<<<<<<<<<<<<< + * mean_right[k] = 0.0 + * mean_init[k] = 0.0 */ - (__pyx_v_self->mean_left[__pyx_v_k]) = 0.0; + (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":408 - * for k from 0 <= k < self.n_outputs: - * self.mean_left[k] = 0.0 - * self.mean_right[k] = 0.0 # <<<<<<<<<<<<<< - * self.mean_init[k] = 0.0 - * self.sq_sum_right[k] = 0.0 + /* "sklearn/tree/_tree.pyx":449 + * for k from 0 <= k < n_outputs: + * mean_left[k] = 0.0 + * mean_right[k] = 0.0 # <<<<<<<<<<<<<< + * mean_init[k] = 0.0 + * sq_sum_right[k] = 0.0 */ - (__pyx_v_self->mean_right[__pyx_v_k]) = 0.0; + (__pyx_v_mean_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":409 - * self.mean_left[k] = 0.0 - * self.mean_right[k] = 0.0 - * self.mean_init[k] = 0.0 # <<<<<<<<<<<<<< - * self.sq_sum_right[k] = 0.0 - * self.sq_sum_left[k] = 0.0 + /* "sklearn/tree/_tree.pyx":450 + * mean_left[k] = 0.0 + * mean_right[k] = 0.0 + * mean_init[k] = 0.0 # <<<<<<<<<<<<<< + * sq_sum_right[k] = 0.0 + * sq_sum_left[k] = 0.0 */ - (__pyx_v_self->mean_init[__pyx_v_k]) = 0.0; + (__pyx_v_mean_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":410 - * self.mean_right[k] = 0.0 - * self.mean_init[k] = 0.0 - * self.sq_sum_right[k] = 0.0 # <<<<<<<<<<<<<< - * self.sq_sum_left[k] = 0.0 - * self.sq_sum_init[k] = 0.0 + /* "sklearn/tree/_tree.pyx":451 + * mean_right[k] = 0.0 + * mean_init[k] = 0.0 + * sq_sum_right[k] = 0.0 # <<<<<<<<<<<<<< + * sq_sum_left[k] = 0.0 + * sq_sum_init[k] = 0.0 */ - (__pyx_v_self->sq_sum_right[__pyx_v_k]) = 0.0; + (__pyx_v_sq_sum_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":411 - * self.mean_init[k] = 0.0 - * self.sq_sum_right[k] = 0.0 - * self.sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.sq_sum_init[k] = 0.0 - * self.var_left[k] = 0.0 + /* "sklearn/tree/_tree.pyx":452 + * mean_init[k] = 0.0 + * sq_sum_right[k] = 0.0 + * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< + * sq_sum_init[k] = 0.0 + * var_left[k] = 0.0 */ - (__pyx_v_self->sq_sum_left[__pyx_v_k]) = 0.0; + (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":412 - * self.sq_sum_right[k] = 0.0 - * self.sq_sum_left[k] = 0.0 - * self.sq_sum_init[k] = 0.0 # <<<<<<<<<<<<<< - * self.var_left[k] = 0.0 - * self.var_right[k] = 0.0 + /* "sklearn/tree/_tree.pyx":453 + * sq_sum_right[k] = 0.0 + * sq_sum_left[k] = 0.0 + * sq_sum_init[k] = 0.0 # <<<<<<<<<<<<<< + * var_left[k] = 0.0 + * var_right[k] = 0.0 */ - (__pyx_v_self->sq_sum_init[__pyx_v_k]) = 0.0; + (__pyx_v_sq_sum_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":413 - * self.sq_sum_left[k] = 0.0 - * self.sq_sum_init[k] = 0.0 - * self.var_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.var_right[k] = 0.0 + /* "sklearn/tree/_tree.pyx":454 + * sq_sum_left[k] = 0.0 + * sq_sum_init[k] = 0.0 + * var_left[k] = 0.0 # <<<<<<<<<<<<<< + * var_right[k] = 0.0 * */ - (__pyx_v_self->var_left[__pyx_v_k]) = 0.0; + (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":414 - * self.sq_sum_init[k] = 0.0 - * self.var_left[k] = 0.0 - * self.var_right[k] = 0.0 # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":455 + * sq_sum_init[k] = 0.0 + * var_left[k] = 0.0 + * var_right[k] = 0.0 # <<<<<<<<<<<<<< * * self.n_samples = n_samples */ - (__pyx_v_self->var_right[__pyx_v_k]) = 0.0; + (__pyx_v_var_right[__pyx_v_k]) = 0.0; } - /* "sklearn/tree/_tree.pyx":416 - * self.var_right[k] = 0.0 + /* "sklearn/tree/_tree.pyx":457 + * var_right[k] = 0.0 * * self.n_samples = n_samples # <<<<<<<<<<<<<< * @@ -4099,91 +3966,121 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_self->n_samples = __pyx_v_n_samples; - /* "sklearn/tree/_tree.pyx":418 + /* "sklearn/tree/_tree.pyx":459 * self.n_samples = n_samples * * cdef int j = 0 # <<<<<<<<<<<<<< + * cdef DTYPE_t y_jk = 0.0 * - * for k from 0 <= k < self.n_outputs: */ __pyx_v_j = 0; - /* "sklearn/tree/_tree.pyx":420 + /* "sklearn/tree/_tree.pyx":460 + * * cdef int j = 0 + * cdef DTYPE_t y_jk = 0.0 # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * for j from 0 <= j < n_total_samples: - * if sample_mask[j] == 0: + * for j from 0 <= j < n_total_samples: */ - __pyx_t_1 = __pyx_v_self->n_outputs; - for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { + __pyx_v_y_jk = 0.0; - /* "sklearn/tree/_tree.pyx":421 + /* "sklearn/tree/_tree.pyx":462 + * cdef DTYPE_t y_jk = 0.0 * - * for k from 0 <= k < self.n_outputs: - * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< - * if sample_mask[j] == 0: - * continue + * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< + * if sample_mask[j] == 0: + * continue */ - __pyx_t_2 = __pyx_v_n_total_samples; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_2; __pyx_v_j++) { + __pyx_t_1 = __pyx_v_n_total_samples; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_1; __pyx_v_j++) { - /* "sklearn/tree/_tree.pyx":422 - * for k from 0 <= k < self.n_outputs: - * for j from 0 <= j < n_total_samples: - * if sample_mask[j] == 0: # <<<<<<<<<<<<<< - * continue + /* "sklearn/tree/_tree.pyx":463 + * + * for j from 0 <= j < n_total_samples: + * if sample_mask[j] == 0: # <<<<<<<<<<<<<< + * continue * */ - __pyx_t_3 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); - if (__pyx_t_3) { + __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); + if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":423 - * for j from 0 <= j < n_total_samples: - * if sample_mask[j] == 0: - * continue # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":464 + * for j from 0 <= j < n_total_samples: + * if sample_mask[j] == 0: + * continue # <<<<<<<<<<<<<< * - * self.sq_sum_init[k] += (y[k * self.y_stride + j] * y[k * self.y_stride + j]) + * for k from 0 <= k < n_outputs: */ - goto __pyx_L7_continue; - goto __pyx_L9; - } - __pyx_L9:; + goto __pyx_L5_continue; + goto __pyx_L7; + } + __pyx_L7:; + + /* "sklearn/tree/_tree.pyx":466 + * continue + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * y_jk = y[j * y_stride + k] + * sq_sum_init[k] += y_jk * y_jk + */ + __pyx_t_3 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":425 - * continue + /* "sklearn/tree/_tree.pyx":467 * - * self.sq_sum_init[k] += (y[k * self.y_stride + j] * y[k * self.y_stride + j]) # <<<<<<<<<<<<<< - * self.mean_init[k] += y[k * self.y_stride + j] + * for k from 0 <= k < n_outputs: + * y_jk = y[j * y_stride + k] # <<<<<<<<<<<<<< + * sq_sum_init[k] += y_jk * y_jk + * mean_init[k] += y_jk + */ + __pyx_v_y_jk = (__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)]); + + /* "sklearn/tree/_tree.pyx":468 + * for k from 0 <= k < n_outputs: + * y_jk = y[j * y_stride + k] + * sq_sum_init[k] += y_jk * y_jk # <<<<<<<<<<<<<< + * mean_init[k] += y_jk * */ __pyx_t_4 = __pyx_v_k; - (__pyx_v_self->sq_sum_init[__pyx_t_4]) = ((__pyx_v_self->sq_sum_init[__pyx_t_4]) + ((__pyx_v_y[((__pyx_v_k * __pyx_v_self->y_stride) + __pyx_v_j)]) * (__pyx_v_y[((__pyx_v_k * __pyx_v_self->y_stride) + __pyx_v_j)]))); + (__pyx_v_sq_sum_init[__pyx_t_4]) = ((__pyx_v_sq_sum_init[__pyx_t_4]) + (__pyx_v_y_jk * __pyx_v_y_jk)); - /* "sklearn/tree/_tree.pyx":426 - * - * self.sq_sum_init[k] += (y[k * self.y_stride + j] * y[k * self.y_stride + j]) - * self.mean_init[k] += y[k * self.y_stride + j] # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":469 + * y_jk = y[j * y_stride + k] + * sq_sum_init[k] += y_jk * y_jk + * mean_init[k] += y_jk # <<<<<<<<<<<<<< * - * self.mean_init[k] = self.mean_init[k] / self.n_samples + * for k from 0 <= k < n_outputs: */ __pyx_t_4 = __pyx_v_k; - (__pyx_v_self->mean_init[__pyx_t_4]) = ((__pyx_v_self->mean_init[__pyx_t_4]) + (__pyx_v_y[((__pyx_v_k * __pyx_v_self->y_stride) + __pyx_v_j)])); - __pyx_L7_continue:; + (__pyx_v_mean_init[__pyx_t_4]) = ((__pyx_v_mean_init[__pyx_t_4]) + __pyx_v_y_jk); } + __pyx_L5_continue:; + } + + /* "sklearn/tree/_tree.pyx":471 + * mean_init[k] += y_jk + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * mean_init[k] /= n_samples + * + */ + __pyx_t_1 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":428 - * self.mean_init[k] += y[k * self.y_stride + j] + /* "sklearn/tree/_tree.pyx":472 * - * self.mean_init[k] = self.mean_init[k] / self.n_samples # <<<<<<<<<<<<<< + * for k from 0 <= k < n_outputs: + * mean_init[k] /= n_samples # <<<<<<<<<<<<<< * * self.reset() */ - (__pyx_v_self->mean_init[__pyx_v_k]) = ((__pyx_v_self->mean_init[__pyx_v_k]) / __pyx_v_self->n_samples); + __pyx_t_3 = __pyx_v_k; + (__pyx_v_mean_init[__pyx_t_3]) = ((__pyx_v_mean_init[__pyx_t_3]) / __pyx_v_n_samples); } - /* "sklearn/tree/_tree.pyx":430 - * self.mean_init[k] = self.mean_init[k] / self.n_samples + /* "sklearn/tree/_tree.pyx":474 + * mean_init[k] /= n_samples * * self.reset() # <<<<<<<<<<<<<< * @@ -4194,7 +4091,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":432 +/* "sklearn/tree/_tree.pyx":476 * self.reset() * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -4203,21 +4100,121 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { + double *__pyx_v_mean_left; + double *__pyx_v_mean_right; + double *__pyx_v_mean_init; + double *__pyx_v_sq_sum_left; + double *__pyx_v_sq_sum_right; + double *__pyx_v_sq_sum_init; + double *__pyx_v_var_left; + double *__pyx_v_var_right; + int __pyx_v_n_samples; + int __pyx_v_n_outputs; int __pyx_v_k; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("reset", 0); - /* "sklearn/tree/_tree.pyx":439 + /* "sklearn/tree/_tree.pyx":483 * right branch. * """ + * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init + */ + __pyx_v_mean_left = __pyx_v_self->mean_left; + + /* "sklearn/tree/_tree.pyx":484 + * """ + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left + */ + __pyx_v_mean_right = __pyx_v_self->mean_right; + + /* "sklearn/tree/_tree.pyx":485 + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + */ + __pyx_v_mean_init = __pyx_v_self->mean_init; + + /* "sklearn/tree/_tree.pyx":486 + * cdef double* mean_right = self.mean_right + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init + */ + __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; + + /* "sklearn/tree/_tree.pyx":487 + * cdef double* mean_init = self.mean_init + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left + */ + __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; + + /* "sklearn/tree/_tree.pyx":488 + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right + */ + __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; + + /* "sklearn/tree/_tree.pyx":489 + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< + * cdef double* var_right = self.var_right + * + */ + __pyx_v_var_left = __pyx_v_self->var_left; + + /* "sklearn/tree/_tree.pyx":490 + * cdef double* sq_sum_init = self.sq_sum_init + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< + * + * cdef int n_samples = self.n_samples + */ + __pyx_v_var_right = __pyx_v_self->var_right; + + /* "sklearn/tree/_tree.pyx":492 + * cdef double* var_right = self.var_right + * + * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs + * + */ + __pyx_v_n_samples = __pyx_v_self->n_samples; + + /* "sklearn/tree/_tree.pyx":493 + * + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * + * cdef int k = 0 + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":495 + * cdef int n_outputs = self.n_outputs + * * cdef int k = 0 # <<<<<<<<<<<<<< * * self.n_right = self.n_samples */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":441 + /* "sklearn/tree/_tree.pyx":497 * cdef int k = 0 * * self.n_right = self.n_samples # <<<<<<<<<<<<<< @@ -4226,92 +4223,102 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_self->n_right = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":442 + /* "sklearn/tree/_tree.pyx":498 * * self.n_right = self.n_samples * self.n_left = 0 # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":444 + /* "sklearn/tree/_tree.pyx":500 * self.n_left = 0 * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * self.mean_right[k] = self.mean_init[k] - * self.mean_left[k] = 0.0 + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * mean_right[k] = mean_init[k] + * mean_left[k] = 0.0 */ - __pyx_t_1 = __pyx_v_self->n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":445 + /* "sklearn/tree/_tree.pyx":501 * - * for k from 0 <= k < self.n_outputs: - * self.mean_right[k] = self.mean_init[k] # <<<<<<<<<<<<<< - * self.mean_left[k] = 0.0 - * self.sq_sum_right[k] = self.sq_sum_init[k] + * for k from 0 <= k < n_outputs: + * mean_right[k] = mean_init[k] # <<<<<<<<<<<<<< + * mean_left[k] = 0.0 + * sq_sum_right[k] = sq_sum_init[k] */ - (__pyx_v_self->mean_right[__pyx_v_k]) = (__pyx_v_self->mean_init[__pyx_v_k]); + (__pyx_v_mean_right[__pyx_v_k]) = (__pyx_v_mean_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":446 - * for k from 0 <= k < self.n_outputs: - * self.mean_right[k] = self.mean_init[k] - * self.mean_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.sq_sum_right[k] = self.sq_sum_init[k] - * self.sq_sum_left[k] = 0.0 + /* "sklearn/tree/_tree.pyx":502 + * for k from 0 <= k < n_outputs: + * mean_right[k] = mean_init[k] + * mean_left[k] = 0.0 # <<<<<<<<<<<<<< + * sq_sum_right[k] = sq_sum_init[k] + * sq_sum_left[k] = 0.0 */ - (__pyx_v_self->mean_left[__pyx_v_k]) = 0.0; + (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":447 - * self.mean_right[k] = self.mean_init[k] - * self.mean_left[k] = 0.0 - * self.sq_sum_right[k] = self.sq_sum_init[k] # <<<<<<<<<<<<<< - * self.sq_sum_left[k] = 0.0 - * self.var_left[k] = 0.0 + /* "sklearn/tree/_tree.pyx":503 + * mean_right[k] = mean_init[k] + * mean_left[k] = 0.0 + * sq_sum_right[k] = sq_sum_init[k] # <<<<<<<<<<<<<< + * sq_sum_left[k] = 0.0 + * var_left[k] = 0.0 */ - (__pyx_v_self->sq_sum_right[__pyx_v_k]) = (__pyx_v_self->sq_sum_init[__pyx_v_k]); + (__pyx_v_sq_sum_right[__pyx_v_k]) = (__pyx_v_sq_sum_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":448 - * self.mean_left[k] = 0.0 - * self.sq_sum_right[k] = self.sq_sum_init[k] - * self.sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.var_left[k] = 0.0 - * self.var_right[k] = self.sq_sum_right[k] - \ + /* "sklearn/tree/_tree.pyx":504 + * mean_left[k] = 0.0 + * sq_sum_right[k] = sq_sum_init[k] + * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< + * var_left[k] = 0.0 + * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) */ - (__pyx_v_self->sq_sum_left[__pyx_v_k]) = 0.0; + (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":449 - * self.sq_sum_right[k] = self.sq_sum_init[k] - * self.sq_sum_left[k] = 0.0 - * self.var_left[k] = 0.0 # <<<<<<<<<<<<<< - * self.var_right[k] = self.sq_sum_right[k] - \ - * self.n_samples * (self.mean_right[k] * self.mean_right[k]) + /* "sklearn/tree/_tree.pyx":505 + * sq_sum_right[k] = sq_sum_init[k] + * sq_sum_left[k] = 0.0 + * var_left[k] = 0.0 # <<<<<<<<<<<<<< + * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) + * */ - (__pyx_v_self->var_left[__pyx_v_k]) = 0.0; + (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":450 - * self.sq_sum_left[k] = 0.0 - * self.var_left[k] = 0.0 - * self.var_right[k] = self.sq_sum_right[k] - \ # <<<<<<<<<<<<<< - * self.n_samples * (self.mean_right[k] * self.mean_right[k]) + /* "sklearn/tree/_tree.pyx":506 + * sq_sum_left[k] = 0.0 + * var_left[k] = 0.0 + * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< * + * cdef int update(self, int a, */ - (__pyx_v_self->var_right[__pyx_v_k]) = ((__pyx_v_self->sq_sum_right[__pyx_v_k]) - (__pyx_v_self->n_samples * ((__pyx_v_self->mean_right[__pyx_v_k]) * (__pyx_v_self->mean_right[__pyx_v_k])))); + (__pyx_v_var_right[__pyx_v_k]) = ((__pyx_v_sq_sum_right[__pyx_v_k]) - (__pyx_v_n_samples * ((__pyx_v_mean_right[__pyx_v_k]) * (__pyx_v_mean_right[__pyx_v_k])))); } __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":453 - * self.n_samples * (self.mean_right[k] * self.mean_right[k]) +/* "sklearn/tree/_tree.pyx":508 + * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) * - * cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, # <<<<<<<<<<<<<< - * BOOL_t *sample_mask): - * """Update the criteria for each value in interval [a,b) (where a and b + * cdef int update(self, int a, # <<<<<<<<<<<<<< + * int b, + * DTYPE_t* y, */ -static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { +static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_v_a, int __pyx_v_b, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y, int __pyx_v_y_stride, int *__pyx_v_X_argsorted_i, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask) { + double *__pyx_v_mean_left; + double *__pyx_v_mean_right; + double *__pyx_v_sq_sum_left; + double *__pyx_v_sq_sum_right; + double *__pyx_v_var_left; + double *__pyx_v_var_right; + int __pyx_v_n_samples; + int __pyx_v_n_outputs; + int __pyx_v_n_left; + int __pyx_v_n_right; double __pyx_v_y_idx; int __pyx_v_idx; int __pyx_v_j; @@ -4324,16 +4331,106 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p int __pyx_t_4; __Pyx_RefNannySetupContext("update", 0); - /* "sklearn/tree/_tree.pyx":457 + /* "sklearn/tree/_tree.pyx":516 * """Update the criteria for each value in interval [a,b) (where a and b * are indices in `X_argsorted_i`).""" + * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< + * cdef double* mean_right = self.mean_right + * cdef double* sq_sum_left = self.sq_sum_left + */ + __pyx_v_mean_left = __pyx_v_self->mean_left; + + /* "sklearn/tree/_tree.pyx":517 + * are indices in `X_argsorted_i`).""" + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + */ + __pyx_v_mean_right = __pyx_v_self->mean_right; + + /* "sklearn/tree/_tree.pyx":518 + * cdef double* mean_left = self.mean_left + * cdef double* mean_right = self.mean_right + * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* var_left = self.var_left + */ + __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; + + /* "sklearn/tree/_tree.pyx":519 + * cdef double* mean_right = self.mean_right + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right + */ + __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; + + /* "sklearn/tree/_tree.pyx":520 + * cdef double* sq_sum_left = self.sq_sum_left + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< + * cdef double* var_right = self.var_right + * + */ + __pyx_v_var_left = __pyx_v_self->var_left; + + /* "sklearn/tree/_tree.pyx":521 + * cdef double* sq_sum_right = self.sq_sum_right + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< + * + * cdef int n_samples = self.n_samples + */ + __pyx_v_var_right = __pyx_v_self->var_right; + + /* "sklearn/tree/_tree.pyx":523 + * cdef double* var_right = self.var_right + * + * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs + * cdef int n_left = self.n_left + */ + __pyx_v_n_samples = __pyx_v_self->n_samples; + + /* "sklearn/tree/_tree.pyx":524 + * + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef int n_left = self.n_left + * cdef int n_right = self.n_right + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":525 + * cdef int n_samples = self.n_samples + * cdef int n_outputs = self.n_outputs + * cdef int n_left = self.n_left # <<<<<<<<<<<<<< + * cdef int n_right = self.n_right + * + */ + __pyx_v_n_left = __pyx_v_self->n_left; + + /* "sklearn/tree/_tree.pyx":526 + * cdef int n_outputs = self.n_outputs + * cdef int n_left = self.n_left + * cdef int n_right = self.n_right # <<<<<<<<<<<<<< + * + * cdef double y_idx = 0.0 + */ + __pyx_v_n_right = __pyx_v_self->n_right; + + /* "sklearn/tree/_tree.pyx":528 + * cdef int n_right = self.n_right + * * cdef double y_idx = 0.0 # <<<<<<<<<<<<<< * cdef int idx, j, k * */ __pyx_v_y_idx = 0.0; - /* "sklearn/tree/_tree.pyx":461 + /* "sklearn/tree/_tree.pyx":532 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -4343,7 +4440,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":462 + /* "sklearn/tree/_tree.pyx":533 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -4352,7 +4449,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":464 + /* "sklearn/tree/_tree.pyx":535 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -4362,133 +4459,151 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":465 + /* "sklearn/tree/_tree.pyx":536 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ goto __pyx_L3_continue; goto __pyx_L5; } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":467 + /* "sklearn/tree/_tree.pyx":538 * continue * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * y_idx = y[k * self.y_stride + j] - * self.sq_sum_left[k] += (y_idx * y_idx) + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * y_idx = y[k * y_stride + j] + * sq_sum_left[k] += (y_idx * y_idx) */ - __pyx_t_3 = __pyx_v_self->n_outputs; + __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":468 + /* "sklearn/tree/_tree.pyx":539 * - * for k from 0 <= k < self.n_outputs: - * y_idx = y[k * self.y_stride + j] # <<<<<<<<<<<<<< - * self.sq_sum_left[k] += (y_idx * y_idx) - * self.sq_sum_right[k] -= (y_idx * y_idx) + * for k from 0 <= k < n_outputs: + * y_idx = y[k * y_stride + j] # <<<<<<<<<<<<<< + * sq_sum_left[k] += (y_idx * y_idx) + * sq_sum_right[k] -= (y_idx * y_idx) */ - __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_k * __pyx_v_self->y_stride) + __pyx_v_j)]); + __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_k * __pyx_v_y_stride) + __pyx_v_j)]); - /* "sklearn/tree/_tree.pyx":469 - * for k from 0 <= k < self.n_outputs: - * y_idx = y[k * self.y_stride + j] - * self.sq_sum_left[k] += (y_idx * y_idx) # <<<<<<<<<<<<<< - * self.sq_sum_right[k] -= (y_idx * y_idx) + /* "sklearn/tree/_tree.pyx":540 + * for k from 0 <= k < n_outputs: + * y_idx = y[k * y_stride + j] + * sq_sum_left[k] += (y_idx * y_idx) # <<<<<<<<<<<<<< + * sq_sum_right[k] -= (y_idx * y_idx) * */ __pyx_t_4 = __pyx_v_k; - (__pyx_v_self->sq_sum_left[__pyx_t_4]) = ((__pyx_v_self->sq_sum_left[__pyx_t_4]) + (__pyx_v_y_idx * __pyx_v_y_idx)); + (__pyx_v_sq_sum_left[__pyx_t_4]) = ((__pyx_v_sq_sum_left[__pyx_t_4]) + (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":470 - * y_idx = y[k * self.y_stride + j] - * self.sq_sum_left[k] += (y_idx * y_idx) - * self.sq_sum_right[k] -= (y_idx * y_idx) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":541 + * y_idx = y[k * y_stride + j] + * sq_sum_left[k] += (y_idx * y_idx) + * sq_sum_right[k] -= (y_idx * y_idx) # <<<<<<<<<<<<<< * - * self.mean_left[k] = (self.n_left * self.mean_left[k] + y_idx) / (self.n_left + 1) + * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) */ __pyx_t_4 = __pyx_v_k; - (__pyx_v_self->sq_sum_right[__pyx_t_4]) = ((__pyx_v_self->sq_sum_right[__pyx_t_4]) - (__pyx_v_y_idx * __pyx_v_y_idx)); + (__pyx_v_sq_sum_right[__pyx_t_4]) = ((__pyx_v_sq_sum_right[__pyx_t_4]) - (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":472 - * self.sq_sum_right[k] -= (y_idx * y_idx) + /* "sklearn/tree/_tree.pyx":543 + * sq_sum_right[k] -= (y_idx * y_idx) * - * self.mean_left[k] = (self.n_left * self.mean_left[k] + y_idx) / (self.n_left + 1) # <<<<<<<<<<<<<< - * self.mean_right[k] = ((self.n_samples - self.n_left) * self.mean_right[k] - y_idx) / (self.n_samples - self.n_left - 1) + * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) # <<<<<<<<<<<<<< + * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) * */ - (__pyx_v_self->mean_left[__pyx_v_k]) = (((__pyx_v_self->n_left * (__pyx_v_self->mean_left[__pyx_v_k])) + __pyx_v_y_idx) / ((double)(__pyx_v_self->n_left + 1))); + (__pyx_v_mean_left[__pyx_v_k]) = (((__pyx_v_n_left * (__pyx_v_mean_left[__pyx_v_k])) + __pyx_v_y_idx) / ((double)(__pyx_v_n_left + 1))); - /* "sklearn/tree/_tree.pyx":473 + /* "sklearn/tree/_tree.pyx":544 * - * self.mean_left[k] = (self.n_left * self.mean_left[k] + y_idx) / (self.n_left + 1) - * self.mean_right[k] = ((self.n_samples - self.n_left) * self.mean_right[k] - y_idx) / (self.n_samples - self.n_left - 1) # <<<<<<<<<<<<<< + * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) + * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) # <<<<<<<<<<<<<< * - * self.n_right -= 1 + * n_left += 1 */ - (__pyx_v_self->mean_right[__pyx_v_k]) = ((((__pyx_v_self->n_samples - __pyx_v_self->n_left) * (__pyx_v_self->mean_right[__pyx_v_k])) - __pyx_v_y_idx) / ((double)((__pyx_v_self->n_samples - __pyx_v_self->n_left) - 1))); + (__pyx_v_mean_right[__pyx_v_k]) = ((((__pyx_v_n_samples - __pyx_v_n_left) * (__pyx_v_mean_right[__pyx_v_k])) - __pyx_v_y_idx) / ((double)((__pyx_v_n_samples - __pyx_v_n_left) - 1))); } - /* "sklearn/tree/_tree.pyx":475 - * self.mean_right[k] = ((self.n_samples - self.n_left) * self.mean_right[k] - y_idx) / (self.n_samples - self.n_left - 1) + /* "sklearn/tree/_tree.pyx":546 + * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) * - * self.n_right -= 1 # <<<<<<<<<<<<<< - * self.n_left += 1 + * n_left += 1 # <<<<<<<<<<<<<< + * self.n_left = n_left + * n_right -= 1 + */ + __pyx_v_n_left = (__pyx_v_n_left + 1); + + /* "sklearn/tree/_tree.pyx":547 * + * n_left += 1 + * self.n_left = n_left # <<<<<<<<<<<<<< + * n_right -= 1 + * self.n_right = n_right */ - __pyx_v_self->n_right = (__pyx_v_self->n_right - 1); + __pyx_v_self->n_left = __pyx_v_n_left; - /* "sklearn/tree/_tree.pyx":476 + /* "sklearn/tree/_tree.pyx":548 + * n_left += 1 + * self.n_left = n_left + * n_right -= 1 # <<<<<<<<<<<<<< + * self.n_right = n_right * - * self.n_right -= 1 - * self.n_left += 1 # <<<<<<<<<<<<<< + */ + __pyx_v_n_right = (__pyx_v_n_right - 1); + + /* "sklearn/tree/_tree.pyx":549 + * self.n_left = n_left + * n_right -= 1 + * self.n_right = n_right # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: + * for k from 0 <= k < n_outputs: */ - __pyx_v_self->n_left = (__pyx_v_self->n_left + 1); + __pyx_v_self->n_right = __pyx_v_n_right; - /* "sklearn/tree/_tree.pyx":478 - * self.n_left += 1 + /* "sklearn/tree/_tree.pyx":551 + * self.n_right = n_right * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * self.var_left[k] = self.sq_sum_left[k] - self.n_left * (self.mean_left[k] * self.mean_left[k]) - * self.var_right[k] = self.sq_sum_right[k] - self.n_right * (self.mean_right[k] * self.mean_right[k]) + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) + * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) */ - __pyx_t_3 = __pyx_v_self->n_outputs; + __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":479 + /* "sklearn/tree/_tree.pyx":552 * - * for k from 0 <= k < self.n_outputs: - * self.var_left[k] = self.sq_sum_left[k] - self.n_left * (self.mean_left[k] * self.mean_left[k]) # <<<<<<<<<<<<<< - * self.var_right[k] = self.sq_sum_right[k] - self.n_right * (self.mean_right[k] * self.mean_right[k]) + * for k from 0 <= k < n_outputs: + * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) # <<<<<<<<<<<<<< + * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) * */ - (__pyx_v_self->var_left[__pyx_v_k]) = ((__pyx_v_self->sq_sum_left[__pyx_v_k]) - (__pyx_v_self->n_left * ((__pyx_v_self->mean_left[__pyx_v_k]) * (__pyx_v_self->mean_left[__pyx_v_k])))); + (__pyx_v_var_left[__pyx_v_k]) = ((__pyx_v_sq_sum_left[__pyx_v_k]) - (__pyx_v_n_left * ((__pyx_v_mean_left[__pyx_v_k]) * (__pyx_v_mean_left[__pyx_v_k])))); - /* "sklearn/tree/_tree.pyx":480 - * for k from 0 <= k < self.n_outputs: - * self.var_left[k] = self.sq_sum_left[k] - self.n_left * (self.mean_left[k] * self.mean_left[k]) - * self.var_right[k] = self.sq_sum_right[k] - self.n_right * (self.mean_right[k] * self.mean_right[k]) # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":553 + * for k from 0 <= k < n_outputs: + * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) + * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< * - * return self.n_left + * return n_left */ - (__pyx_v_self->var_right[__pyx_v_k]) = ((__pyx_v_self->sq_sum_right[__pyx_v_k]) - (__pyx_v_self->n_right * ((__pyx_v_self->mean_right[__pyx_v_k]) * (__pyx_v_self->mean_right[__pyx_v_k])))); + (__pyx_v_var_right[__pyx_v_k]) = ((__pyx_v_sq_sum_right[__pyx_v_k]) - (__pyx_v_n_right * ((__pyx_v_mean_right[__pyx_v_k]) * (__pyx_v_mean_right[__pyx_v_k])))); } __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":482 - * self.var_right[k] = self.sq_sum_right[k] - self.n_right * (self.mean_right[k] * self.mean_right[k]) + /* "sklearn/tree/_tree.pyx":555 + * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) * - * return self.n_left # <<<<<<<<<<<<<< + * return n_left # <<<<<<<<<<<<<< * * cdef double eval(self): */ - __pyx_r = __pyx_v_self->n_left; + __pyx_r = __pyx_v_n_left; goto __pyx_L0; __pyx_r = 0; @@ -4497,8 +4612,8 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p return __pyx_r; } -/* "sklearn/tree/_tree.pyx":484 - * return self.n_left +/* "sklearn/tree/_tree.pyx":557 + * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< * pass @@ -4515,35 +4630,51 @@ static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(CYTHON_UN return __pyx_r; } -/* "sklearn/tree/_tree.pyx":487 +/* "sklearn/tree/_tree.pyx":560 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< - * return self.ndarray_mean_init - * + * cdef int n_outputs = self.n_outputs + * cdef double* mean_init = self.mean_init */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_n_outputs; + double *__pyx_v_mean_init; + PyArrayObject *__pyx_v_value = 0; + int __pyx_v_k; + __Pyx_LocalBuf_ND __pyx_pybuffernd_value; + __Pyx_Buffer __pyx_pybuffer_value; PyArrayObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); + __pyx_pybuffer_value.pybuffer.buf = NULL; + __pyx_pybuffer_value.refcount = 0; + __pyx_pybuffernd_value.data = NULL; + __pyx_pybuffernd_value.rcbuffer = &__pyx_pybuffer_value; /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4552,17 +4683,108 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":488 + /* "sklearn/tree/_tree.pyx":561 + * + * cpdef np.ndarray init_value(self): + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * cdef double* mean_init = self.mean_init * + */ + __pyx_v_n_outputs = __pyx_v_self->n_outputs; + + /* "sklearn/tree/_tree.pyx":562 * cpdef np.ndarray init_value(self): - * return self.ndarray_mean_init # <<<<<<<<<<<<<< + * cdef int n_outputs = self.n_outputs + * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, 1), dtype=DTYPE) + */ + __pyx_v_mean_init = __pyx_v_self->mean_init; + + /* "sklearn/tree/_tree.pyx":564 + * cdef double* mean_init = self.mean_init + * + * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, 1), dtype=DTYPE) # <<<<<<<<<<<<<< + * cdef int k + * + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { + __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __pyx_v_value = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "sklearn/tree/_tree.pyx":567 + * cdef int k + * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * value[k, 0] = (mean_init[k]) + * + */ + __pyx_t_6 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { + + /* "sklearn/tree/_tree.pyx":568 + * + * for k from 0 <= k < n_outputs: + * value[k, 0] = (mean_init[k]) # <<<<<<<<<<<<<< + * + * return value + */ + __pyx_t_7 = __pyx_v_k; + __pyx_t_8 = 0; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_value.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_value.diminfo[1].strides) = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_mean_init[__pyx_v_k])); + } + + /* "sklearn/tree/_tree.pyx":570 + * value[k, 0] = (mean_init[k]) + * + * return value # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - if (!(likely(((__pyx_v_self->ndarray_mean_init) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self->ndarray_mean_init, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_INCREF(__pyx_v_self->ndarray_mean_init); - __pyx_r = ((PyArrayObject *)__pyx_v_self->ndarray_mean_init); + __Pyx_INCREF(((PyObject *)__pyx_v_value)); + __pyx_r = ((PyArrayObject *)__pyx_v_value); goto __pyx_L0; __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); @@ -4570,34 +4792,44 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_value.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.init_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; + goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_value.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_value); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_value (wrapper)", 0); - __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)); + __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":487 +/* "sklearn/tree/_tree.pyx":560 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< - * return self.ndarray_mean_init - * + * cdef int n_outputs = self.n_outputs + * cdef double* mean_init = self.mean_init */ -static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { +static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_value(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -4606,7 +4838,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_valu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4624,59 +4856,98 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":497 +/* "sklearn/tree/_tree.pyx":579 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< - * cdef double total = 0.0 - * cdef int k + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right */ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_4tree_5_tree_MSE *__pyx_v_self) { - double __pyx_v_total; + double *__pyx_v_var_left; + double *__pyx_v_var_right; + int __pyx_v_n_outputs; int __pyx_v_k; + double __pyx_v_total; double __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":498 + /* "sklearn/tree/_tree.pyx":580 * * cdef double eval(self): - * cdef double total = 0.0 # <<<<<<<<<<<<<< - * cdef int k + * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< + * cdef double* var_right = self.var_right * */ - __pyx_v_total = 0.0; + __pyx_v_var_left = __pyx_v_self->__pyx_base.var_left; + + /* "sklearn/tree/_tree.pyx":581 + * cdef double eval(self): + * cdef double* var_left = self.var_left + * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< + * + * cdef int n_outputs = self.n_outputs + */ + __pyx_v_var_right = __pyx_v_self->__pyx_base.var_right; + + /* "sklearn/tree/_tree.pyx":583 + * cdef double* var_right = self.var_right + * + * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< + * + * cdef int k + */ + __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":501 + /* "sklearn/tree/_tree.pyx":586 + * * cdef int k + * cdef double total = 0.0 # <<<<<<<<<<<<<< * - * for k from 0 <= k < self.n_outputs: # <<<<<<<<<<<<<< - * total += self.var_left[k] + self.var_right[k] + * for k from 0 <= k < n_outputs: + */ + __pyx_v_total = 0.0; + + /* "sklearn/tree/_tree.pyx":588 + * cdef double total = 0.0 * + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * total += var_left[k] + * total += var_right[k] */ - __pyx_t_1 = __pyx_v_self->__pyx_base.n_outputs; + __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":502 + /* "sklearn/tree/_tree.pyx":589 + * + * for k from 0 <= k < n_outputs: + * total += var_left[k] # <<<<<<<<<<<<<< + * total += var_right[k] * - * for k from 0 <= k < self.n_outputs: - * total += self.var_left[k] + self.var_right[k] # <<<<<<<<<<<<<< + */ + __pyx_v_total = (__pyx_v_total + (__pyx_v_var_left[__pyx_v_k])); + + /* "sklearn/tree/_tree.pyx":590 + * for k from 0 <= k < n_outputs: + * total += var_left[k] + * total += var_right[k] # <<<<<<<<<<<<<< * - * return total / self.n_outputs + * return total / n_outputs */ - __pyx_v_total = (__pyx_v_total + ((__pyx_v_self->__pyx_base.var_left[__pyx_v_k]) + (__pyx_v_self->__pyx_base.var_right[__pyx_v_k]))); + __pyx_v_total = (__pyx_v_total + (__pyx_v_var_right[__pyx_v_k])); } - /* "sklearn/tree/_tree.pyx":504 - * total += self.var_left[k] + self.var_right[k] + /* "sklearn/tree/_tree.pyx":592 + * total += var_right[k] * - * return total / self.n_outputs # <<<<<<<<<<<<<< + * return total / n_outputs # <<<<<<<<<<<<<< * * */ - __pyx_r = (__pyx_v_total / __pyx_v_self->__pyx_base.n_outputs); + __pyx_r = (__pyx_v_total / __pyx_v_n_outputs); goto __pyx_L0; __pyx_r = 0; @@ -4720,17 +4991,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_total_in_bag); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -4739,13 +5010,13 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } - __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_random_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._random_sample_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4756,7 +5027,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":513 +/* "sklearn/tree/_tree.pyx":601 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< @@ -4800,33 +5071,33 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_pybuffernd_sample_mask.data = NULL; __pyx_pybuffernd_sample_mask.rcbuffer = &__pyx_pybuffer_sample_mask; - /* "sklearn/tree/_tree.pyx":532 + /* "sklearn/tree/_tree.pyx":620 * """ * cdef np.ndarray[np.float64_t, ndim=1, mode="c"] rand = \ * random_state.rand(n_total_samples) # <<<<<<<<<<<<<< * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rand.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_rand = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_rand.diminfo[0].strides = __pyx_pybuffernd_rand.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rand.diminfo[0].shape = __pyx_pybuffernd_rand.rcbuffer->pybuffer.shape[0]; } } @@ -4834,51 +5105,51 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_rand = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":534 + /* "sklearn/tree/_tree.pyx":622 * random_state.rand(n_total_samples) * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) # <<<<<<<<<<<<<< * * cdef int n_bagged = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__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 = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_sample_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_sample_mask.diminfo[0].strides = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_mask.diminfo[0].shape = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.shape[0]; } } @@ -4886,7 +5157,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_sample_mask = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":536 + /* "sklearn/tree/_tree.pyx":624 * np.zeros((n_total_samples,), dtype=np.int8) * * cdef int n_bagged = 0 # <<<<<<<<<<<<<< @@ -4895,7 +5166,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_n_bagged = 0; - /* "sklearn/tree/_tree.pyx":537 + /* "sklearn/tree/_tree.pyx":625 * * cdef int n_bagged = 0 * cdef int i = 0 # <<<<<<<<<<<<<< @@ -4904,7 +5175,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":538 + /* "sklearn/tree/_tree.pyx":626 * cdef int n_bagged = 0 * cdef int i = 0 * for i in range(n_total_samples): # <<<<<<<<<<<<<< @@ -4915,7 +5186,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9; - /* "sklearn/tree/_tree.pyx":539 + /* "sklearn/tree/_tree.pyx":627 * cdef int i = 0 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): # <<<<<<<<<<<<<< @@ -4926,7 +5197,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_t_11 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_rand.diminfo[0].strides)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); if (__pyx_t_11) { - /* "sklearn/tree/_tree.pyx":540 + /* "sklearn/tree/_tree.pyx":628 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 # <<<<<<<<<<<<<< @@ -4936,7 +5207,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_t_12 = __pyx_v_i; *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_sample_mask.diminfo[0].strides) = 1; - /* "sklearn/tree/_tree.pyx":541 + /* "sklearn/tree/_tree.pyx":629 * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 * n_bagged += 1 # <<<<<<<<<<<<<< @@ -4949,7 +5220,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_L5:; } - /* "sklearn/tree/_tree.pyx":543 + /* "sklearn/tree/_tree.pyx":631 * n_bagged += 1 * * return sample_mask.astype(np.bool) # <<<<<<<<<<<<<< @@ -4957,19 +5228,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -5043,29 +5314,29 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__out); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -5084,17 +5355,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._apply_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_out); goto __pyx_L0; __pyx_L1_error:; @@ -5104,7 +5375,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel return __pyx_r; } -/* "sklearn/tree/_tree.pyx":546 +/* "sklearn/tree/_tree.pyx":634 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5172,31 +5443,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out; { __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 = 546; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; - /* "sklearn/tree/_tree.pyx":553 + /* "sklearn/tree/_tree.pyx":641 * """Finds the terminal region (=leaf node) for each sample in * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 # <<<<<<<<<<<<<< @@ -5205,7 +5476,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":554 + /* "sklearn/tree/_tree.pyx":642 * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< @@ -5214,7 +5485,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":555 + /* "sklearn/tree/_tree.pyx":643 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< @@ -5223,7 +5494,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":556 + /* "sklearn/tree/_tree.pyx":644 * cdef int n = X.shape[0] * cdef int node_id = 0 * for i in xrange(n): # <<<<<<<<<<<<<< @@ -5234,7 +5505,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "sklearn/tree/_tree.pyx":557 + /* "sklearn/tree/_tree.pyx":645 * cdef int node_id = 0 * for i in xrange(n): * node_id = 0 # <<<<<<<<<<<<<< @@ -5243,7 +5514,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":559 + /* "sklearn/tree/_tree.pyx":647 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5264,7 +5535,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj } if (!__pyx_t_9) break; - /* "sklearn/tree/_tree.pyx":560 + /* "sklearn/tree/_tree.pyx":648 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -5278,7 +5549,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":561 + /* "sklearn/tree/_tree.pyx":649 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -5292,7 +5563,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj } /*else*/ { - /* "sklearn/tree/_tree.pyx":563 + /* "sklearn/tree/_tree.pyx":651 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< @@ -5306,7 +5577,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":564 + /* "sklearn/tree/_tree.pyx":652 * else: * node_id = children[node_id, 1] * out[i] = node_id # <<<<<<<<<<<<<< @@ -5384,35 +5655,35 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__values); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -5433,18 +5704,18 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._predict_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_values, __pyx_v_pred); goto __pyx_L0; __pyx_L1_error:; @@ -5454,7 +5725,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s return __pyx_r; } -/* "sklearn/tree/_tree.pyx":567 +/* "sklearn/tree/_tree.pyx":655 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5466,8 +5737,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO int __pyx_v_i; int __pyx_v_n; int __pyx_v_node_id; - int __pyx_v_K; + int __pyx_v_n_outputs; + int __pyx_v_n_classes; int __pyx_v_k; + int __pyx_v_c; __Pyx_LocalBuf_ND __pyx_pybuffernd_X; __Pyx_Buffer __pyx_pybuffer_X; __Pyx_LocalBuf_ND __pyx_pybuffernd_children; @@ -5505,6 +5778,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO int __pyx_t_21; int __pyx_t_22; int __pyx_t_23; + int __pyx_t_24; + int __pyx_t_25; + int __pyx_t_26; + int __pyx_t_27; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5535,37 +5812,37 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_pybuffernd_pred.rcbuffer = &__pyx_pybuffer_pred; { __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 = 567; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1]; + __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_values.diminfo[2].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_values.diminfo[2].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[2]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_pred.diminfo[0].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred.diminfo[0].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred.diminfo[1].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred.diminfo[1].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[1]; + __pyx_pybuffernd_pred.diminfo[0].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred.diminfo[0].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred.diminfo[1].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred.diminfo[1].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_pred.diminfo[2].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_pred.diminfo[2].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[2]; - /* "sklearn/tree/_tree.pyx":574 - * np.ndarray[np.float64_t, ndim=2] pred): + /* "sklearn/tree/_tree.pyx":662 + * np.ndarray[np.float64_t, ndim=3] pred): * """Finds the terminal region (=leaf node) values for each sample. """ * cdef int i = 0 # <<<<<<<<<<<<<< * cdef int n = X.shape[0] @@ -5573,36 +5850,45 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":575 + /* "sklearn/tree/_tree.pyx":663 * """Finds the terminal region (=leaf node) values for each sample. """ * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< * cdef int node_id = 0 - * cdef int K = values.shape[1] + * cdef int n_outputs = values.shape[1] */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":576 + /* "sklearn/tree/_tree.pyx":664 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< - * cdef int K = values.shape[1] - * for i in xrange(n): + * cdef int n_outputs = values.shape[1] + * cdef int n_classes = values.shape[2] */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":577 + /* "sklearn/tree/_tree.pyx":665 * cdef int n = X.shape[0] * cdef int node_id = 0 - * cdef int K = values.shape[1] # <<<<<<<<<<<<<< - * for i in xrange(n): - * node_id = 0 + * cdef int n_outputs = values.shape[1] # <<<<<<<<<<<<<< + * cdef int n_classes = values.shape[2] + * */ - __pyx_v_K = (__pyx_v_values->dimensions[1]); + __pyx_v_n_outputs = (__pyx_v_values->dimensions[1]); - /* "sklearn/tree/_tree.pyx":578 + /* "sklearn/tree/_tree.pyx":666 * cdef int node_id = 0 - * cdef int K = values.shape[1] + * cdef int n_outputs = values.shape[1] + * cdef int n_classes = values.shape[2] # <<<<<<<<<<<<<< + * + * for i in xrange(n): + */ + __pyx_v_n_classes = (__pyx_v_values->dimensions[2]); + + /* "sklearn/tree/_tree.pyx":668 + * cdef int n_classes = values.shape[2] + * * for i in xrange(n): # <<<<<<<<<<<<<< * node_id = 0 * # While node_id not a leaf @@ -5611,8 +5897,8 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "sklearn/tree/_tree.pyx":579 - * cdef int K = values.shape[1] + /* "sklearn/tree/_tree.pyx":669 + * * for i in xrange(n): * node_id = 0 # <<<<<<<<<<<<<< * # While node_id not a leaf @@ -5620,7 +5906,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":581 + /* "sklearn/tree/_tree.pyx":671 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5641,7 +5927,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO } if (!__pyx_t_9) break; - /* "sklearn/tree/_tree.pyx":582 + /* "sklearn/tree/_tree.pyx":672 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -5655,7 +5941,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":583 + /* "sklearn/tree/_tree.pyx":673 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -5669,12 +5955,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO } /*else*/ { - /* "sklearn/tree/_tree.pyx":585 + /* "sklearn/tree/_tree.pyx":675 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< - * for k in xrange(K): - * pred[i, k] = values[node_id, k] + * + * for k in xrange(n_outputs): */ __pyx_t_16 = __pyx_v_node_id; __pyx_t_17 = 1; @@ -5683,29 +5969,43 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":586 - * else: + /* "sklearn/tree/_tree.pyx":677 * node_id = children[node_id, 1] - * for k in xrange(K): # <<<<<<<<<<<<<< - * pred[i, k] = values[node_id, k] + * + * for k in xrange(n_outputs): # <<<<<<<<<<<<<< + * for c in xrange(n_classes): + * pred[i, k, c] = values[node_id, k, c] + */ + __pyx_t_18 = __pyx_v_n_outputs; + for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { + __pyx_v_k = __pyx_t_19; + + /* "sklearn/tree/_tree.pyx":678 + * + * for k in xrange(n_outputs): + * for c in xrange(n_classes): # <<<<<<<<<<<<<< + * pred[i, k, c] = values[node_id, k, c] * */ - __pyx_t_18 = __pyx_v_K; - for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { - __pyx_v_k = __pyx_t_19; + __pyx_t_20 = __pyx_v_n_classes; + for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) { + __pyx_v_c = __pyx_t_21; - /* "sklearn/tree/_tree.pyx":587 - * node_id = children[node_id, 1] - * for k in xrange(K): - * pred[i, k] = values[node_id, k] # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":679 + * for k in xrange(n_outputs): + * for c in xrange(n_classes): + * pred[i, k, c] = values[node_id, k, c] # <<<<<<<<<<<<<< * * */ - __pyx_t_20 = __pyx_v_node_id; - __pyx_t_21 = __pyx_v_k; - __pyx_t_22 = __pyx_v_i; - __pyx_t_23 = __pyx_v_k; - *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_pred.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_pred.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_pred.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_values.diminfo[1].strides)); + __pyx_t_22 = __pyx_v_node_id; + __pyx_t_23 = __pyx_v_k; + __pyx_t_24 = __pyx_v_c; + __pyx_t_25 = __pyx_v_i; + __pyx_t_26 = __pyx_v_k; + __pyx_t_27 = __pyx_v_c; + *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_pred.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_pred.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_pred.diminfo[1].strides, __pyx_t_27, __pyx_pybuffernd_pred.diminfo[2].strides) = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_values.diminfo[1].strides, __pyx_t_24, __pyx_pybuffernd_values.diminfo[2].strides)); + } } } @@ -5774,23 +6074,23 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -5803,19 +6103,19 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ __pyx_v_y = ((PyArrayObject *)values[0]); __pyx_v_sample_mask = ((PyArrayObject *)values[1]); __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[2]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._error_at_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(__pyx_self, __pyx_v_y, __pyx_v_sample_mask, __pyx_v_criterion, __pyx_v_n_samples); goto __pyx_L0; __pyx_L1_error:; @@ -5825,17 +6125,18 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":590 +/* "sklearn/tree/_tree.pyx":682 * * - * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< - * np.ndarray sample_mask, Criterion criterion, - * int n_samples): + * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< + * np.ndarray sample_mask, + * Criterion criterion, */ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_sample_mask, struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_criterion, int __pyx_v_n_samples) { - int __pyx_v_n_total_samples; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; + int __pyx_v_y_stride; + int __pyx_v_n_total_samples; __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; __Pyx_LocalBuf_ND __pyx_pybuffernd_y; __Pyx_Buffer __pyx_pybuffer_y; @@ -5852,55 +6153,64 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; + __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":595 + /* "sklearn/tree/_tree.pyx":688 * """Compute criterion error at leaf with terminal region defined * by `sample_mask`. """ - * cdef int n_total_samples = y.shape[0] # <<<<<<<<<<<<<< - * cdef DTYPE_t *y_ptr = y.data - * cdef BOOL_t *sample_mask_ptr = sample_mask.data + * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< + * cdef int y_stride = y.strides[0] / y.strides[1] + * cdef int n_total_samples = y.shape[0] */ - __pyx_v_n_total_samples = (__pyx_v_y->dimensions[0]); + __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":596 + /* "sklearn/tree/_tree.pyx":689 * by `sample_mask`. """ + * cdef DTYPE_t* y_ptr = y.data + * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< * cdef int n_total_samples = y.shape[0] - * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) */ - __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); + __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); + + /* "sklearn/tree/_tree.pyx":690 + * cdef DTYPE_t* y_ptr = y.data + * cdef int y_stride = y.strides[0] / y.strides[1] + * cdef int n_total_samples = y.shape[0] # <<<<<<<<<<<<<< + * cdef BOOL_t *sample_mask_ptr = sample_mask.data + * + */ + __pyx_v_n_total_samples = (__pyx_v_y->dimensions[0]); - /* "sklearn/tree/_tree.pyx":597 + /* "sklearn/tree/_tree.pyx":691 + * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int n_total_samples = y.shape[0] - * cdef DTYPE_t *y_ptr = y.data * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) - * return criterion.eval() + * + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":598 - * cdef DTYPE_t *y_ptr = y.data + /* "sklearn/tree/_tree.pyx":693 * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< - * return criterion.eval() * + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< + * + * return criterion.eval() */ - ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":599 - * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + /* "sklearn/tree/_tree.pyx":695 + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) + * * return criterion.eval() # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5925,7 +6235,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":602 +/* "sklearn/tree/_tree.pyx":698 * * * cdef int smallest_sample_larger_than(int sample_idx, DTYPE_t *X_i, # <<<<<<<<<<<<<< @@ -5943,7 +6253,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v int __pyx_t_2; __Pyx_RefNannySetupContext("smallest_sample_larger_than", 0); - /* "sklearn/tree/_tree.pyx":619 + /* "sklearn/tree/_tree.pyx":715 * -1 if no such element exists. * """ * cdef int idx = 0, j # <<<<<<<<<<<<<< @@ -5952,7 +6262,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_idx = 0; - /* "sklearn/tree/_tree.pyx":620 + /* "sklearn/tree/_tree.pyx":716 * """ * cdef int idx = 0, j * cdef DTYPE_t threshold = -DBL_MAX # <<<<<<<<<<<<<< @@ -5961,7 +6271,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_threshold = (-DBL_MAX); - /* "sklearn/tree/_tree.pyx":622 + /* "sklearn/tree/_tree.pyx":718 * cdef DTYPE_t threshold = -DBL_MAX * * if sample_idx > -1: # <<<<<<<<<<<<<< @@ -5971,7 +6281,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = (__pyx_v_sample_idx > -1); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":623 + /* "sklearn/tree/_tree.pyx":719 * * if sample_idx > -1: * threshold = X_i[X_argsorted_i[sample_idx]] # <<<<<<<<<<<<<< @@ -5983,7 +6293,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":625 + /* "sklearn/tree/_tree.pyx":721 * threshold = X_i[X_argsorted_i[sample_idx]] * * for idx from sample_idx < idx < n_total_samples: # <<<<<<<<<<<<<< @@ -5993,7 +6303,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_2 = __pyx_v_n_total_samples; for (__pyx_v_idx = __pyx_v_sample_idx+1; __pyx_v_idx < __pyx_t_2; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":626 + /* "sklearn/tree/_tree.pyx":722 * * for idx from sample_idx < idx < n_total_samples: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -6002,7 +6312,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":628 + /* "sklearn/tree/_tree.pyx":724 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -6012,7 +6322,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":629 + /* "sklearn/tree/_tree.pyx":725 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -6024,7 +6334,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L6:; - /* "sklearn/tree/_tree.pyx":631 + /* "sklearn/tree/_tree.pyx":727 * continue * * if X_i[j] > threshold + 1.e-7: # <<<<<<<<<<<<<< @@ -6034,7 +6344,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_X_i[__pyx_v_j]) > (__pyx_v_threshold + 1.e-7)); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":632 + /* "sklearn/tree/_tree.pyx":728 * * if X_i[j] > threshold + 1.e-7: * return idx # <<<<<<<<<<<<<< @@ -6049,7 +6359,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_L4_continue:; } - /* "sklearn/tree/_tree.pyx":634 + /* "sklearn/tree/_tree.pyx":730 * return idx * * return -1 # <<<<<<<<<<<<<< @@ -6112,53 +6422,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -6177,25 +6487,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -6205,11 +6515,11 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":637 +/* "sklearn/tree/_tree.pyx":733 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ @@ -6227,11 +6537,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; int *__pyx_v_X_argsorted_i; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; PyArrayObject *__pyx_v_features = 0; + int __pyx_v_y_stride; int __pyx_v_X_elem_stride; int __pyx_v_X_col_stride; int __pyx_v_X_stride; @@ -6263,7 +6574,6 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED int __pyx_t_13; int __pyx_t_14; Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -6286,21 +6596,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":696 + /* "sklearn/tree/_tree.pyx":792 * """ * # Variables declarations * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -6309,7 +6619,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":697 + /* "sklearn/tree/_tree.pyx":793 * # Variables declarations * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -6318,7 +6628,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":698 + /* "sklearn/tree/_tree.pyx":794 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 # <<<<<<<<<<<<<< @@ -6327,7 +6637,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":699 + /* "sklearn/tree/_tree.pyx":795 * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 * cdef Py_ssize_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -6336,7 +6646,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":700 + /* "sklearn/tree/_tree.pyx":796 * cdef int i, a, b, best_i = -1 * cdef Py_ssize_t feature_idx = -1 * cdef int n_left = 0 # <<<<<<<<<<<<<< @@ -6345,70 +6655,70 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = 0; - /* "sklearn/tree/_tree.pyx":702 + /* "sklearn/tree/_tree.pyx":798 * cdef int n_left = 0 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":703 + /* "sklearn/tree/_tree.pyx":799 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf - * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL + * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data */ - __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); + __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":704 + /* "sklearn/tree/_tree.pyx":800 * cdef DTYPE_t best_error = np.inf, best_t = np.inf - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL # <<<<<<<<<<<<<< - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data */ - __pyx_v_X_i = NULL; + __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":705 - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL # <<<<<<<<<<<<<< - * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + /* "sklearn/tree/_tree.pyx":801 + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< + * cdef BOOL_t* sample_mask_ptr = sample_mask.data + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None */ - __pyx_v_X_argsorted_i = NULL; + __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":706 - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + /* "sklearn/tree/_tree.pyx":802 + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None * */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":707 - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":803 + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< * * # Compute the column strides (increment in pointer elements to get */ @@ -6417,7 +6727,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } @@ -6425,17 +6735,26 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":711 + /* "sklearn/tree/_tree.pyx":807 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` + * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< + * cdef int X_elem_stride = X.strides[0] + * cdef int X_col_stride = X.strides[1] + */ + __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); + + /* "sklearn/tree/_tree.pyx":808 + * # from column i to i + 1) for `X` and `X_argsorted` + * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":712 - * # from column i to i + 1) for `X` and `X_argsorted` + /* "sklearn/tree/_tree.pyx":809 + * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< * cdef int X_stride = X_col_stride / X_elem_stride @@ -6443,7 +6762,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":713 + /* "sklearn/tree/_tree.pyx":810 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -6452,7 +6771,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":714 + /* "sklearn/tree/_tree.pyx":811 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -6461,7 +6780,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":715 + /* "sklearn/tree/_tree.pyx":812 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -6470,7 +6789,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":716 + /* "sklearn/tree/_tree.pyx":813 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -6479,34 +6798,34 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":719 + /* "sklearn/tree/_tree.pyx":816 * * # Compute the initial criterion value in the node - * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":720 + /* "sklearn/tree/_tree.pyx":817 * # Compute the initial criterion value in the node - * X_argsorted_i = X_argsorted.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< + * X_argsorted_i = X_argsorted.data + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< * initial_error = criterion.eval() * */ - ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":721 - * X_argsorted_i = X_argsorted.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + /* "sklearn/tree/_tree.pyx":818 + * X_argsorted_i = X_argsorted.data + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< * * if initial_error == 0: # break early if the node is pure */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":723 + /* "sklearn/tree/_tree.pyx":820 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -6516,7 +6835,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":724 + /* "sklearn/tree/_tree.pyx":821 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, initial_error, initial_error # <<<<<<<<<<<<<< @@ -6524,15 +6843,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -6553,7 +6872,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":726 + /* "sklearn/tree/_tree.pyx":823 * return best_i, best_t, initial_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -6562,40 +6881,40 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":729 + /* "sklearn/tree/_tree.pyx":826 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -6611,14 +6930,14 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":730 + /* "sklearn/tree/_tree.pyx":827 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< @@ -6634,7 +6953,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":731 + /* "sklearn/tree/_tree.pyx":828 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -6646,28 +6965,28 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } /*else*/ { - /* "sklearn/tree/_tree.pyx":733 + /* "sklearn/tree/_tree.pyx":830 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * - * + * # Look for the best split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_v_features)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -6683,7 +7002,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); @@ -6692,46 +7011,45 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":737 + /* "sklearn/tree/_tree.pyx":833 * * # Look for the best split - * for feature_idx in range(max_features): # <<<<<<<<<<<<<< + * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< * i = features[feature_idx] * # Get i-th col of X and X_sorted */ __pyx_t_9 = __pyx_v_max_features; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_9; __pyx_t_15+=1) { - __pyx_v_feature_idx = __pyx_t_15; + for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":738 + /* "sklearn/tree/_tree.pyx":834 * # Look for the best split - * for feature_idx in range(max_features): + * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i + * X_i = (X.data) + X_stride * i */ - __pyx_t_16 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_t_15 = __pyx_v_feature_idx; + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":740 + /* "sklearn/tree/_tree.pyx":836 * i = features[feature_idx] * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< - * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i + * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< + * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i * */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":741 + /* "sklearn/tree/_tree.pyx":837 * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i - * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< + * X_i = (X.data) + X_stride * i + * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< * * # Reset the criterion for this feature */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":744 + /* "sklearn/tree/_tree.pyx":840 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -6740,7 +7058,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":747 + /* "sklearn/tree/_tree.pyx":843 * * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 # <<<<<<<<<<<<<< @@ -6749,7 +7067,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":748 + /* "sklearn/tree/_tree.pyx":844 * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -6760,7 +7078,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":749 + /* "sklearn/tree/_tree.pyx":845 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -6770,7 +7088,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":752 + /* "sklearn/tree/_tree.pyx":848 * * # Consider splits between two consecutive samples * while True: # <<<<<<<<<<<<<< @@ -6780,7 +7098,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":755 + /* "sklearn/tree/_tree.pyx":851 * # Find the following larger sample * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) # <<<<<<<<<<<<<< @@ -6789,7 +7107,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_b = __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(__pyx_v_a, __pyx_v_X_i, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":756 + /* "sklearn/tree/_tree.pyx":852 * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) * if b == -1: # <<<<<<<<<<<<<< @@ -6799,7 +7117,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_14 = (__pyx_v_b == -1); if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":757 + /* "sklearn/tree/_tree.pyx":853 * sample_mask_ptr, n_total_samples) * if b == -1: * break # <<<<<<<<<<<<<< @@ -6811,16 +7129,16 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":760 + /* "sklearn/tree/_tree.pyx":856 * * # Better split than the best so far? - * n_left = criterion.update(a, b, y_ptr, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< + * n_left = criterion.update(a, b, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< * * # Only consider splits that respect min_leaf */ - __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y_ptr, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); + __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":763 + /* "sklearn/tree/_tree.pyx":859 * * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -6836,7 +7154,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":764 + /* "sklearn/tree/_tree.pyx":860 * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b # <<<<<<<<<<<<<< @@ -6845,7 +7163,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = __pyx_v_b; - /* "sklearn/tree/_tree.pyx":765 + /* "sklearn/tree/_tree.pyx":861 * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b * continue # <<<<<<<<<<<<<< @@ -6857,7 +7175,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":767 + /* "sklearn/tree/_tree.pyx":863 * continue * * error = criterion.eval() # <<<<<<<<<<<<<< @@ -6866,7 +7184,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":769 + /* "sklearn/tree/_tree.pyx":865 * error = criterion.eval() * * if error < best_error: # <<<<<<<<<<<<<< @@ -6876,7 +7194,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_13 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":771 + /* "sklearn/tree/_tree.pyx":867 * if error < best_error: * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) # <<<<<<<<<<<<<< @@ -6885,7 +7203,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_t = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) + (((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])) / 2.0)); - /* "sklearn/tree/_tree.pyx":772 + /* "sklearn/tree/_tree.pyx":868 * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -6895,7 +7213,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":773 + /* "sklearn/tree/_tree.pyx":869 * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -6907,7 +7225,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L14:; - /* "sklearn/tree/_tree.pyx":774 + /* "sklearn/tree/_tree.pyx":870 * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] * best_i = i # <<<<<<<<<<<<<< @@ -6916,7 +7234,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":775 + /* "sklearn/tree/_tree.pyx":871 * t = X_i[X_argsorted_i[a]] * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -6925,7 +7243,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":776 + /* "sklearn/tree/_tree.pyx":872 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -6937,7 +7255,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L13:; - /* "sklearn/tree/_tree.pyx":779 + /* "sklearn/tree/_tree.pyx":875 * * # Proceed to the next interval * a = b # <<<<<<<<<<<<<< @@ -6950,7 +7268,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_L10_break:; } - /* "sklearn/tree/_tree.pyx":781 + /* "sklearn/tree/_tree.pyx":877 * a = b * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -6958,15 +7276,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); @@ -7061,53 +7379,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -7126,25 +7444,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_random_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -7154,11 +7472,11 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje return __pyx_r; } -/* "sklearn/tree/_tree.pyx":783 +/* "sklearn/tree/_tree.pyx":879 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ @@ -7177,11 +7495,12 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_error; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_error; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_best_t; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_X_i; int *__pyx_v_X_argsorted_i; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *__pyx_v_y_ptr; __pyx_t_7sklearn_4tree_5_tree_BOOL_t *__pyx_v_sample_mask_ptr; PyArrayObject *__pyx_v_features = 0; + int __pyx_v_y_stride; int __pyx_v_X_elem_stride; int __pyx_v_X_col_stride; int __pyx_v_X_stride; @@ -7213,7 +7532,6 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON int __pyx_t_13; int __pyx_t_14; __pyx_t_5numpy_int32_t __pyx_t_15; - __pyx_t_5numpy_int32_t __pyx_t_16; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -7236,21 +7554,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":842 + /* "sklearn/tree/_tree.pyx":938 * """ * # Variables * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -7259,7 +7577,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":843 + /* "sklearn/tree/_tree.pyx":939 * # Variables * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -7268,7 +7586,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":844 + /* "sklearn/tree/_tree.pyx":940 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 # <<<<<<<<<<<<<< @@ -7277,7 +7595,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":845 + /* "sklearn/tree/_tree.pyx":941 * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -7286,70 +7604,70 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":847 + /* "sklearn/tree/_tree.pyx":943 * cdef np.int32_t feature_idx = -1 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":848 + /* "sklearn/tree/_tree.pyx":944 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf - * cdef DTYPE_t *y_ptr = y.data # <<<<<<<<<<<<<< - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL + * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data */ - __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); + __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":849 + /* "sklearn/tree/_tree.pyx":945 * cdef DTYPE_t best_error = np.inf, best_t = np.inf - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL # <<<<<<<<<<<<<< - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data */ - __pyx_v_X_i = NULL; + __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":850 - * cdef DTYPE_t *y_ptr = y.data - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL # <<<<<<<<<<<<<< - * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + /* "sklearn/tree/_tree.pyx":946 + * cdef DTYPE_t* X_i = NULL + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< + * cdef BOOL_t* sample_mask_ptr = sample_mask.data + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None */ - __pyx_v_X_argsorted_i = NULL; + __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":851 - * cdef DTYPE_t *X_i = NULL - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + /* "sklearn/tree/_tree.pyx":947 + * cdef int* X_argsorted_i = NULL + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None * */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":852 - * cdef int *X_argsorted_i = NULL - * cdef BOOL_t *sample_mask_ptr = sample_mask.data - * cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None # <<<<<<<<<<<<<< + /* "sklearn/tree/_tree.pyx":948 + * cdef DTYPE_t* y_ptr = y.data + * cdef BOOL_t* sample_mask_ptr = sample_mask.data + * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< * * # Compute the column strides (increment in pointer elements to get */ @@ -7358,7 +7676,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } @@ -7366,17 +7684,26 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":856 + /* "sklearn/tree/_tree.pyx":952 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` + * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< + * cdef int X_elem_stride = X.strides[0] + * cdef int X_col_stride = X.strides[1] + */ + __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); + + /* "sklearn/tree/_tree.pyx":953 + * # from column i to i + 1) for `X` and `X_argsorted` + * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":857 - * # from column i to i + 1) for `X` and `X_argsorted` + /* "sklearn/tree/_tree.pyx":954 + * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< * cdef int X_stride = X_col_stride / X_elem_stride @@ -7384,7 +7711,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":858 + /* "sklearn/tree/_tree.pyx":955 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -7393,7 +7720,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":859 + /* "sklearn/tree/_tree.pyx":956 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -7402,7 +7729,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":860 + /* "sklearn/tree/_tree.pyx":957 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -7411,7 +7738,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":861 + /* "sklearn/tree/_tree.pyx":958 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -7420,34 +7747,34 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":864 + /* "sklearn/tree/_tree.pyx":961 * * # Compute the initial criterion value - * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":865 + /* "sklearn/tree/_tree.pyx":962 * # Compute the initial criterion value - * X_argsorted_i = X_argsorted.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< + * X_argsorted_i = X_argsorted.data + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< * initial_error = criterion.eval() * */ - ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); + ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":866 - * X_argsorted_i = X_argsorted.data - * criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + /* "sklearn/tree/_tree.pyx":963 + * X_argsorted_i = X_argsorted.data + * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< * * if initial_error == 0: # break early if the node is pure */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":868 + /* "sklearn/tree/_tree.pyx":965 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -7457,7 +7784,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":869 + /* "sklearn/tree/_tree.pyx":966 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -7465,15 +7792,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -7494,7 +7821,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":871 + /* "sklearn/tree/_tree.pyx":968 * return best_i, best_t, best_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -7503,40 +7830,40 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":874 + /* "sklearn/tree/_tree.pyx":971 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7552,14 +7879,14 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":875 + /* "sklearn/tree/_tree.pyx":972 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< @@ -7575,7 +7902,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":876 + /* "sklearn/tree/_tree.pyx":973 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -7587,28 +7914,28 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } /*else*/ { - /* "sklearn/tree/_tree.pyx":878 + /* "sklearn/tree/_tree.pyx":975 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best random split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_v_features)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7624,7 +7951,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); @@ -7633,46 +7960,45 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":881 + /* "sklearn/tree/_tree.pyx":978 * * # Look for the best random split - * for feature_idx in range(max_features): # <<<<<<<<<<<<<< + * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< * i = features[feature_idx] * # Get i-th col of X and X_sorted */ __pyx_t_9 = __pyx_v_max_features; - for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_9; __pyx_t_15+=1) { - __pyx_v_feature_idx = __pyx_t_15; + for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":882 + /* "sklearn/tree/_tree.pyx":979 * # Look for the best random split - * for feature_idx in range(max_features): + * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i + * X_i = (X.data) + X_stride * i */ - __pyx_t_16 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_t_15 = __pyx_v_feature_idx; + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":884 + /* "sklearn/tree/_tree.pyx":981 * i = features[feature_idx] * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< - * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i + * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< + * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i * */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":885 + /* "sklearn/tree/_tree.pyx":982 * # Get i-th col of X and X_sorted - * X_i = (X.data) + X_stride * i - * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< + * X_i = (X.data) + X_stride * i + * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< * * # Reset the criterion for this feature */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":888 + /* "sklearn/tree/_tree.pyx":985 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -7681,7 +8007,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":891 + /* "sklearn/tree/_tree.pyx":988 * * # Find min and max * a = 0 # <<<<<<<<<<<<<< @@ -7690,7 +8016,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":892 + /* "sklearn/tree/_tree.pyx":989 * # Find min and max * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -7701,7 +8027,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":893 + /* "sklearn/tree/_tree.pyx":990 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -7711,7 +8037,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":895 + /* "sklearn/tree/_tree.pyx":992 * a = a + 1 * * b = n_total_samples - 1 # <<<<<<<<<<<<<< @@ -7720,7 +8046,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_b = (__pyx_v_n_total_samples - 1); - /* "sklearn/tree/_tree.pyx":896 + /* "sklearn/tree/_tree.pyx":993 * * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: # <<<<<<<<<<<<<< @@ -7731,7 +8057,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_b])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":897 + /* "sklearn/tree/_tree.pyx":994 * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: * b = b - 1 # <<<<<<<<<<<<<< @@ -7741,7 +8067,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_b = (__pyx_v_b - 1); } - /* "sklearn/tree/_tree.pyx":899 + /* "sklearn/tree/_tree.pyx":996 * b = b - 1 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -7757,7 +8083,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":900 + /* "sklearn/tree/_tree.pyx":997 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: * continue # <<<<<<<<<<<<<< @@ -7769,43 +8095,43 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":903 + /* "sklearn/tree/_tree.pyx":1000 * * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * # <<<<<<<<<<<<<< * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: */ - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":904 + /* "sklearn/tree/_tree.pyx":1001 * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) # <<<<<<<<<<<<<< * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] */ - __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":905 + /* "sklearn/tree/_tree.pyx":1002 * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -7815,7 +8141,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":906 + /* "sklearn/tree/_tree.pyx":1003 * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -7827,7 +8153,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":909 + /* "sklearn/tree/_tree.pyx":1006 * * # Find the sample just greater than t * c = a + 1 # <<<<<<<<<<<<<< @@ -7836,7 +8162,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_c = (__pyx_v_a + 1); - /* "sklearn/tree/_tree.pyx":911 + /* "sklearn/tree/_tree.pyx":1008 * c = a + 1 * * while True: # <<<<<<<<<<<<<< @@ -7846,7 +8172,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":912 + /* "sklearn/tree/_tree.pyx":1009 * * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: # <<<<<<<<<<<<<< @@ -7856,7 +8182,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_c])]) != 0); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":913 + /* "sklearn/tree/_tree.pyx":1010 * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: # <<<<<<<<<<<<<< @@ -7872,7 +8198,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":914 + /* "sklearn/tree/_tree.pyx":1011 * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: * break # <<<<<<<<<<<<<< @@ -7887,7 +8213,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L15:; - /* "sklearn/tree/_tree.pyx":916 + /* "sklearn/tree/_tree.pyx":1013 * break * * c += 1 # <<<<<<<<<<<<<< @@ -7898,25 +8224,25 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L14_break:; - /* "sklearn/tree/_tree.pyx":919 + /* "sklearn/tree/_tree.pyx":1016 * * # Better than the best so far? - * n_left = criterion.update(0, c, y_ptr, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< + * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< * error = criterion.eval() * */ - __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, 0, __pyx_v_c, __pyx_v_y_ptr, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); + __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, 0, __pyx_v_c, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":920 + /* "sklearn/tree/_tree.pyx":1017 * # Better than the best so far? - * n_left = criterion.update(0, c, y_ptr, X_argsorted_i, sample_mask_ptr) + * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) * error = criterion.eval() # <<<<<<<<<<<<<< * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":922 + /* "sklearn/tree/_tree.pyx":1019 * error = criterion.eval() * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -7932,7 +8258,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":923 + /* "sklearn/tree/_tree.pyx":1020 * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * continue # <<<<<<<<<<<<<< @@ -7944,7 +8270,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L17:; - /* "sklearn/tree/_tree.pyx":925 + /* "sklearn/tree/_tree.pyx":1022 * continue * * if error < best_error: # <<<<<<<<<<<<<< @@ -7954,7 +8280,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":926 + /* "sklearn/tree/_tree.pyx":1023 * * if error < best_error: * best_i = i # <<<<<<<<<<<<<< @@ -7963,7 +8289,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":927 + /* "sklearn/tree/_tree.pyx":1024 * if error < best_error: * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -7972,7 +8298,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":928 + /* "sklearn/tree/_tree.pyx":1025 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -7986,21 +8312,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_L5_continue:; } - /* "sklearn/tree/_tree.pyx":930 + /* "sklearn/tree/_tree.pyx":1027 * best_error = error * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); @@ -8204,7 +8530,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -8244,7 +8570,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * * info.buf = PyArray_DATA(self) */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -8514,7 +8840,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -8754,7 +9080,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_8), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -9294,7 +9620,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * if ((child.byteorder == '>' and little_endian) or */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -9345,7 +9671,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -9450,7 +9776,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9796,7 +10122,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 * else: */ - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_8), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_7), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); @@ -10182,58 +10508,12 @@ static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_ClassificationCriterion(PyTy if (!o) return 0; p = ((struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; - p->ndarray_label_count_left = Py_None; Py_INCREF(Py_None); - p->ndarray_label_count_right = Py_None; Py_INCREF(Py_None); - p->ndarray_label_count_init = Py_None; Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_7sklearn_4tree_5_tree_ClassificationCriterion(PyObject *o) { - struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)o; - Py_XDECREF(p->ndarray_label_count_left); - Py_XDECREF(p->ndarray_label_count_right); - Py_XDECREF(p->ndarray_label_count_init); - __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion(o); -} - -static int __pyx_tp_traverse_7sklearn_4tree_5_tree_ClassificationCriterion(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)o; - if (__pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_traverse) { - e = __pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_traverse(o, v, a); if (e) return e; - } - if (p->ndarray_label_count_left) { - e = (*v)(p->ndarray_label_count_left, a); if (e) return e; - } - if (p->ndarray_label_count_right) { - e = (*v)(p->ndarray_label_count_right, a); if (e) return e; - } - if (p->ndarray_label_count_init) { - e = (*v)(p->ndarray_label_count_init, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_7sklearn_4tree_5_tree_ClassificationCriterion(PyObject *o) { - struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *)o; - PyObject* tmp; - if (__pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_clear) { - __pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_clear(o); - } - tmp = ((PyObject*)p->ndarray_label_count_left); - p->ndarray_label_count_left = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_label_count_right); - p->ndarray_label_count_right = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_label_count_init); - p->ndarray_label_count_init = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_ClassificationCriterion[] = { - {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3__del__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -10340,7 +10620,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion = { __Pyx_NAMESTR("sklearn.tree._tree.ClassificationCriterion"), /*tp_name*/ sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_dealloc*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -10359,10 +10639,10 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_ClassificationCriterion, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ __Pyx_DOCSTR("Abstract criterion for classification.\n\n Attributes\n ----------\n n_classes : int\n The number of classes.\n\n n_samples : int\n The number of samples.\n\n label_count_left : int*\n The label counts for samples left of splitting point.\n\n label_count_right : int*\n The label counts for samples right of splitting point.\n\n label_count_init : int*\n The initial label counts for samples right of splitting point.\n Used to reset `label_count_right` for each feature.\n\n n_left : int\n The number of samples left of splitting point.\n\n n_right : int\n The number of samples right of splitting point.\n "), /*tp_doc*/ - __pyx_tp_traverse_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_traverse*/ - __pyx_tp_clear_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -10394,7 +10674,7 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini __pyx_vtable_7sklearn_ static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_Gini(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_7sklearn_4tree_5_tree_Gini *p; - PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_ClassificationCriterion(t, a, k); + PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_Criterion(t, a, k); if (!o) return 0; p = ((struct __pyx_obj_7sklearn_4tree_5_tree_Gini *)o); p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_Gini; @@ -10508,7 +10788,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_Gini = { __Pyx_NAMESTR("sklearn.tree._tree.Gini"), /*tp_name*/ sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_Gini), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_dealloc*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -10527,10 +10807,10 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_Gini = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Gini, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ __Pyx_DOCSTR("Gini Index splitting criteria.\n\n Gini index = \\sum_{k=0}^{K-1} pmk (1 - pmk)\n = 1 - \\sum_{k=0}^{K-1} pmk ** 2\n "), /*tp_doc*/ - __pyx_tp_traverse_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_traverse*/ - __pyx_tp_clear_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -10562,7 +10842,7 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy __pyx_vtable_7sklea static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_Entropy(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_7sklearn_4tree_5_tree_Entropy *p; - PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_ClassificationCriterion(t, a, k); + PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_Criterion(t, a, k); if (!o) return 0; p = ((struct __pyx_obj_7sklearn_4tree_5_tree_Entropy *)o); p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_Entropy; @@ -10676,7 +10956,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_Entropy = { __Pyx_NAMESTR("sklearn.tree._tree.Entropy"), /*tp_name*/ sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_Entropy), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_dealloc*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -10695,10 +10975,10 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_Entropy = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Entropy, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ __Pyx_DOCSTR("Entropy splitting criteria.\n\n Cross Entropy = - \\sum_{k=0}^{K-1} pmk log(pmk)\n "), /*tp_doc*/ - __pyx_tp_traverse_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_traverse*/ - __pyx_tp_clear_7sklearn_4tree_5_tree_ClassificationCriterion, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -10734,98 +11014,12 @@ static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_RegressionCriterion(PyTypeOb if (!o) return 0; p = ((struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; - p->ndarray_mean_left = Py_None; Py_INCREF(Py_None); - p->ndarray_mean_right = Py_None; Py_INCREF(Py_None); - p->ndarray_mean_init = Py_None; Py_INCREF(Py_None); - p->ndarray_sq_sum_left = Py_None; Py_INCREF(Py_None); - p->ndarray_sq_sum_right = Py_None; Py_INCREF(Py_None); - p->ndarray_sq_sum_init = Py_None; Py_INCREF(Py_None); - p->ndarray_var_left = Py_None; Py_INCREF(Py_None); - p->ndarray_var_right = Py_None; Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_7sklearn_4tree_5_tree_RegressionCriterion(PyObject *o) { - struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)o; - Py_XDECREF(p->ndarray_mean_left); - Py_XDECREF(p->ndarray_mean_right); - Py_XDECREF(p->ndarray_mean_init); - Py_XDECREF(p->ndarray_sq_sum_left); - Py_XDECREF(p->ndarray_sq_sum_right); - Py_XDECREF(p->ndarray_sq_sum_init); - Py_XDECREF(p->ndarray_var_left); - Py_XDECREF(p->ndarray_var_right); - __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion(o); -} - -static int __pyx_tp_traverse_7sklearn_4tree_5_tree_RegressionCriterion(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)o; - if (__pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_traverse) { - e = __pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_traverse(o, v, a); if (e) return e; - } - if (p->ndarray_mean_left) { - e = (*v)(p->ndarray_mean_left, a); if (e) return e; - } - if (p->ndarray_mean_right) { - e = (*v)(p->ndarray_mean_right, a); if (e) return e; - } - if (p->ndarray_mean_init) { - e = (*v)(p->ndarray_mean_init, a); if (e) return e; - } - if (p->ndarray_sq_sum_left) { - e = (*v)(p->ndarray_sq_sum_left, a); if (e) return e; - } - if (p->ndarray_sq_sum_right) { - e = (*v)(p->ndarray_sq_sum_right, a); if (e) return e; - } - if (p->ndarray_sq_sum_init) { - e = (*v)(p->ndarray_sq_sum_init, a); if (e) return e; - } - if (p->ndarray_var_left) { - e = (*v)(p->ndarray_var_left, a); if (e) return e; - } - if (p->ndarray_var_right) { - e = (*v)(p->ndarray_var_right, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_7sklearn_4tree_5_tree_RegressionCriterion(PyObject *o) { - struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *p = (struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion *)o; - PyObject* tmp; - if (__pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_clear) { - __pyx_ptype_7sklearn_4tree_5_tree_Criterion->tp_clear(o); - } - tmp = ((PyObject*)p->ndarray_mean_left); - p->ndarray_mean_left = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_mean_right); - p->ndarray_mean_right = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_mean_init); - p->ndarray_mean_init = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_sq_sum_left); - p->ndarray_sq_sum_left = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_sq_sum_right); - p->ndarray_sq_sum_right = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_sq_sum_init); - p->ndarray_sq_sum_init = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_var_left); - p->ndarray_var_left = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->ndarray_var_right); - p->ndarray_var_right = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - static PyMethodDef __pyx_methods_7sklearn_4tree_5_tree_RegressionCriterion[] = { - {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3__del__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("init_value"), (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -10932,7 +11126,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion = { __Pyx_NAMESTR("sklearn.tree._tree.RegressionCriterion"), /*tp_name*/ sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_dealloc*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -10951,10 +11145,10 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_RegressionCriterion, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ __Pyx_DOCSTR("Abstract criterion for regression. Computes variance of the\n target values left and right of the split point.\n\n Computation is linear in `n_samples` by using ::\n\n var = \\sum_i^n (y_i - y_bar) ** 2\n = (\\sum_i^n y_i ** 2) - n_samples y_bar ** 2\n\n Attributes\n ----------\n n_samples : int\n The number of samples\n\n mean_left : double\n The mean target value of the samples left of the split point.\n\n mean_right : double\n The mean target value of the samples right of the split.\n\n sq_sum_left : double\n The sum of squared target values left of the split point.\n\n sq_sum_right : double\n The sum of squared target values right of the split point.\n\n var_left : double\n The variance of the target values left of the split point.\n\n var_right : double\n The variance of the target values left of the split point.\n\n n_left : int\n number of samples left of split point.\n\n n_right : int\n number of samples right of split point.\n "), /*tp_doc*/ - __pyx_tp_traverse_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_traverse*/ - __pyx_tp_clear_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -10986,7 +11180,7 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE __pyx_vtable_7sklearn_4 static PyObject *__pyx_tp_new_7sklearn_4tree_5_tree_MSE(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_7sklearn_4tree_5_tree_MSE *p; - PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_RegressionCriterion(t, a, k); + PyObject *o = __pyx_tp_new_7sklearn_4tree_5_tree_Criterion(t, a, k); if (!o) return 0; p = ((struct __pyx_obj_7sklearn_4tree_5_tree_MSE *)o); p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion*)__pyx_vtabptr_7sklearn_4tree_5_tree_MSE; @@ -11100,7 +11294,7 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { __Pyx_NAMESTR("sklearn.tree._tree.MSE"), /*tp_name*/ sizeof(struct __pyx_obj_7sklearn_4tree_5_tree_MSE), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_dealloc*/ + __pyx_tp_dealloc_7sklearn_4tree_5_tree_Criterion, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -11119,10 +11313,10 @@ static PyTypeObject __pyx_type_7sklearn_4tree_5_tree_MSE = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_MSE, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ __Pyx_DOCSTR("Mean squared error impurity criterion.\n\n MSE = var_left + var_right\n "), /*tp_doc*/ - __pyx_tp_traverse_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_traverse*/ - __pyx_tp_clear_7sklearn_4tree_5_tree_RegressionCriterion, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -11170,20 +11364,18 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_u_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 1, 0, 0}, - {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, - {&__pyx_n_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 1}, - {&__pyx_kp_u_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 1, 0, 0}, + {&__pyx_kp_u_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 1, 0, 0}, + {&__pyx_kp_u_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 1, 0, 0}, + {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0}, + {&__pyx_n_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 1}, + {&__pyx_n_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 1}, {&__pyx_n_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 1}, - {&__pyx_n_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 1}, - {&__pyx_n_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 1}, - {&__pyx_kp_u_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 1, 0, 0}, - {&__pyx_kp_u_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 1, 0, 0}, + {&__pyx_n_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 1}, + {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0}, + {&__pyx_kp_u_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 1, 0, 0}, + {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0}, {&__pyx_kp_u_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 1, 0, 0}, - {&__pyx_kp_u_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0, 0}, - {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1}, {&__pyx_n_s__DTYPE, __pyx_k__DTYPE, sizeof(__pyx_k__DTYPE), 0, 0, 1, 1}, - {&__pyx_n_s__K, __pyx_k__K, sizeof(__pyx_k__K), 0, 0, 1, 1}, {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1}, @@ -11225,20 +11417,20 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__int32, __pyx_k__int32, sizeof(__pyx_k__int32), 0, 0, 1, 1}, {&__pyx_n_s__int8, __pyx_k__int8, sizeof(__pyx_k__int8), 0, 0, 1, 1}, {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1}, - {&__pyx_n_s__max, __pyx_k__max, sizeof(__pyx_k__max), 0, 0, 1, 1}, {&__pyx_n_s__max_features, __pyx_k__max_features, sizeof(__pyx_k__max_features), 0, 0, 1, 1}, {&__pyx_n_s__min_leaf, __pyx_k__min_leaf, sizeof(__pyx_k__min_leaf), 0, 0, 1, 1}, {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1}, {&__pyx_n_s__n_bagged, __pyx_k__n_bagged, sizeof(__pyx_k__n_bagged), 0, 0, 1, 1}, + {&__pyx_n_s__n_classes, __pyx_k__n_classes, sizeof(__pyx_k__n_classes), 0, 0, 1, 1}, {&__pyx_n_s__n_features, __pyx_k__n_features, sizeof(__pyx_k__n_features), 0, 0, 1, 1}, {&__pyx_n_s__n_left, __pyx_k__n_left, sizeof(__pyx_k__n_left), 0, 0, 1, 1}, + {&__pyx_n_s__n_outputs, __pyx_k__n_outputs, sizeof(__pyx_k__n_outputs), 0, 0, 1, 1}, {&__pyx_n_s__n_samples, __pyx_k__n_samples, sizeof(__pyx_k__n_samples), 0, 0, 1, 1}, {&__pyx_n_s__n_total_in_bag, __pyx_k__n_total_in_bag, sizeof(__pyx_k__n_total_in_bag), 0, 0, 1, 1}, {&__pyx_n_s__n_total_samples, __pyx_k__n_total_samples, sizeof(__pyx_k__n_total_samples), 0, 0, 1, 1}, {&__pyx_n_s__node_id, __pyx_k__node_id, sizeof(__pyx_k__node_id), 0, 0, 1, 1}, {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, - {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1}, {&__pyx_n_s__out, __pyx_k__out, sizeof(__pyx_k__out), 0, 0, 1, 1}, {&__pyx_n_s__permutation, __pyx_k__permutation, sizeof(__pyx_k__permutation), 0, 0, 1, 1}, {&__pyx_n_s__pred, __pyx_k__pred, sizeof(__pyx_k__pred), 0, 0, 1, 1}, @@ -11249,20 +11441,20 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__sample_mask_ptr, __pyx_k__sample_mask_ptr, sizeof(__pyx_k__sample_mask_ptr), 0, 0, 1, 1}, {&__pyx_n_s__t, __pyx_k__t, sizeof(__pyx_k__t), 0, 0, 1, 1}, {&__pyx_n_s__threshold, __pyx_k__threshold, sizeof(__pyx_k__threshold), 0, 0, 1, 1}, - {&__pyx_n_s__unique, __pyx_k__unique, sizeof(__pyx_k__unique), 0, 0, 1, 1}, {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1}, {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1}, {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, {&__pyx_n_s__y_ptr, __pyx_k__y_ptr, sizeof(__pyx_k__y_ptr), 0, 0, 1, 1}, + {&__pyx_n_s__y_stride, __pyx_k__y_stride, sizeof(__pyx_k__y_stride), 0, 0, 1, 1}, {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION >= 3 - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -11275,17 +11467,6 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "sklearn/tree/_tree.pyx":131 - * if y.ndim == 2: - * for k from 0 <= k < self.n_outputs: - * n_classes[k] = len(np.unique(y[:, k])) # <<<<<<<<<<<<<< - * else: - * n_classes[0] = len(np.unique(y)) - */ - __pyx_k_slice_1 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_slice_1); - __Pyx_GIVEREF(__pyx_k_slice_1); - /* "numpy.pxd":214 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): @@ -11293,12 +11474,12 @@ static int __Pyx_InitCachedConstants(void) { * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_3); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_2)); - PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_u_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3)); + __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_1)); + PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_u_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); /* "numpy.pxd":218 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) @@ -11307,12 +11488,12 @@ static int __Pyx_InitCachedConstants(void) { * * info.buf = PyArray_DATA(self) */ - __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_5); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_4)); - PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_u_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); + __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_4); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_3)); + PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_u_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); /* "numpy.pxd":256 * if ((descr.byteorder == '>' and little_endian) or @@ -11321,12 +11502,12 @@ static int __Pyx_InitCachedConstants(void) { * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_7); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_6)); - PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_u_6)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_6)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); + __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_6); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_5)); + PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_u_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); /* "numpy.pxd":798 * @@ -11335,12 +11516,12 @@ static int __Pyx_InitCachedConstants(void) { * * if ((child.byteorder == '>' and little_endian) or */ - __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_10); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_9)); - PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_u_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); + __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_9); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_8)); + PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_u_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_8)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9)); /* "numpy.pxd":802 * if ((child.byteorder == '>' and little_endian) or @@ -11349,12 +11530,12 @@ static int __Pyx_InitCachedConstants(void) { * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_11); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_6)); - PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_kp_u_6)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_6)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11)); + __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_10); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_5)); + PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_u_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); /* "numpy.pxd":822 * t = child.type_num @@ -11363,384 +11544,399 @@ static int __Pyx_InitCachedConstants(void) { * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_13); - __Pyx_INCREF(((PyObject *)__pyx_kp_u_12)); - PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_u_12)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_12)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_12); + __Pyx_INCREF(((PyObject *)__pyx_kp_u_11)); + PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_u_11)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_11)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); - /* "sklearn/tree/_tree.pyx":513 + /* "sklearn/tree/_tree.pyx":601 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_k_tuple_14 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_14); + __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_13); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_n_s__n_total_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_in_bag)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 1, ((PyObject *)__pyx_n_s__n_total_in_bag)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 1, ((PyObject *)__pyx_n_s__n_total_in_bag)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_in_bag)); __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 2, ((PyObject *)__pyx_n_s__random_state)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 2, ((PyObject *)__pyx_n_s__random_state)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); __Pyx_INCREF(((PyObject *)__pyx_n_s__rand)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 3, ((PyObject *)__pyx_n_s__rand)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 3, ((PyObject *)__pyx_n_s__rand)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rand)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 4, ((PyObject *)__pyx_n_s__sample_mask)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 4, ((PyObject *)__pyx_n_s__sample_mask)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_bagged)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 5, ((PyObject *)__pyx_n_s__n_bagged)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 5, ((PyObject *)__pyx_n_s__n_bagged)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_bagged)); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 6, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_13, 6, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); - __pyx_k_codeobj_15 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s___random_sample_mask, 513, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); + __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 601, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":546 + /* "sklearn/tree/_tree.pyx":634 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_18 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_18); + __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_17); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_n_s__X)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__X)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); __Pyx_INCREF(((PyObject *)__pyx_n_s__children)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 1, ((PyObject *)__pyx_n_s__children)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 1, ((PyObject *)__pyx_n_s__children)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__children)); __Pyx_INCREF(((PyObject *)__pyx_n_s__feature)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 2, ((PyObject *)__pyx_n_s__feature)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 2, ((PyObject *)__pyx_n_s__feature)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature)); __Pyx_INCREF(((PyObject *)__pyx_n_s__threshold)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 3, ((PyObject *)__pyx_n_s__threshold)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 3, ((PyObject *)__pyx_n_s__threshold)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__threshold)); __Pyx_INCREF(((PyObject *)__pyx_n_s__out)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 4, ((PyObject *)__pyx_n_s__out)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 4, ((PyObject *)__pyx_n_s__out)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__out)); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 5, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 5, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 6, ((PyObject *)__pyx_n_s__n)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 6, ((PyObject *)__pyx_n_s__n)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n)); __Pyx_INCREF(((PyObject *)__pyx_n_s__node_id)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 7, ((PyObject *)__pyx_n_s__node_id)); + PyTuple_SET_ITEM(__pyx_k_tuple_17, 7, ((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); - __pyx_k_codeobj_19 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s___apply_tree, 546, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); + __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 634, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":567 + /* "sklearn/tree/_tree.pyx":655 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_20 = PyTuple_New(11); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_20); + __pyx_k_tuple_19 = PyTuple_New(13); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_19); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_n_s__X)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_n_s__X)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); __Pyx_INCREF(((PyObject *)__pyx_n_s__children)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 1, ((PyObject *)__pyx_n_s__children)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 1, ((PyObject *)__pyx_n_s__children)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__children)); __Pyx_INCREF(((PyObject *)__pyx_n_s__feature)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 2, ((PyObject *)__pyx_n_s__feature)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 2, ((PyObject *)__pyx_n_s__feature)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature)); __Pyx_INCREF(((PyObject *)__pyx_n_s__threshold)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 3, ((PyObject *)__pyx_n_s__threshold)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 3, ((PyObject *)__pyx_n_s__threshold)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__threshold)); __Pyx_INCREF(((PyObject *)__pyx_n_s__values)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 4, ((PyObject *)__pyx_n_s__values)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 4, ((PyObject *)__pyx_n_s__values)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__values)); __Pyx_INCREF(((PyObject *)__pyx_n_s__pred)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 5, ((PyObject *)__pyx_n_s__pred)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 5, ((PyObject *)__pyx_n_s__pred)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pred)); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 6, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 6, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 7, ((PyObject *)__pyx_n_s__n)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 7, ((PyObject *)__pyx_n_s__n)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n)); __Pyx_INCREF(((PyObject *)__pyx_n_s__node_id)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 8, ((PyObject *)__pyx_n_s__node_id)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 8, ((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__K)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 9, ((PyObject *)__pyx_n_s__K)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__K)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__n_outputs)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 9, ((PyObject *)__pyx_n_s__n_outputs)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_outputs)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__n_classes)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 10, ((PyObject *)__pyx_n_s__n_classes)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_classes)); __Pyx_INCREF(((PyObject *)__pyx_n_s__k)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 10, ((PyObject *)__pyx_n_s__k)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 11, ((PyObject *)__pyx_n_s__k)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); - __pyx_k_codeobj_21 = (PyObject*)__Pyx_PyCode_New(6, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s___predict_tree, 567, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(((PyObject *)__pyx_n_s__c)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 12, ((PyObject *)__pyx_n_s__c)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); + __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 655, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":590 + /* "sklearn/tree/_tree.pyx":682 * * - * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< - * np.ndarray sample_mask, Criterion criterion, - * int n_samples): + * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< + * np.ndarray sample_mask, + * Criterion criterion, */ - __pyx_k_tuple_22 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_22); + __pyx_k_tuple_21 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_n_s__y)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__y)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 1, ((PyObject *)__pyx_n_s__sample_mask)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 1, ((PyObject *)__pyx_n_s__sample_mask)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 2, ((PyObject *)__pyx_n_s__criterion)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 2, ((PyObject *)__pyx_n_s__criterion)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 3, ((PyObject *)__pyx_n_s__n_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 3, ((PyObject *)__pyx_n_s__n_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 4, ((PyObject *)__pyx_n_s__n_total_samples)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 5, ((PyObject *)__pyx_n_s__y_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 4, ((PyObject *)__pyx_n_s__y_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 5, ((PyObject *)__pyx_n_s__y_stride)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_stride)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 6, ((PyObject *)__pyx_n_s__n_total_samples)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 6, ((PyObject *)__pyx_n_s__sample_mask_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 7, ((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); - __pyx_k_codeobj_23 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s___error_at_leaf, 590, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); + __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 682, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":637 + /* "sklearn/tree/_tree.pyx":733 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_26 = PyTuple_New(33); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_26); + __pyx_k_tuple_25 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_25); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_n_s__X)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__X)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 1, ((PyObject *)__pyx_n_s__y)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 1, ((PyObject *)__pyx_n_s__y)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 2, ((PyObject *)__pyx_n_s__X_argsorted)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 2, ((PyObject *)__pyx_n_s__X_argsorted)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 3, ((PyObject *)__pyx_n_s__sample_mask)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 3, ((PyObject *)__pyx_n_s__sample_mask)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 4, ((PyObject *)__pyx_n_s__n_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 4, ((PyObject *)__pyx_n_s__n_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__min_leaf)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 5, ((PyObject *)__pyx_n_s__min_leaf)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 5, ((PyObject *)__pyx_n_s__min_leaf)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__min_leaf)); __Pyx_INCREF(((PyObject *)__pyx_n_s__max_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 6, ((PyObject *)__pyx_n_s__max_features)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 6, ((PyObject *)__pyx_n_s__max_features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_features)); __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 7, ((PyObject *)__pyx_n_s__criterion)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 7, ((PyObject *)__pyx_n_s__criterion)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 8, ((PyObject *)__pyx_n_s__random_state)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 8, ((PyObject *)__pyx_n_s__random_state)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 9, ((PyObject *)__pyx_n_s__n_total_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 9, ((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 10, ((PyObject *)__pyx_n_s__n_features)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 10, ((PyObject *)__pyx_n_s__n_features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_features)); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 11, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 11, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__a)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 12, ((PyObject *)__pyx_n_s__a)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 12, ((PyObject *)__pyx_n_s__a)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a)); __Pyx_INCREF(((PyObject *)__pyx_n_s__b)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 13, ((PyObject *)__pyx_n_s__b)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 13, ((PyObject *)__pyx_n_s__b)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 14, ((PyObject *)__pyx_n_s__best_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 14, ((PyObject *)__pyx_n_s__best_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__feature_idx)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 15, ((PyObject *)__pyx_n_s__feature_idx)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 15, ((PyObject *)__pyx_n_s__feature_idx)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature_idx)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_left)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 16, ((PyObject *)__pyx_n_s__n_left)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 16, ((PyObject *)__pyx_n_s__n_left)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_left)); __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 17, ((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 17, ((PyObject *)__pyx_n_s__t)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); __Pyx_INCREF(((PyObject *)__pyx_n_s__initial_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 18, ((PyObject *)__pyx_n_s__initial_error)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 18, ((PyObject *)__pyx_n_s__initial_error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__initial_error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__error)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 19, ((PyObject *)__pyx_n_s__error)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 19, ((PyObject *)__pyx_n_s__error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 20, ((PyObject *)__pyx_n_s__best_error)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 20, ((PyObject *)__pyx_n_s__best_error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_t)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 21, ((PyObject *)__pyx_n_s__best_t)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 21, ((PyObject *)__pyx_n_s__best_t)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 22, ((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 23, ((PyObject *)__pyx_n_s__X_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 22, ((PyObject *)__pyx_n_s__X_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 24, ((PyObject *)__pyx_n_s__X_argsorted_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 23, ((PyObject *)__pyx_n_s__X_argsorted_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_i)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 24, ((PyObject *)__pyx_n_s__y_ptr)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 25, ((PyObject *)__pyx_n_s__sample_mask_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 25, ((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__features)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 26, ((PyObject *)__pyx_n_s__features)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 26, ((PyObject *)__pyx_n_s__features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__features)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 27, ((PyObject *)__pyx_n_s__y_stride)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_elem_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 27, ((PyObject *)__pyx_n_s__X_elem_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 28, ((PyObject *)__pyx_n_s__X_elem_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_elem_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_col_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 28, ((PyObject *)__pyx_n_s__X_col_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 29, ((PyObject *)__pyx_n_s__X_col_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_col_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 29, ((PyObject *)__pyx_n_s__X_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 30, ((PyObject *)__pyx_n_s__X_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_stride)); + __Pyx_INCREF(((PyObject *)__pyx_n_s_23)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 31, ((PyObject *)__pyx_n_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s_23)); __Pyx_INCREF(((PyObject *)__pyx_n_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 30, ((PyObject *)__pyx_n_s_24)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 32, ((PyObject *)__pyx_n_s_24)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s_24)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_25)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 31, ((PyObject *)__pyx_n_s_25)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_25)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 32, ((PyObject *)__pyx_n_s__X_argsorted_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 33, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - __pyx_k_codeobj_27 = (PyObject*)__Pyx_PyCode_New(9, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s___find_best_split, 637, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); + __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 733, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":783 + /* "sklearn/tree/_tree.pyx":879 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_28 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_28); + __pyx_k_tuple_27 = PyTuple_New(35); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_27); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 0, ((PyObject *)__pyx_n_s__X)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__X)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X)); __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 1, ((PyObject *)__pyx_n_s__y)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 1, ((PyObject *)__pyx_n_s__y)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 2, ((PyObject *)__pyx_n_s__X_argsorted)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 2, ((PyObject *)__pyx_n_s__X_argsorted)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 3, ((PyObject *)__pyx_n_s__sample_mask)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 3, ((PyObject *)__pyx_n_s__sample_mask)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 4, ((PyObject *)__pyx_n_s__n_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 4, ((PyObject *)__pyx_n_s__n_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__min_leaf)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 5, ((PyObject *)__pyx_n_s__min_leaf)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 5, ((PyObject *)__pyx_n_s__min_leaf)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__min_leaf)); __Pyx_INCREF(((PyObject *)__pyx_n_s__max_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 6, ((PyObject *)__pyx_n_s__max_features)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 6, ((PyObject *)__pyx_n_s__max_features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_features)); __Pyx_INCREF(((PyObject *)__pyx_n_s__criterion)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 7, ((PyObject *)__pyx_n_s__criterion)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 7, ((PyObject *)__pyx_n_s__criterion)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__criterion)); __Pyx_INCREF(((PyObject *)__pyx_n_s__random_state)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 8, ((PyObject *)__pyx_n_s__random_state)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 8, ((PyObject *)__pyx_n_s__random_state)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__random_state)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 9, ((PyObject *)__pyx_n_s__n_total_samples)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 9, ((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_total_samples)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_features)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 10, ((PyObject *)__pyx_n_s__n_features)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 10, ((PyObject *)__pyx_n_s__n_features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_features)); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 11, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 11, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__a)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 12, ((PyObject *)__pyx_n_s__a)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 12, ((PyObject *)__pyx_n_s__a)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a)); __Pyx_INCREF(((PyObject *)__pyx_n_s__b)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 13, ((PyObject *)__pyx_n_s__b)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 13, ((PyObject *)__pyx_n_s__b)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b)); __Pyx_INCREF(((PyObject *)__pyx_n_s__c)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 14, ((PyObject *)__pyx_n_s__c)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 14, ((PyObject *)__pyx_n_s__c)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_left)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 15, ((PyObject *)__pyx_n_s__n_left)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 15, ((PyObject *)__pyx_n_s__n_left)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_left)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 16, ((PyObject *)__pyx_n_s__best_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 16, ((PyObject *)__pyx_n_s__best_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__feature_idx)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 17, ((PyObject *)__pyx_n_s__feature_idx)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 17, ((PyObject *)__pyx_n_s__feature_idx)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__feature_idx)); __Pyx_INCREF(((PyObject *)__pyx_n_s__t)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 18, ((PyObject *)__pyx_n_s__t)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 18, ((PyObject *)__pyx_n_s__t)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__t)); __Pyx_INCREF(((PyObject *)__pyx_n_s__initial_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 19, ((PyObject *)__pyx_n_s__initial_error)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 19, ((PyObject *)__pyx_n_s__initial_error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__initial_error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__error)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 20, ((PyObject *)__pyx_n_s__error)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 20, ((PyObject *)__pyx_n_s__error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_error)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 21, ((PyObject *)__pyx_n_s__best_error)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 21, ((PyObject *)__pyx_n_s__best_error)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_error)); __Pyx_INCREF(((PyObject *)__pyx_n_s__best_t)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 22, ((PyObject *)__pyx_n_s__best_t)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 22, ((PyObject *)__pyx_n_s__best_t)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__best_t)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 23, ((PyObject *)__pyx_n_s__y_ptr)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 24, ((PyObject *)__pyx_n_s__X_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 23, ((PyObject *)__pyx_n_s__X_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_i)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 25, ((PyObject *)__pyx_n_s__X_argsorted_i)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 24, ((PyObject *)__pyx_n_s__X_argsorted_i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_i)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 25, ((PyObject *)__pyx_n_s__y_ptr)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 26, ((PyObject *)__pyx_n_s__sample_mask_ptr)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 26, ((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__features)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 27, ((PyObject *)__pyx_n_s__features)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 27, ((PyObject *)__pyx_n_s__features)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__features)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__y_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 28, ((PyObject *)__pyx_n_s__y_stride)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_elem_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 28, ((PyObject *)__pyx_n_s__X_elem_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 29, ((PyObject *)__pyx_n_s__X_elem_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_elem_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_col_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 29, ((PyObject *)__pyx_n_s__X_col_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 30, ((PyObject *)__pyx_n_s__X_col_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_col_stride)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 30, ((PyObject *)__pyx_n_s__X_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 31, ((PyObject *)__pyx_n_s__X_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_stride)); + __Pyx_INCREF(((PyObject *)__pyx_n_s_23)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 32, ((PyObject *)__pyx_n_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s_23)); __Pyx_INCREF(((PyObject *)__pyx_n_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 31, ((PyObject *)__pyx_n_s_24)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 33, ((PyObject *)__pyx_n_s_24)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s_24)); - __Pyx_INCREF(((PyObject *)__pyx_n_s_25)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 32, ((PyObject *)__pyx_n_s_25)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_25)); __Pyx_INCREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 33, ((PyObject *)__pyx_n_s__X_argsorted_stride)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 34, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28)); - __pyx_k_codeobj_29 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s_30, 783, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); + __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 879, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -11750,6 +11946,7 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; @@ -11823,62 +12020,62 @@ PyMODINIT_FUNC PyInit__tree(void) /*--- Function export code ---*/ /*--- Type init code ---*/ __pyx_vtabptr_7sklearn_4tree_5_tree_Criterion = &__pyx_vtable_7sklearn_4tree_5_tree_Criterion; - __pyx_vtable_7sklearn_4tree_5_tree_Criterion.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_9Criterion_init; + __pyx_vtable_7sklearn_4tree_5_tree_Criterion.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_9Criterion_init; __pyx_vtable_7sklearn_4tree_5_tree_Criterion.reset = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_reset; - __pyx_vtable_7sklearn_4tree_5_tree_Criterion.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_update; + __pyx_vtable_7sklearn_4tree_5_tree_Criterion.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_update; __pyx_vtable_7sklearn_4tree_5_tree_Criterion.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_Criterion.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Criterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Criterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Criterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Criterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Criterion = &__pyx_type_7sklearn_4tree_5_tree_Criterion; __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; - __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init; + __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.reset = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset; - __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update; + __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init_value; __pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "ClassificationCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ClassificationCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion = &__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtabptr_7sklearn_4tree_5_tree_Gini = &__pyx_vtable_7sklearn_4tree_5_tree_Gini; __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_4Gini_eval; __pyx_type_7sklearn_4tree_5_tree_Gini.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Gini = &__pyx_type_7sklearn_4tree_5_tree_Gini; __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy = &__pyx_vtable_7sklearn_4tree_5_tree_Entropy; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_7Entropy_eval; __pyx_type_7sklearn_4tree_5_tree_Entropy.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Entropy = &__pyx_type_7sklearn_4tree_5_tree_Entropy; __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; - __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init; + __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.init = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int, int))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.reset = (void (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset; - __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update; + __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_value; __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtabptr_7sklearn_4tree_5_tree_MSE = &__pyx_vtable_7sklearn_4tree_5_tree_MSE; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_3MSE_eval; __pyx_type_7sklearn_4tree_5_tree_MSE.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_MSE = &__pyx_type_7sklearn_4tree_5_tree_MSE; /*--- Type import code ---*/ __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -11917,76 +12114,76 @@ PyMODINIT_FUNC PyInit__tree(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":513 + /* "sklearn/tree/_tree.pyx":601 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":546 + /* "sklearn/tree/_tree.pyx":634 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":567 + /* "sklearn/tree/_tree.pyx":655 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":590 + /* "sklearn/tree/_tree.pyx":682 * * - * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, # <<<<<<<<<<<<<< - * np.ndarray sample_mask, Criterion criterion, - * int n_samples): + * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< + * np.ndarray sample_mask, + * Criterion criterion, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":637 + /* "sklearn/tree/_tree.pyx":733 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":783 + /* "sklearn/tree/_tree.pyx":879 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_17); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_30, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "sklearn/tree/_tree.pyx":1 @@ -12069,6 +12266,31 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { return 0; } +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) @@ -12159,50 +12381,7 @@ static int __Pyx_ParseOptionalKeywords( return -1; } -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) -{ - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - return 0; - } - if (none_allowed && obj == Py_None) return 1; - else if (exact) { - if (Py_TYPE(obj) == type) return 1; - } - else { - if (PyObject_TypeCheck(obj, type)) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%s' has incorrect type (expected %s, got %s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; @@ -12772,6 +12951,26 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb #endif } +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (Py_TYPE(obj) == type) return 1; + } + else { + if (PyObject_TypeCheck(obj, type)) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + static void __Pyx_RaiseBufferFallbackError(void) { PyErr_Format(PyExc_ValueError, "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); @@ -13086,58 +13285,6 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { return module; } -static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject* x) { - const npy_int32 neg_one = (npy_int32)-1, const_zero = (npy_int32)0; - const int is_unsigned = const_zero < neg_one; - if (sizeof(npy_int32) == sizeof(char)) { - if (is_unsigned) - return (npy_int32)__Pyx_PyInt_AsUnsignedChar(x); - else - return (npy_int32)__Pyx_PyInt_AsSignedChar(x); - } else if (sizeof(npy_int32) == sizeof(short)) { - if (is_unsigned) - return (npy_int32)__Pyx_PyInt_AsUnsignedShort(x); - else - return (npy_int32)__Pyx_PyInt_AsSignedShort(x); - } else if (sizeof(npy_int32) == sizeof(int)) { - if (is_unsigned) - return (npy_int32)__Pyx_PyInt_AsUnsignedInt(x); - else - return (npy_int32)__Pyx_PyInt_AsSignedInt(x); - } else if (sizeof(npy_int32) == sizeof(long)) { - if (is_unsigned) - return (npy_int32)__Pyx_PyInt_AsUnsignedLong(x); - else - return (npy_int32)__Pyx_PyInt_AsSignedLong(x); - } else if (sizeof(npy_int32) == sizeof(PY_LONG_LONG)) { - if (is_unsigned) - return (npy_int32)__Pyx_PyInt_AsUnsignedLongLong(x); - else - return (npy_int32)__Pyx_PyInt_AsSignedLongLong(x); - } else { - npy_int32 val; - PyObject *v = __Pyx_PyNumber_Int(x); - #if PY_VERSION_HEX < 0x03000000 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } - return (npy_int32)-1; - } -} - #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index 0c76b904fae2a..c2271296107bd 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -17,6 +17,11 @@ DTYPE = np.float32 ctypedef np.float32_t DTYPE_t ctypedef np.int8_t BOOL_t +cdef extern from "stdlib.h": + void* malloc(size_t size) + void* calloc(size_t nmemb, size_t size) + void free(void* ptr) + cdef extern from "math.h": cdef extern double log(double x) cdef extern double pow(double base, double exponent) @@ -40,8 +45,9 @@ cdef extern from "float.h": cdef class Criterion: """Interface for splitting criteria (regression and classification)""" - cdef void init(self, DTYPE_t *y, - BOOL_t *sample_mask, + cdef void init(self, DTYPE_t* y, + int y_stride, + BOOL_t* sample_mask, int n_samples, int n_total_samples): """Initialise the criterion class for new split point.""" @@ -53,9 +59,10 @@ cdef class Criterion: cdef int update(self, int a, int b, - DTYPE_t *y, - int *X_argsorted_i, - BOOL_t *sample_mask): + DTYPE_t* y, + int y_stride, + int* X_argsorted_i, + BOOL_t* sample_mask): """Update the criteria for each value in interval [a,b) (where a and b are indices in `X_argsorted_i`).""" pass @@ -96,101 +103,112 @@ cdef class ClassificationCriterion(Criterion): n_right : int The number of samples right of splitting point. """ - cdef int y_stride cdef int n_outputs cdef int* n_classes - cdef int count_stride - cdef int n_samples + + cdef int label_count_stride cdef int* label_count_left cdef int* label_count_right cdef int* label_count_init + cdef int n_left cdef int n_right - # need to store ref to arrays to prevent GC - cdef ndarray_label_count_left - cdef ndarray_label_count_right - cdef ndarray_label_count_init - - def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): + def __init__(self, int n_outputs, object n_classes): cdef int k = 0 - if y.ndim == 2: - self.y_stride = y.strides[1] / y.strides[0] - self.n_outputs = y.shape[1] - else: - self.y_stride = 1 - self.n_outputs = 1 + self.n_outputs = n_outputs + self.n_classes = calloc(n_outputs, sizeof(int)) + cdef int label_count_stride = -1 - cdef np.ndarray[np.int32_t, ndim=1] n_classes = \ - np.zeros((self.n_outputs,), dtype=np.int32, order="C") + for k from 0 <= k < n_outputs: + self.n_classes[k] = n_classes[k] - if y.ndim == 2: - for k from 0 <= k < self.n_outputs: - n_classes[k] = len(np.unique(y[:, k])) - else: - n_classes[0] = len(np.unique(y)) + if n_classes[k] > label_count_stride: + label_count_stride = n_classes[k] - self.n_classes = n_classes.data - self.count_stride = np.max(n_classes) - - cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_left \ - = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") - cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_right \ - = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") - cdef np.ndarray[np.int32_t, ndim=2] ndarray_label_count_init \ - = np.zeros((self.n_outputs, self.count_stride), dtype=np.int32, order="C") + self.label_count_stride = label_count_stride + self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) + self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) + self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) self.n_samples = 0 self.n_left = 0 self.n_right = 0 - self.label_count_left = ndarray_label_count_left.data - self.label_count_right = ndarray_label_count_right.data - self.label_count_init = ndarray_label_count_init.data - self.ndarray_label_count_left = ndarray_label_count_left - self.ndarray_label_count_right = ndarray_label_count_right - self.ndarray_label_count_init = ndarray_label_count_init - - cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, - int n_total_samples): + + def __del__(self): + free(self.n_classes) + free(self.label_count_left) + free(self.label_count_right) + free(self.label_count_init) + + cdef void init(self, DTYPE_t* y, + int y_stride, + BOOL_t *sample_mask, + int n_samples, + int n_total_samples): """Initialise the criterion class.""" + cdef int n_outputs = self.n_outputs + cdef int* n_classes = self.n_classes + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_init = self.label_count_init + cdef int k = 0 cdef int c = 0 cdef int j = 0 self.n_samples = n_samples - for k from 0 <= k < self.n_outputs: - for c from 0 <= c < self.n_classes[k]: - self.label_count_init[k * self.count_stride + c] = 0 + for k from 0 <= k < n_outputs: + for c from 0 <= c < n_classes[k]: + label_count_init[k * label_count_stride + c] = 0 - for j from 0 <= j < n_total_samples: - if sample_mask[j] == 0: - continue + for j from 0 <= j < n_total_samples: + if sample_mask[j] == 0: + continue - c = (y[k * self.y_stride + j]) - self.label_count_init[k * self.count_stride + c] += 1 + for k from 0 <= k < n_outputs: + c = y[j * y_stride + k] + label_count_init[k * label_count_stride + c] += 1 self.reset() cdef void reset(self): """Reset label_counts by setting `label_count_left to zero and copying the init array into the right.""" + cdef int n_outputs = self.n_outputs + cdef int* n_classes = self.n_classes + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_init = self.label_count_init + cdef int* label_count_left = self.label_count_left + cdef int* label_count_right = self.label_count_right + cdef int k = 0 cdef int c = 0 self.n_left = 0 self.n_right = self.n_samples - for k from 0 <= k < self.n_outputs: - for c from 0 <= c < self.n_classes[k]: - self.label_count_left[k * self.count_stride + c] = 0 - self.label_count_right[k * self.count_stride + c] = self.label_count_init[k * self.count_stride + c] + for k from 0 <= k < n_outputs: + for c from 0 <= c < n_classes[k]: + label_count_left[k * label_count_stride + c] = 0 + label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] - cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, - BOOL_t *sample_mask): + cdef int update(self, int a, + int b, + DTYPE_t* y, + int y_stride, + int* X_argsorted_i, + BOOL_t* sample_mask): """Update the criteria for each value in interval [a,b) (where a and b are indices in `X_argsorted_i`).""" + cdef int n_outputs = self.n_outputs + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_left = self.label_count_left + cdef int* label_count_right = self.label_count_right + cdef int n_left = self.n_left + cdef int n_right = self.n_right + cdef int k cdef int c @@ -201,22 +219,35 @@ cdef class ClassificationCriterion(Criterion): if sample_mask[s] == 0: continue - for k from 0 <= k < self.n_outputs: - c = (y[k * self.y_stride + s]) - self.label_count_right[k * self.count_stride + c] -= 1 - self.label_count_left[k * self.count_stride + c] += 1 + for k from 0 <= k < n_outputs: + c = y[s * y_stride + k] + label_count_right[k * label_count_stride + c] -= 1 + label_count_left[k * label_count_stride + c] += 1 - self.n_right -= 1 - self.n_left += 1 + n_left += 1 + n_right -=1 - return self.n_left + self.n_left = n_left + self.n_right = n_right + + return n_left cdef double eval(self): pass cpdef np.ndarray init_value(self): - return self.ndarray_label_count_init + cdef int n_outputs = self.n_outputs + cdef int* n_classes = self.n_classes + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_init = self.label_count_init + + cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + + for k from 0 <= k < n_outputs: + for c from 0 <= c < n_classes[k]: + value[k, c] = (label_count_init[k * label_count_stride + c]) + return value cdef class Gini(ClassificationCriterion): """Gini Index splitting criteria. @@ -227,23 +258,30 @@ cdef class Gini(ClassificationCriterion): cdef double eval(self): """Returns Gini index of left branch + Gini index of right branch. """ - cdef double total = 0.0 + cdef int n_samples = self.n_samples + cdef int n_outputs = self.n_outputs + cdef int* n_classes = self.n_classes + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_left = self.label_count_left + cdef int* label_count_right = self.label_count_right cdef double n_left = self.n_left cdef double n_right = self.n_right + + cdef double total = 0.0 cdef double H_left cdef double H_right cdef int k, c, count_left, count_right - for k from 0 <= k < self.n_outputs: + for k from 0 <= k < n_outputs: H_left = n_left * n_left H_right = n_right * n_right - for c from 0 <= c < self.n_classes[k]: - count_left = self.label_count_left[k * self.count_stride + c] + for c from 0 <= c < n_classes[k]: + count_left = label_count_left[k * label_count_stride + c] if count_left > 0: H_left -= (count_left * count_left) - count_right = self.label_count_right[k * self.count_stride + c] + count_right = label_count_right[k * label_count_stride + c] if count_right > 0: H_right -= (count_right * count_right) @@ -259,7 +297,7 @@ cdef class Gini(ClassificationCriterion): total += (H_left + H_right) - return total / (self.n_samples * self.n_outputs) + return total / (n_samples * n_outputs) cdef class Entropy(ClassificationCriterion): @@ -270,33 +308,38 @@ cdef class Entropy(ClassificationCriterion): cdef double eval(self): """Returns Entropy of left branch + Entropy index of right branch. """ + cdef int n_samples = self.n_samples + cdef int n_outputs = self.n_outputs + cdef int* n_classes = self.n_classes + cdef int label_count_stride = self.label_count_stride + cdef int* label_count_left = self.label_count_left + cdef int* label_count_right = self.label_count_right + cdef double n_left = self.n_left + cdef double n_right = self.n_right + cdef double total = 0.0 cdef double H_left cdef double H_right cdef int k, c cdef double e1, e2 - cdef double n_left = self.n_left - cdef double n_right = self.n_right - for k from 0 <= k < self.n_outputs: + for k from 0 <= k < n_outputs: H_left = 0.0 H_right = 0.0 - for c from 0 <= c < self.n_classes[k]: - if self.label_count_left[k * self.count_stride + c] > 0: - H_left -= ((self.label_count_left[k * self.count_stride + c] / n_left) - * log(self.label_count_left[k * self.count_stride + c] / n_left)) + for c from 0 <= c < n_classes[k]: + if label_count_left[k * label_count_stride + c] > 0: + H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) - if self.label_count_right[k * self.count_stride + c] > 0: - H_right -= ((self.label_count_right[k * self.count_stride + c] / n_right) - * log(self.label_count_right[k * self.count_stride + c] / n_right)) + if self.label_count_right[k * label_count_stride + c] > 0: + H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) - e1 = (n_left / self.n_samples) * H_left - e2 = (n_right / self.n_samples) * H_right + e1 = (n_left / n_samples) * H_left + e2 = (n_right / n_samples) * H_right total += e1 + e2 - return total / self.n_outputs + return total / n_outputs cdef class RegressionCriterion(Criterion): @@ -338,94 +381,95 @@ cdef class RegressionCriterion(Criterion): number of samples right of split point. """ - cdef int y_stride cdef int n_outputs - cdef int n_samples + + cdef double* mean_left + cdef double* mean_right + cdef double* mean_init + cdef double* sq_sum_left + cdef double* sq_sum_right + cdef double* sq_sum_init + cdef double* var_left + cdef double* var_right + cdef int n_right cdef int n_left - cdef DTYPE_t* mean_left - cdef DTYPE_t* mean_right - cdef DTYPE_t* mean_init - cdef DTYPE_t* sq_sum_left - cdef DTYPE_t* sq_sum_right - cdef DTYPE_t* sq_sum_init - cdef DTYPE_t* var_left - cdef DTYPE_t* var_right - - # need to store ref to arrays to prevent GC - cdef ndarray_mean_left - cdef ndarray_mean_right - cdef ndarray_mean_init - cdef ndarray_sq_sum_left - cdef ndarray_sq_sum_right - cdef ndarray_sq_sum_init - cdef ndarray_var_left - cdef ndarray_var_right - - def __init__(self, np.ndarray[DTYPE_t, mode="fortran"] y): + def __init__(self, int n_outputs): cdef int k = 0 - if y.ndim == 2: - self.y_stride = y.strides[1] / y.strides[0] - self.n_outputs = y.shape[1] - else: - self.y_stride = 1 - self.n_outputs = 1 + self.n_outputs = n_outputs self.n_samples = 0 self.n_left = 0 self.n_right = 0 - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_mean_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_sq_sum_init = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_left = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - cdef np.ndarray[DTYPE_t, ndim=1] ndarray_var_right = np.zeros((self.n_outputs,), dtype=DTYPE, order="C") - - self.mean_left = ndarray_mean_left.data - self.mean_right = ndarray_mean_left.data - self.mean_init = ndarray_mean_init.data - self.sq_sum_right = ndarray_sq_sum_left.data - self.sq_sum_left = ndarray_sq_sum_right.data - self.sq_sum_init = ndarray_sq_sum_init.data - self.var_left = ndarray_var_left.data - self.var_right = ndarray_var_left.data - - cdef void init(self, DTYPE_t *y, BOOL_t *sample_mask, int n_samples, - int n_total_samples): + self.mean_left = calloc(n_outputs, sizeof(double)) + self.mean_right = calloc(n_outputs, sizeof(double)) + self.mean_init = calloc(n_outputs, sizeof(double)) + self.sq_sum_left = calloc(n_outputs, sizeof(double)) + self.sq_sum_right = calloc(n_outputs, sizeof(double)) + self.sq_sum_init = calloc(n_outputs, sizeof(double)) + self.var_left = calloc(n_outputs, sizeof(double)) + self.var_right = calloc(n_outputs, sizeof(double)) + + def __del__(self): + free(self.mean_left) + free(self.mean_right) + free(self.mean_init) + free(self.sq_sum_left) + free(self.sq_sum_right) + free(self.sq_sum_init) + free(self.var_left) + free(self.var_right) + + cdef void init(self, DTYPE_t* y, + int y_stride, + BOOL_t* sample_mask, + int n_samples, + int n_total_samples): """Initialise the criterion class; assume all samples are in the right branch and store the mean and squared sum in `self.mean_init` and `self.sq_sum_init`. """ + cdef double* mean_left = self.mean_left + cdef double* mean_right = self.mean_right + cdef double* mean_init = self.mean_init + cdef double* sq_sum_left = self.sq_sum_left + cdef double* sq_sum_right = self.sq_sum_right + cdef double* sq_sum_init = self.sq_sum_init + cdef double* var_left = self.var_left + cdef double* var_right = self.var_right + cdef int n_outputs = self.n_outputs + cdef int k = 0 - for k from 0 <= k < self.n_outputs: - self.mean_left[k] = 0.0 - self.mean_right[k] = 0.0 - self.mean_init[k] = 0.0 - self.sq_sum_right[k] = 0.0 - self.sq_sum_left[k] = 0.0 - self.sq_sum_init[k] = 0.0 - self.var_left[k] = 0.0 - self.var_right[k] = 0.0 + for k from 0 <= k < n_outputs: + mean_left[k] = 0.0 + mean_right[k] = 0.0 + mean_init[k] = 0.0 + sq_sum_right[k] = 0.0 + sq_sum_left[k] = 0.0 + sq_sum_init[k] = 0.0 + var_left[k] = 0.0 + var_right[k] = 0.0 self.n_samples = n_samples cdef int j = 0 + cdef DTYPE_t y_jk = 0.0 - for k from 0 <= k < self.n_outputs: - for j from 0 <= j < n_total_samples: - if sample_mask[j] == 0: - continue + for j from 0 <= j < n_total_samples: + if sample_mask[j] == 0: + continue - self.sq_sum_init[k] += (y[k * self.y_stride + j] * y[k * self.y_stride + j]) - self.mean_init[k] += y[k * self.y_stride + j] + for k from 0 <= k < n_outputs: + y_jk = y[j * y_stride + k] + sq_sum_init[k] += y_jk * y_jk + mean_init[k] += y_jk - self.mean_init[k] = self.mean_init[k] / self.n_samples + for k from 0 <= k < n_outputs: + mean_init[k] /= n_samples self.reset() @@ -436,24 +480,51 @@ cdef class RegressionCriterion(Criterion): whole dataset into the auxiliary variables of the right branch. """ + cdef double* mean_left = self.mean_left + cdef double* mean_right = self.mean_right + cdef double* mean_init = self.mean_init + cdef double* sq_sum_left = self.sq_sum_left + cdef double* sq_sum_right = self.sq_sum_right + cdef double* sq_sum_init = self.sq_sum_init + cdef double* var_left = self.var_left + cdef double* var_right = self.var_right + + cdef int n_samples = self.n_samples + cdef int n_outputs = self.n_outputs + cdef int k = 0 self.n_right = self.n_samples self.n_left = 0 - for k from 0 <= k < self.n_outputs: - self.mean_right[k] = self.mean_init[k] - self.mean_left[k] = 0.0 - self.sq_sum_right[k] = self.sq_sum_init[k] - self.sq_sum_left[k] = 0.0 - self.var_left[k] = 0.0 - self.var_right[k] = self.sq_sum_right[k] - \ - self.n_samples * (self.mean_right[k] * self.mean_right[k]) - - cdef int update(self, int a, int b, DTYPE_t *y, int *X_argsorted_i, - BOOL_t *sample_mask): + for k from 0 <= k < n_outputs: + mean_right[k] = mean_init[k] + mean_left[k] = 0.0 + sq_sum_right[k] = sq_sum_init[k] + sq_sum_left[k] = 0.0 + var_left[k] = 0.0 + var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) + + cdef int update(self, int a, + int b, + DTYPE_t* y, + int y_stride, + int* X_argsorted_i, + BOOL_t* sample_mask): """Update the criteria for each value in interval [a,b) (where a and b are indices in `X_argsorted_i`).""" + cdef double* mean_left = self.mean_left + cdef double* mean_right = self.mean_right + cdef double* sq_sum_left = self.sq_sum_left + cdef double* sq_sum_right = self.sq_sum_right + cdef double* var_left = self.var_left + cdef double* var_right = self.var_right + + cdef int n_samples = self.n_samples + cdef int n_outputs = self.n_outputs + cdef int n_left = self.n_left + cdef int n_right = self.n_right + cdef double y_idx = 0.0 cdef int idx, j, k @@ -464,28 +535,39 @@ cdef class RegressionCriterion(Criterion): if sample_mask[j] == 0: continue - for k from 0 <= k < self.n_outputs: - y_idx = y[k * self.y_stride + j] - self.sq_sum_left[k] += (y_idx * y_idx) - self.sq_sum_right[k] -= (y_idx * y_idx) + for k from 0 <= k < n_outputs: + y_idx = y[k * y_stride + j] + sq_sum_left[k] += (y_idx * y_idx) + sq_sum_right[k] -= (y_idx * y_idx) - self.mean_left[k] = (self.n_left * self.mean_left[k] + y_idx) / (self.n_left + 1) - self.mean_right[k] = ((self.n_samples - self.n_left) * self.mean_right[k] - y_idx) / (self.n_samples - self.n_left - 1) + mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) + mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) - self.n_right -= 1 - self.n_left += 1 + n_left += 1 + self.n_left = n_left + n_right -= 1 + self.n_right = n_right - for k from 0 <= k < self.n_outputs: - self.var_left[k] = self.sq_sum_left[k] - self.n_left * (self.mean_left[k] * self.mean_left[k]) - self.var_right[k] = self.sq_sum_right[k] - self.n_right * (self.mean_right[k] * self.mean_right[k]) + for k from 0 <= k < n_outputs: + var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) + var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) - return self.n_left + return n_left cdef double eval(self): pass cpdef np.ndarray init_value(self): - return self.ndarray_mean_init + cdef int n_outputs = self.n_outputs + cdef double* mean_init = self.mean_init + + cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, 1), dtype=DTYPE) + cdef int k + + for k from 0 <= k < n_outputs: + value[k, 0] = (mean_init[k]) + + return value cdef class MSE(RegressionCriterion): @@ -495,13 +577,19 @@ cdef class MSE(RegressionCriterion): """ cdef double eval(self): - cdef double total = 0.0 + cdef double* var_left = self.var_left + cdef double* var_right = self.var_right + + cdef int n_outputs = self.n_outputs + cdef int k + cdef double total = 0.0 - for k from 0 <= k < self.n_outputs: - total += self.var_left[k] + self.var_right[k] + for k from 0 <= k < n_outputs: + total += var_left[k] + total += var_right[k] - return total / self.n_outputs + return total / n_outputs @@ -568,13 +656,15 @@ def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, np.ndarray[np.int32_t, ndim=2] children, np.ndarray[np.int32_t, ndim=1] feature, np.ndarray[np.float64_t, ndim=1] threshold, - np.ndarray[np.float64_t, ndim=2] values, - np.ndarray[np.float64_t, ndim=2] pred): + np.ndarray[np.float64_t, ndim=3] values, + np.ndarray[np.float64_t, ndim=3] pred): """Finds the terminal region (=leaf node) values for each sample. """ cdef int i = 0 cdef int n = X.shape[0] cdef int node_id = 0 - cdef int K = values.shape[1] + cdef int n_outputs = values.shape[1] + cdef int n_classes = values.shape[2] + for i in xrange(n): node_id = 0 # While node_id not a leaf @@ -583,19 +673,25 @@ def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, node_id = children[node_id, 0] else: node_id = children[node_id, 1] - for k in xrange(K): - pred[i, k] = values[node_id, k] + + for k in xrange(n_outputs): + for c in xrange(n_classes): + pred[i, k, c] = values[node_id, k, c] -def _error_at_leaf(np.ndarray[DTYPE_t, ndim=1, mode="c"] y, - np.ndarray sample_mask, Criterion criterion, +def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, + np.ndarray sample_mask, + Criterion criterion, int n_samples): """Compute criterion error at leaf with terminal region defined by `sample_mask`. """ + cdef DTYPE_t* y_ptr = y.data + cdef int y_stride = y.strides[0] / y.strides[1] cdef int n_total_samples = y.shape[0] - cdef DTYPE_t *y_ptr = y.data cdef BOOL_t *sample_mask_ptr = sample_mask.data - criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + + criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) + return criterion.eval() @@ -635,7 +731,7 @@ cdef int smallest_sample_larger_than(int sample_idx, DTYPE_t *X_i, def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, - np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + np.ndarray[DTYPE_t, ndim=2, mode="c"] y, np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, np.ndarray sample_mask, int n_samples, @@ -700,14 +796,15 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef int n_left = 0 cdef DTYPE_t t, initial_error, error cdef DTYPE_t best_error = np.inf, best_t = np.inf - cdef DTYPE_t *y_ptr = y.data - cdef DTYPE_t *X_i = NULL - cdef int *X_argsorted_i = NULL - cdef BOOL_t *sample_mask_ptr = sample_mask.data - cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + cdef DTYPE_t* X_i = NULL + cdef int* X_argsorted_i = NULL + cdef DTYPE_t* y_ptr = y.data + cdef BOOL_t* sample_mask_ptr = sample_mask.data + cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # Compute the column strides (increment in pointer elements to get # from column i to i + 1) for `X` and `X_argsorted` + cdef int y_stride = y.strides[0] / y.strides[1] cdef int X_elem_stride = X.strides[0] cdef int X_col_stride = X.strides[1] cdef int X_stride = X_col_stride / X_elem_stride @@ -716,8 +813,8 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # Compute the initial criterion value in the node - X_argsorted_i = X_argsorted.data - criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + X_argsorted_i = X_argsorted.data + criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) initial_error = criterion.eval() if initial_error == 0: # break early if the node is pure @@ -732,13 +829,12 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, else: features = random_state.permutation(features)[:max_features] - # Look for the best split - for feature_idx in range(max_features): + for feature_idx from 0 <= feature_idx < max_features: i = features[feature_idx] # Get i-th col of X and X_sorted - X_i = (X.data) + X_stride * i - X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i + X_i = (X.data) + X_stride * i + X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # Reset the criterion for this feature criterion.reset() @@ -757,7 +853,7 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, break # Better split than the best so far? - n_left = criterion.update(a, b, y_ptr, X_argsorted_i, sample_mask_ptr) + n_left = criterion.update(a, b, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # Only consider splits that respect min_leaf if n_left < min_leaf or (n_samples - n_left) < min_leaf: @@ -781,7 +877,7 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, return best_i, best_t, best_error, initial_error def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, - np.ndarray[DTYPE_t, ndim=2, mode="fortran"] y, + np.ndarray[DTYPE_t, ndim=2, mode="c"] y, np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, np.ndarray sample_mask, int n_samples, @@ -845,14 +941,15 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef np.int32_t feature_idx = -1 cdef DTYPE_t t, initial_error, error cdef DTYPE_t best_error = np.inf, best_t = np.inf - cdef DTYPE_t *y_ptr = y.data - cdef DTYPE_t *X_i = NULL - cdef int *X_argsorted_i = NULL - cdef BOOL_t *sample_mask_ptr = sample_mask.data - cdef np.ndarray[np.int32_t, ndim=1, mode='c'] features = None + cdef DTYPE_t* X_i = NULL + cdef int* X_argsorted_i = NULL + cdef DTYPE_t* y_ptr = y.data + cdef BOOL_t* sample_mask_ptr = sample_mask.data + cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # Compute the column strides (increment in pointer elements to get # from column i to i + 1) for `X` and `X_argsorted` + cdef int y_stride = y.strides[0] / y.strides[1] cdef int X_elem_stride = X.strides[0] cdef int X_col_stride = X.strides[1] cdef int X_stride = X_col_stride / X_elem_stride @@ -861,8 +958,8 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # Compute the initial criterion value - X_argsorted_i = X_argsorted.data - criterion.init(y_ptr, sample_mask_ptr, n_samples, n_total_samples) + X_argsorted_i = X_argsorted.data + criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) initial_error = criterion.eval() if initial_error == 0: # break early if the node is pure @@ -878,11 +975,11 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, features = random_state.permutation(features)[:max_features] # Look for the best random split - for feature_idx in range(max_features): + for feature_idx from 0 <= feature_idx < max_features: i = features[feature_idx] # Get i-th col of X and X_sorted - X_i = (X.data) + X_stride * i - X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i + X_i = (X.data) + X_stride * i + X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # Reset the criterion for this feature criterion.reset() @@ -916,7 +1013,7 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, c += 1 # Better than the best so far? - n_left = criterion.update(0, c, y_ptr, X_argsorted_i, sample_mask_ptr) + n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) error = criterion.eval() if n_left < min_leaf or (n_samples - n_left) < min_leaf: diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 14fe00fb3ee39..e966606e4154d 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -37,7 +37,7 @@ def test_classification_toy(): """Check classification on a toy dataset.""" - clf = tree.DecisionTreeClassifier() + clf = tree.DecisionTreeRegressor() clf.fit(X, y) assert_array_equal(clf.predict(T), true_result) @@ -63,53 +63,53 @@ def test_regression_toy(): assert_almost_equal(clf.predict(T), true_result) -def test_graphviz_toy(): - """Check correctness of graphviz output on a toy dataset.""" - clf = tree.DecisionTreeClassifier(max_depth=3, min_samples_split=1) - clf.fit(X, y) - from StringIO import StringIO - - # test export code - out = StringIO() - tree.export_graphviz(clf, out_file=out) - contents1 = out.getvalue() - - tree_toy = StringIO("digraph Tree {\n" - "0 [label=\"X[0] <= 0.0000\\nerror = 0.5" - "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" - "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" - "0 -> 1 ;\n" - "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" - "0 -> 2 ;\n" - "}") - contents2 = tree_toy.getvalue() - - assert contents1 == contents2, \ - "graphviz output test failed\n: %s != %s" % (contents1, contents2) - - # test with feature_names - out = StringIO() - out = tree.export_graphviz(clf, out_file=out, - feature_names=["feature1", ""]) - contents1 = out.getvalue() - - tree_toy = StringIO("digraph Tree {\n" - "0 [label=\"feature1 <= 0.0000\\nerror = 0.5" - "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" - "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" - "0 -> 1 ;\n" - "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" - "0 -> 2 ;\n" - "}") - contents2 = tree_toy.getvalue() - - assert contents1 == contents2, \ - "graphviz output test failed\n: %s != %s" % (contents1, contents2) - - # test improperly formed feature_names - out = StringIO() - assert_raises(IndexError, tree.export_graphviz, - clf, out, feature_names=[]) +# def test_graphviz_toy(): +# """Check correctness of graphviz output on a toy dataset.""" +# clf = tree.DecisionTreeClassifier(max_depth=3, min_samples_split=1) +# clf.fit(X, y) +# from StringIO import StringIO + +# # test export code +# out = StringIO() +# tree.export_graphviz(clf, out_file=out) +# contents1 = out.getvalue() + +# tree_toy = StringIO("digraph Tree {\n" +# "0 [label=\"X[0] <= 0.0000\\nerror = 0.5" +# "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" +# "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" +# "0 -> 1 ;\n" +# "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" +# "0 -> 2 ;\n" +# "}") +# contents2 = tree_toy.getvalue() + +# assert contents1 == contents2, \ +# "graphviz output test failed\n: %s != %s" % (contents1, contents2) + +# # test with feature_names +# out = StringIO() +# out = tree.export_graphviz(clf, out_file=out, +# feature_names=["feature1", ""]) +# contents1 = out.getvalue() + +# tree_toy = StringIO("digraph Tree {\n" +# "0 [label=\"feature1 <= 0.0000\\nerror = 0.5" +# "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" +# "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" +# "0 -> 1 ;\n" +# "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" +# "0 -> 2 ;\n" +# "}") +# contents2 = tree_toy.getvalue() + +# assert contents1 == contents2, \ +# "graphviz output test failed\n: %s != %s" % (contents1, contents2) + +# # test improperly formed feature_names +# out = StringIO() +# assert_raises(IndexError, tree.export_graphviz, +# clf, out, feature_names=[]) def test_iris(): @@ -349,5 +349,7 @@ def test_pickle(): if __name__ == "__main__": - import nose - nose.runmodule() + # import nose + # nose.runmodule() + import cProfile + cProfile.run("test_arrayrepr()") diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 702cf419eff20..ea83f455b42cb 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -19,6 +19,8 @@ from . import _tree +import sys + __all__ = ["DecisionTreeClassifier", "DecisionTreeRegressor", "ExtraTreeClassifier", @@ -146,7 +148,7 @@ class Tree(object): threshold : np.ndarray of float64 The threshold of each node (only for leaves). - value : np.ndarray of float64, shape=(capacity, n_classes) + value : np.ndarray of float64, shape=(capacity, n_outputs, n_classes) Contains the constant prediction value of each node. best_error : np.ndarray of float64 @@ -164,9 +166,10 @@ class Tree(object): LEAF = -1 UNDEFINED = -2 - def __init__(self, n_classes, n_features, capacity=3): + def __init__(self, n_classes, n_features, n_outputs, capacity=3): self.n_classes = n_classes self.n_features = n_features + self.n_outputs = n_outputs self.node_count = 0 @@ -177,7 +180,7 @@ def __init__(self, n_classes, n_features, capacity=3): self.feature.fill(Tree.UNDEFINED) self.threshold = np.empty((capacity,), dtype=np.float64) - self.value = np.empty((capacity, n_classes), dtype=np.float64) + self.value = np.empty((capacity, n_outputs, np.max(n_classes)), dtype=np.float64) self.best_error = np.empty((capacity,), dtype=np.float32) self.init_error = np.empty((capacity,), dtype=np.float32) @@ -194,7 +197,7 @@ def _resize(self, capacity=None): self.children.resize((capacity, 2), refcheck=False) self.feature.resize((capacity,), refcheck=False) self.threshold.resize((capacity,), refcheck=False) - self.value.resize((capacity, self.value.shape[1]), refcheck=False) + self.value.resize((capacity, self.value.shape[1], self.value.shape[2]), refcheck=False) self.best_error.resize((capacity,), refcheck=False) self.init_error.resize((capacity,), refcheck=False) self.n_samples.resize((capacity,), refcheck=False) @@ -217,6 +220,7 @@ def _add_split_node(self, parent, is_left_child, feature, threshold, self.init_error[node_id] = init_error self.best_error[node_id] = best_error self.n_samples[node_id] = n_samples + self.value[node_id] = value # set as left or right child of parent @@ -314,10 +318,10 @@ def recursive_partition(X, X_argsorted, y, sample_mask, depth, # Setup auxiliary data structures and check input before # recursive partitioning if X.dtype != DTYPE or not np.isfortran(X): - X = np.asanyarray(X, dtype=DTYPE, order="F") + X = np.asarray(X, dtype=DTYPE, order="F") if y.dtype != DTYPE or not y.flags.contiguous: - y = np.ascontiguousarray(y, dtype=DTYPE) + y = np.asarray(y, dtype=DTYPE, order="C") if sample_mask is None: sample_mask = np.ones((X.shape[0],), dtype=np.bool) @@ -345,7 +349,7 @@ def recursive_partition(X, X_argsorted, y, sample_mask, depth, return self def predict(self, X): - out = np.empty((X.shape[0], self.value.shape[1]), dtype=np.float64) + out = np.empty((X.shape[0], self.value.shape[1], self.value.shape[2]), dtype=np.float64) _tree._predict_tree(X, self.children, @@ -426,6 +430,7 @@ def __init__(self, criterion, self.random_state = check_random_state(random_state) self.n_features_ = None + self.n_outputs_ = None self.classes_ = None self.n_classes_ = None self.find_split_ = _tree._find_best_split @@ -451,27 +456,39 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): Returns self. """ # set min_samples_split sensibly - self.min_samples_split = max(self.min_samples_split, 2 * - self.min_samples_leaf) + self.min_samples_split = max(self.min_samples_split, 2 * self.min_samples_leaf) # Convert data - X = np.asarray(X, dtype=DTYPE, order='F') + X = np.asarray(X, dtype=DTYPE, order="F") n_samples, self.n_features_ = X.shape is_classification = isinstance(self, ClassifierMixin) + y = np.atleast_1d(y) + if y.ndim == 1: + y = y[:, np.newaxis] + + self.classes_ = [] + self.n_classes_ = [] + self.n_outputs_ = y.shape[1] + if is_classification: - self.classes_ = np.unique(y) - self.n_classes_ = self.classes_.shape[0] - criterion = CLASSIFICATION[self.criterion](self.n_classes_) - y = np.searchsorted(self.classes_, y) + for k in xrange(self.n_outputs_): + unique = np.unique(y[:, k]) + self.classes_.append(unique) + self.n_classes_.append(unique.shape[0]) + y[:, k] = np.searchsorted(unique, y[:, k]) else: - self.classes_ = None - self.n_classes_ = 1 - criterion = REGRESSION[self.criterion]() + self.classes_ = [None] * self.n_outputs_ + self.n_classes_ = [1] * self.n_outputs_ - y = np.asarray(y, dtype=DTYPE) + y = np.asarray(y, dtype=DTYPE, order="C") + + if is_classification: + criterion = CLASSIFICATION[self.criterion](self.n_outputs_, self.n_classes_) + else: + criterion = REGRESSION[self.criterion](self.n_outputs_) # Check parameters max_depth = np.inf if self.max_depth is None else self.max_depth @@ -516,7 +533,7 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): raise ValueError("max_features must be in (0, n_features]") # Build tree - self.tree_ = Tree(self.n_classes_, self.n_features_) + self.tree_ = Tree(self.n_classes_, self.n_features_, self.n_outputs_) self.tree_.build(X, y, criterion, max_depth, self.min_samples_split, self.min_samples_leaf, self.min_density, max_features, self.random_state, @@ -558,11 +575,18 @@ def predict(self, X): " input n_features is %s " % (self.n_features_, n_features)) + P = self.tree_.predict(X) + if isinstance(self, ClassifierMixin): - predictions = self.classes_.take(np.argmax( - self.tree_.predict(X), axis=1), axis=0) + predictions = np.zeros((X.shape[0], self.n_outputs_)) + + for k in xrange(self.n_outputs_): + predictions[:, k] = self.classes_[k].take(np.argmax(P[:, k], axis=1), axis=0) else: - predictions = self.tree_.predict(X).ravel() + predictions = P[:, :, 0] + + if self.n_outputs_ == 1: + predictions = predictions.reshape((predictions.shape[0], )) return predictions @@ -703,11 +727,21 @@ def predict_proba(self, X): " input n_features is %s " % (self.n_features_, n_features)) + proba = [] P = self.tree_.predict(X) - normalizer = P.sum(axis=1)[:, np.newaxis] - normalizer[normalizer == 0.0] = 1.0 - P /= normalizer - return P + + for k in xrange(self.n_outputs_): + P_k = P[:, k, :self.n_classes_[k]] + normalizer = P_k.sum(axis=1)[:, np.newaxis] + normalizer[normalizer == 0.0] = 1.0 + P_k /= normalizer + proba.append(P_k) + + if self.n_outputs_ == 1: + return proba[0] + + else: + return proba def predict_log_proba(self, X): """Predict class log-probabilities of the input samples X. From 064a48cfdc2aadd5d90552d579414971febd4671 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Fri, 29 Jun 2012 12:49:58 +0200 Subject: [PATCH 03/33] ENH: Regenerate .c file --- sklearn/tree/_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index 40c2656c1ebcd..b3174a9e8ed6e 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Fri Jun 29 11:44:42 2012 */ +/* Generated by Cython 0.16 on Fri Jun 29 12:49:27 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" From 74bf03c0f07ec96e190fccc71b9f272ffa7be39b Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Fri, 29 Jun 2012 13:46:53 +0200 Subject: [PATCH 04/33] FIX: graphviz test --- sklearn/tree/tests/test_tree.py | 94 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index e966606e4154d..7c3051c2e58fb 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -63,53 +63,53 @@ def test_regression_toy(): assert_almost_equal(clf.predict(T), true_result) -# def test_graphviz_toy(): -# """Check correctness of graphviz output on a toy dataset.""" -# clf = tree.DecisionTreeClassifier(max_depth=3, min_samples_split=1) -# clf.fit(X, y) -# from StringIO import StringIO - -# # test export code -# out = StringIO() -# tree.export_graphviz(clf, out_file=out) -# contents1 = out.getvalue() - -# tree_toy = StringIO("digraph Tree {\n" -# "0 [label=\"X[0] <= 0.0000\\nerror = 0.5" -# "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" -# "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" -# "0 -> 1 ;\n" -# "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" -# "0 -> 2 ;\n" -# "}") -# contents2 = tree_toy.getvalue() - -# assert contents1 == contents2, \ -# "graphviz output test failed\n: %s != %s" % (contents1, contents2) - -# # test with feature_names -# out = StringIO() -# out = tree.export_graphviz(clf, out_file=out, -# feature_names=["feature1", ""]) -# contents1 = out.getvalue() - -# tree_toy = StringIO("digraph Tree {\n" -# "0 [label=\"feature1 <= 0.0000\\nerror = 0.5" -# "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" -# "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" -# "0 -> 1 ;\n" -# "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" -# "0 -> 2 ;\n" -# "}") -# contents2 = tree_toy.getvalue() - -# assert contents1 == contents2, \ -# "graphviz output test failed\n: %s != %s" % (contents1, contents2) - -# # test improperly formed feature_names -# out = StringIO() -# assert_raises(IndexError, tree.export_graphviz, -# clf, out, feature_names=[]) +def test_graphviz_toy(): + """Check correctness of graphviz output on a toy dataset.""" + clf = tree.DecisionTreeClassifier(max_depth=3, min_samples_split=1) + clf.fit(X, y) + from StringIO import StringIO + + # test export code + out = StringIO() + tree.export_graphviz(clf, out_file=out) + contents1 = out.getvalue() + + tree_toy = StringIO("digraph Tree {\n" + "0 [label=\"X[0] <= 0.0000\\nerror = 0.5" + "\\nsamples = 6\\nvalue = [[ 3. 3.]]\", shape=\"box\"] ;\n" + "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 3. 0.]]\", shape=\"box\"] ;\n" + "0 -> 1 ;\n" + "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 0. 3.]]\", shape=\"box\"] ;\n" + "0 -> 2 ;\n" + "}") + contents2 = tree_toy.getvalue() + + assert contents1 == contents2, \ + "graphviz output test failed\n: %s != %s" % (contents1, contents2) + + # test with feature_names + out = StringIO() + out = tree.export_graphviz(clf, out_file=out, + feature_names=["feature1", ""]) + contents1 = out.getvalue() + + tree_toy = StringIO("digraph Tree {\n" + "0 [label=\"feature1 <= 0.0000\\nerror = 0.5" + "\\nsamples = 6\\nvalue = [[ 3. 3.]]\", shape=\"box\"] ;\n" + "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 3. 0.]]\", shape=\"box\"] ;\n" + "0 -> 1 ;\n" + "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 0. 3.]]\", shape=\"box\"] ;\n" + "0 -> 2 ;\n" + "}") + contents2 = tree_toy.getvalue() + + assert contents1 == contents2, \ + "graphviz output test failed\n: %s != %s" % (contents1, contents2) + + # test improperly formed feature_names + out = StringIO() + assert_raises(IndexError, tree.export_graphviz, + clf, out, feature_names=[]) def test_iris(): From be8ea69e135336debaab01b00dc08e72d0eabcb7 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Fri, 29 Jun 2012 14:16:33 +0200 Subject: [PATCH 05/33] FIX: test_classification_toy --- sklearn/tree/tests/test_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 7c3051c2e58fb..a98c6b27bb037 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -37,7 +37,7 @@ def test_classification_toy(): """Check classification on a toy dataset.""" - clf = tree.DecisionTreeRegressor() + clf = tree.DecisionTreeClassifier() clf.fit(X, y) assert_array_equal(clf.predict(T), true_result) From afacf44383a66967ca2e46080a768e4a747b2d03 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Fri, 29 Jun 2012 15:16:50 +0200 Subject: [PATCH 06/33] TEST: test_multioutput (1) --- sklearn/tree/tests/test_tree.py | 19 +++++++++++++++++++ sklearn/tree/tree.py | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index a98c6b27bb037..135eae1457d6a 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -348,6 +348,25 @@ def test_pickle(): " after pickling (regression) " +def test_multioutput(): + X = [[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]] + y = [[-1, 1], [-1, 1], [-1, 1], [1, -1], [1, -1], [1, -1]] + T = [[-1, -1], [2, 2], [3, 2]] + true_result = [[-1, 1], [1, -1], [1, -1]] + + # toy classification problem + clf = tree.DecisionTreeClassifier() + clf.fit(X, y) + + assert_array_equal(clf.predict(T), true_result) + + # toy regression problem + clf = tree.DecisionTreeRegressor() + clf.fit(X, y) + + assert_almost_equal(clf.predict(T), true_result) + + if __name__ == "__main__": # import nose # nose.runmodule() diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 22da11334ddd3..3980ad39806e3 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -582,7 +582,7 @@ def predict(self, X): P = self.tree_.predict(X) if isinstance(self, ClassifierMixin): - predictions = np.zeros((X.shape[0], self.n_outputs_)) + predictions = np.zeros((n_samples, self.n_outputs_)) for k in xrange(self.n_outputs_): predictions[:, k] = self.classes_[k].take(np.argmax(P[:, k], axis=1), axis=0) @@ -590,7 +590,7 @@ def predict(self, X): predictions = P[:, :, 0] if self.n_outputs_ == 1: - predictions = predictions.reshape((predictions.shape[0], )) + predictions = predictions.reshape((n_samples, )) return predictions From 6cf4d26134ec4b9bd81b551dcbd5fa47a09d4f96 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 09:56:24 +0200 Subject: [PATCH 07/33] TEST: test_multioutput --- sklearn/tree/tests/test_tree.py | 52 +++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 135eae1457d6a..2441d6ebfc5b3 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -349,26 +349,54 @@ def test_pickle(): def test_multioutput(): - X = [[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]] - y = [[-1, 1], [-1, 1], [-1, 1], [1, -1], [1, -1], [1, -1]] - T = [[-1, -1], [2, 2], [3, 2]] - true_result = [[-1, 1], [1, -1], [1, -1]] + X = [[-2, -1], + [-1, -1], + [-1, -2], + [1, 1], + [1, 2], + [2, 1], + [-2, 1], + [-1, 1], + [-1, 2], + [2, -1], + [1, -1], + [1, -2]] + + y = [[-1, 0], + [-1, 0], + [-1, 0], + [1, 1], + [1, 1], + [1, 1], + [-1, 2], + [-1, 2], + [-1, 2], + [1, 3], + [1, 3], + [1, 3]] + + T = [[-1, -1], [1, 1], [-1, 1], [1, -1]] + y_true = [[-1, 0], [1, 1], [-1, 2], [1, 3]] # toy classification problem clf = tree.DecisionTreeClassifier() - clf.fit(X, y) + y_hat = clf.fit(X, y).predict(T) + assert_array_equal(y_hat, y_true) + assert_equal(y_hat.shape, (4, 2)) - assert_array_equal(clf.predict(T), true_result) + proba = clf.predict_proba(T) + assert_equal(len(proba), 2) + assert_equal(proba[0].shape, (4, 2)) + assert_equal(proba[1].shape, (4, 4)) # toy regression problem clf = tree.DecisionTreeRegressor() - clf.fit(X, y) + y_hat = clf.fit(X, y).predict(T) + assert_almost_equal(y_hat, y_true) + assert_equal(y_hat.shape, (4, 2)) - assert_almost_equal(clf.predict(T), true_result) if __name__ == "__main__": - # import nose - # nose.runmodule() - import cProfile - cProfile.run("test_arrayrepr()") + import nose + nose.runmodule() From b22b1f6908aa313cf8097c72ab0d839a2c990b11 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:05:09 +0200 Subject: [PATCH 08/33] ENH: make forests support multi-output --- sklearn/ensemble/forest.py | 141 +++++++++++++++++++++++++++++-------- 1 file changed, 110 insertions(+), 31 deletions(-) diff --git a/sklearn/ensemble/forest.py b/sklearn/ensemble/forest.py index b3dfc8854b0ac..62f7d9a101bc2 100644 --- a/sklearn/ensemble/forest.py +++ b/sklearn/ensemble/forest.py @@ -86,19 +86,27 @@ def _parallel_build_trees(n_trees, forest, X, y, return trees -def _parallel_predict_proba(trees, X, n_classes): +def _parallel_predict_proba(trees, X, n_classes, n_outputs): """Private function used to compute a batch of predictions within a job.""" - p = np.zeros((X.shape[0], n_classes)) + n_samples = X.shape[0] + p = [] + + for k in xrange(n_outputs): + p.append(np.zeros((n_samples, n_classes[k]))) for tree in trees: - if n_classes == tree.n_classes_: - p += tree.predict_proba(X) + p_tree = tree.predict_proba(X) - else: - proba = tree.predict_proba(X) + if n_outputs == 1: + p_tree = [p_tree] - for j, c in enumerate(tree.classes_): - p[:, c] += proba[:, j] + for k in xrange(n_outputs): + if n_classes[k] == tree.n_classes_[k]: + p[k] += p_tree[k] + + else: + for j, c in enumerate(tree.classes_[k]): + p[k][:, c] += p_tree[k][:, j] return p @@ -188,7 +196,12 @@ def __init__(self, base_estimator, self.n_jobs = n_jobs self.random_state = check_random_state(random_state) + self.n_features_ = None + self.n_outputs_ = None + self.classes_ = None + self.n_classes_ = None self.feature_importances_ = None + self.verbose = verbose def fit(self, X, y): @@ -210,7 +223,7 @@ def fit(self, X, y): """ # Precompute some data X = np.atleast_2d(X) - y = np.atleast_1d(y) + n_samples, self.n_features_ = X.shape if self.bootstrap: sample_mask = None @@ -221,9 +234,9 @@ def fit(self, X, y): raise ValueError("Out of bag estimation only available" " if bootstrap=True") - sample_mask = np.ones((X.shape[0],), dtype=np.bool) + sample_mask = np.ones((n_samples,), dtype=np.bool) - n_jobs, _, starts = _partition_features(self, X.shape[1]) + n_jobs, _, starts = _partition_features(self, self.n_features_) all_X_argsorted = Parallel(n_jobs=n_jobs)( delayed(_parallel_X_argsort)( @@ -232,10 +245,20 @@ def fit(self, X, y): X_argsorted = np.asfortranarray(np.hstack(all_X_argsorted)) + y = np.atleast_1d(y) + if y.ndim == 1: + y = y[:, np.newaxis] + + self.classes_ = [] + self.n_classes_ = [] + self.n_outputs_ = y.shape[1] + if isinstance(self.base_estimator, ClassifierMixin): - self.classes_ = np.unique(y) - self.n_classes_ = len(self.classes_) - y = np.searchsorted(self.classes_, y) + for k in xrange(self.n_outputs_): + unique = np.unique(y[:, k]) + self.classes_.append(unique) + self.n_classes_.append(unique.shape[0]) + y[:, k] = np.searchsorted(unique, y[:, k]) # Assign chunk of trees to jobs n_jobs, n_trees, _ = _partition_trees(self) @@ -259,29 +282,59 @@ def fit(self, X, y): # Calculate out of bag predictions and score if self.oob_score: if isinstance(self, ClassifierMixin): - predictions = np.zeros((X.shape[0], self.n_classes_)) + self.oob_decision_function_ = [] + self.oob_score_ = 0.0 + + predictions = [] + for k in xrange(self.n_outputs_): + predictions.append(np.zeros((n_samples, self.n_classes_[k]))) + for estimator in self.estimators_: - mask = np.ones(X.shape[0], dtype=np.bool) + mask = np.ones(n_samples, dtype=np.bool) mask[estimator.indices_] = False - predictions[mask, :] += estimator.predict_proba(X[mask, :]) - self.oob_decision_function_ = (predictions - / predictions.sum(axis=1)[:, np.newaxis]) - self.oob_score_ = np.mean(y == np.argmax(predictions, axis=1)) + p_estimator = estimator.predict_proba(X[mask, :]) + if self.n_outputs_ == 1: + p_estimator = [p_estimator] + + for k in xrange(self.n_outputs_): + predictions[k][mask, :] += p_estimator[k] + + for k in xrange(self.n_outputs_): + self.oob_decision_function_.append((predictions[k] / predictions[k].sum(axis=1)[:, np.newaxis])) + self.oob_score_ += np.mean(y[:, k] == np.argmax(predictions[k], axis=1)) + + if self.n_outputs_ == 1: + self.oob_decision_function_ = self.oob_decision_function_[0] + + self.oob_score_ /= self.n_outputs_ else: # Regression: - predictions = np.zeros(X.shape[0]) - n_predictions = np.zeros(X.shape[0]) + predictions = np.zeros((n_samples, self.n_outputs_)) + n_predictions = np.zeros((n_samples, self.n_outputs_)) + for estimator in self.estimators_: - mask = np.ones(X.shape[0], dtype=np.bool) + mask = np.ones(n_samples, dtype=np.bool) mask[estimator.indices_] = False - predictions[mask] += estimator.predict(X[mask, :]) - n_predictions[mask] += 1 + + p_estimator = estimator.predict(X[mask, :]) + if self.n_outputs_ == 1: + p_estimator = p_estimator[:, np.newaxis] + + predictions[mask, :] += p_estimator + n_predictions[mask, :] += 1 + predictions /= n_predictions self.oob_prediction_ = predictions - self.oob_score_ = r2_score(y, predictions) + if self.n_outputs_ == 1: + self.oob_prediction_ = self.oob_prediction_.reshape((n_samples, )) + + self.oob_score_ = 0.0 + for k in xrange(self.n_outputs_): + self.oob_score_ += r2_score(y[:, k], predictions[:, k]) + self.oob_score_ /= self.n_outputs_ # Sum the importances if self.compute_importances: @@ -337,8 +390,21 @@ def predict(self, X): y : array of shape = [n_samples] The predicted classes. """ - return self.classes_.take( - np.argmax(self.predict_proba(X), axis=1), axis=0) + n_samples = len(X) + + P = self.predict_proba(X) + if self.n_outputs_ == 1: + P = [P] + + predictions = np.zeros((n_samples, self.n_outputs_)) + + for k in xrange(self.n_outputs_): + predictions[:, k] = self.classes_[k].take(np.argmax(P[k], axis=1), axis=0) + + if self.n_outputs_ == 1: + predictions = predictions.reshape((n_samples, )) + + return predictions def predict_proba(self, X): """Predict class probabilities for X. @@ -367,13 +433,26 @@ def predict_proba(self, X): all_p = Parallel(n_jobs=n_jobs)( delayed(_parallel_predict_proba)( self.estimators_[starts[i]:starts[i + 1]], - X, self.n_classes_) + X, + self.n_classes_, + self.n_outputs_) for i in xrange(n_jobs)) # Reduce - p = sum(all_p) / self.n_estimators + p = all_p[0] + + for j in xrange(1, self.n_jobs): + for k in xrange(self.n_outputs_): + p[k] += all_p[j][k] - return p + for k in xrange(self.n_outputs_): + p[k] /= self.n_estimators + + if self.n_outputs_ == 1: + return p[0] + + else: + return p def predict_log_proba(self, X): """Predict class log-probabilities for X. From 7b6ef37d01a7146b08a5df7ffeb80a5e9e02f30c Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:16:18 +0200 Subject: [PATCH 09/33] TEST: test_multioutput --- sklearn/ensemble/tests/test_forest.py | 58 +++++++++++++++++++++++++-- sklearn/tree/tests/test_tree.py | 2 + 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/sklearn/ensemble/tests/test_forest.py b/sklearn/ensemble/tests/test_forest.py index 0259c289273cf..b65d328c5e4d7 100644 --- a/sklearn/ensemble/tests/test_forest.py +++ b/sklearn/ensemble/tests/test_forest.py @@ -260,7 +260,7 @@ def test_pickle(): import pickle # Random forest - obj = RandomForestClassifier() + obj = RandomForestClassifier(random_state=0) obj.fit(iris.data, iris.target) score = obj.score(iris.data, iris.target) s = pickle.dumps(obj) @@ -270,7 +270,7 @@ def test_pickle(): score2 = obj2.score(iris.data, iris.target) assert_true(score == score2) - obj = RandomForestRegressor() + obj = RandomForestRegressor(random_state=0) obj.fit(boston.data, boston.target) score = obj.score(boston.data, boston.target) s = pickle.dumps(obj) @@ -281,7 +281,7 @@ def test_pickle(): assert_true(score == score2) # Extra-trees - obj = ExtraTreesClassifier() + obj = ExtraTreesClassifier(random_state=0) obj.fit(iris.data, iris.target) score = obj.score(iris.data, iris.target) s = pickle.dumps(obj) @@ -291,7 +291,7 @@ def test_pickle(): score2 = obj2.score(iris.data, iris.target) assert_true(score == score2) - obj = ExtraTreesRegressor() + obj = ExtraTreesRegressor(random_state=0) obj.fit(boston.data, boston.target) score = obj.score(boston.data, boston.target) s = pickle.dumps(obj) @@ -302,6 +302,56 @@ def test_pickle(): assert_true(score == score2) +def test_multioutput(): + """Check estimators on multi-output problems.""" + + X = [[-2, -1], + [-1, -1], + [-1, -2], + [1, 1], + [1, 2], + [2, 1], + [-2, 1], + [-1, 1], + [-1, 2], + [2, -1], + [1, -1], + [1, -2]] + + y = [[-1, 0], + [-1, 0], + [-1, 0], + [1, 1], + [1, 1], + [1, 1], + [-1, 2], + [-1, 2], + [-1, 2], + [1, 3], + [1, 3], + [1, 3]] + + T = [[-1, -1], [1, 1], [-1, 1], [1, -1]] + y_true = [[-1, 0], [1, 1], [-1, 2], [1, 3]] + + # toy classification problem + clf = ExtraTreesClassifier(random_state=0) + y_hat = clf.fit(X, y).predict(T) + assert_array_equal(y_hat, y_true) + assert_equal(y_hat.shape, (4, 2)) + + proba = clf.predict_proba(T) + assert_equal(len(proba), 2) + assert_equal(proba[0].shape, (4, 2)) + assert_equal(proba[1].shape, (4, 4)) + + # toy regression problem + clf = ExtraTreesRegressor(random_state=5) + y_hat = clf.fit(X, y).predict(T) + assert_almost_equal(y_hat, y_true) + assert_equal(y_hat.shape, (4, 2)) + + if __name__ == "__main__": import nose nose.runmodule() diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 2441d6ebfc5b3..8836358bc3745 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -349,6 +349,8 @@ def test_pickle(): def test_multioutput(): + """Check estimators on multi-output problems.""" + X = [[-2, -1], [-1, -1], [-1, -2], From 5ee718c3081415fe50e41dc6bc753463b93cd57b Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:31:09 +0200 Subject: [PATCH 10/33] ENH: Patch GradientBoosting --- sklearn/ensemble/gradient_boosting.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sklearn/ensemble/gradient_boosting.py b/sklearn/ensemble/gradient_boosting.py index b050201c5bc98..354cc86ff869b 100644 --- a/sklearn/ensemble/gradient_boosting.py +++ b/sklearn/ensemble/gradient_boosting.py @@ -162,7 +162,7 @@ def update_terminal_regions(self, tree, X, y, residual, y_pred, y_pred[:, k]) # update predictions (both in-bag and out-of-bag) - y_pred[:, k] += learn_rate * tree.value[:, 0].take(terminal_regions, + y_pred[:, k] += learn_rate * tree.value[:, 0, 0].take(terminal_regions, axis=0) @abstractmethod @@ -222,8 +222,8 @@ def _update_terminal_region(self, tree, terminal_regions, leaf, X, y, residual, pred): """LAD updates terminal regions to median estimates. """ terminal_region = np.where(terminal_regions == leaf)[0] - tree.value[leaf, 0] = np.median(y.take(terminal_region, axis=0) - \ - pred.take(terminal_region, axis=0)) + tree.value[leaf, 0, 0] = np.median(y.take(terminal_region, axis=0) - \ + pred.take(terminal_region, axis=0)) class BinomialDeviance(LossFunction): @@ -262,9 +262,9 @@ def _update_terminal_region(self, tree, terminal_regions, leaf, X, y, denominator = np.sum((y - residual) * (1 - y + residual)) if denominator == 0.0: - tree.value[leaf, 0] = 0.0 + tree.value[leaf, 0, 0] = 0.0 else: - tree.value[leaf, 0] = numerator / denominator + tree.value[leaf, 0, 0] = numerator / denominator class MultinomialDeviance(LossFunction): @@ -312,9 +312,9 @@ def _update_terminal_region(self, tree, terminal_regions, leaf, X, y, denominator = np.sum((y - residual) * (1.0 - y + residual)) if denominator == 0.0: - tree.value[leaf, 0] = 0.0 + tree.value[leaf, 0, 0] = 0.0 else: - tree.value[leaf, 0] = numerator / denominator + tree.value[leaf, 0, 0] = numerator / denominator LOSS_FUNCTIONS = {'ls': LeastSquaresError, @@ -377,16 +377,17 @@ def fit_stage(self, i, X, X_argsorted, y, y_pred, sample_mask): if loss.is_multi_class: y = np.array(original_y == k, dtype=np.float64) - residual = loss.negative_gradient(y, y_pred, k=k) + residual = loss.negative_gradient(y, y_pred, k=k)[:, np.newaxis] # induce regression tree on residuals - tree = Tree(1, self.n_features) - tree.build(X, residual, MSE(), self.max_depth, + tree = Tree(1, self.n_features, 1) + tree.build(X, residual, MSE(1), self.max_depth, self.min_samples_split, self.min_samples_leaf, 0.0, self.n_features, self.random_state, _find_best_split, sample_mask, X_argsorted) # update tree leaves + residual = residual[:, 0] self.loss_.update_terminal_regions(tree, X, y, residual, y_pred, sample_mask, self.learn_rate, k=k) From 41cd38f8bc32fd484319ee02581b891a613e0c34 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:37:28 +0200 Subject: [PATCH 11/33] ENH: Patch GradientBoosting (2) --- sklearn/ensemble/gradient_boosting.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sklearn/ensemble/gradient_boosting.py b/sklearn/ensemble/gradient_boosting.py index 354cc86ff869b..3889deb3da1f9 100644 --- a/sklearn/ensemble/gradient_boosting.py +++ b/sklearn/ensemble/gradient_boosting.py @@ -377,17 +377,16 @@ def fit_stage(self, i, X, X_argsorted, y, y_pred, sample_mask): if loss.is_multi_class: y = np.array(original_y == k, dtype=np.float64) - residual = loss.negative_gradient(y, y_pred, k=k)[:, np.newaxis] + residual = loss.negative_gradient(y, y_pred, k=k) # induce regression tree on residuals tree = Tree(1, self.n_features, 1) - tree.build(X, residual, MSE(1), self.max_depth, + tree.build(X, residual[:, np.newaxis], MSE(1), self.max_depth, self.min_samples_split, self.min_samples_leaf, 0.0, self.n_features, self.random_state, _find_best_split, sample_mask, X_argsorted) # update tree leaves - residual = residual[:, 0] self.loss_.update_terminal_regions(tree, X, y, residual, y_pred, sample_mask, self.learn_rate, k=k) From b4131f9ed1d13a17fb2e6fe15abb78ba5eaae323 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:51:50 +0200 Subject: [PATCH 12/33] FIX: log_proba + DOC --- sklearn/ensemble/forest.py | 25 +++++++++++++++++++------ sklearn/ensemble/tests/test_forest.py | 5 +++++ sklearn/tree/tests/test_tree.py | 5 +++++ sklearn/tree/tree.py | 24 ++++++++++++++++++------ 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/sklearn/ensemble/forest.py b/sklearn/ensemble/forest.py index 62f7d9a101bc2..24c812f87e06e 100644 --- a/sklearn/ensemble/forest.py +++ b/sklearn/ensemble/forest.py @@ -28,6 +28,8 @@ class calls the ``fit`` method of each sub-estimator on random samples ``ExtraTreeClassifier`` and ``ExtraTreeRegressor`` as sub-estimator implementations. +Single and multi-output problems are both handled. + """ # Authors: Gilles Louppe, Brian Holt @@ -212,7 +214,7 @@ def fit(self, X, y): X : array-like of shape = [n_samples, n_features] The training input samples. - y : array-like, shape = [n_samples] + y : array-like, shape = [n_samples] or [n_samples, n_outputs] The target values (integers that correspond to classes in classification, real numbers in regression). @@ -387,7 +389,7 @@ def predict(self, X): Returns ------- - y : array of shape = [n_samples] + y : array of shape = [n_samples] or [n_samples, n_outputs] The predicted classes. """ n_samples = len(X) @@ -419,7 +421,8 @@ def predict_proba(self, X): Returns ------- - p : array of shape = [n_samples] + p : array of shape = [n_samples, n_classes], or a list of n_outputs such + arrays if n_outputs > 1. The class probabilities of the input samples. Classes are ordered by arithmetical order. """ @@ -467,11 +470,21 @@ def predict_log_proba(self, X): Returns ------- - p : array of shape = [n_samples] + p : array of shape = [n_samples, n_classes], or a list of n_outputs such + arrays if n_outputs > 1. The class log-probabilities of the input samples. Classes are ordered by arithmetical order. """ - return np.log(self.predict_proba(X)) + proba = self.predict_proba(X) + + if self.n_outputs_ == 1: + return np.log(proba) + + else: + for k in xrange(self.n_outputs_): + proba[k] = np.log(proba[k]) + + return proba class ForestRegressor(BaseForest, RegressorMixin): @@ -516,7 +529,7 @@ def predict(self, X): Returns ------- - y: array of shape = [n_samples] + y: array of shape = [n_samples] or [n_samples, n_outputs] The predicted values. """ # Check data diff --git a/sklearn/ensemble/tests/test_forest.py b/sklearn/ensemble/tests/test_forest.py index b65d328c5e4d7..3aed8c73fb96f 100644 --- a/sklearn/ensemble/tests/test_forest.py +++ b/sklearn/ensemble/tests/test_forest.py @@ -345,6 +345,11 @@ def test_multioutput(): assert_equal(proba[0].shape, (4, 2)) assert_equal(proba[1].shape, (4, 4)) + log_proba = clf.predict_log_proba(T) + assert_equal(len(log_proba), 2) + assert_equal(log_proba[0].shape, (4, 2)) + assert_equal(log_proba[1].shape, (4, 4)) + # toy regression problem clf = ExtraTreesRegressor(random_state=5) y_hat = clf.fit(X, y).predict(T) diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 8836358bc3745..2050cd82bbd41 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -391,6 +391,11 @@ def test_multioutput(): assert_equal(proba[0].shape, (4, 2)) assert_equal(proba[1].shape, (4, 4)) + log_proba = clf.predict_log_proba(T) + assert_equal(len(log_proba), 2) + assert_equal(log_proba[0].shape, (4, 2)) + assert_equal(log_proba[1].shape, (4, 4)) + # toy regression problem clf = tree.DecisionTreeRegressor() y_hat = clf.fit(X, y).predict(T) diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 3980ad39806e3..c7dbf7e6d8433 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -1,6 +1,6 @@ """ This module gathers tree-based methods, including decision, regression and -randomized trees. +randomized trees. Single and multi-output problems are both handled. """ # Code is originally adapted from MILK: Machine Learning Toolkit @@ -450,7 +450,7 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): X : array-like of shape = [n_samples, n_features] The training input samples. - y : array-like, shape = [n_samples] + y : array-like, shape = [n_samples] or [n_samples, n_outputs] The target values (integers that correspond to classes in classification, real numbers in regression). @@ -564,7 +564,7 @@ def predict(self, X): Returns ------- - y : array of shape = [n_samples] + y : array of shape = [n_samples] or [n_samples, n_outputs] The predicted classes, or the predict values. """ X = array2d(X, dtype=DTYPE) @@ -715,7 +715,8 @@ def predict_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes] + p : array of shape = [n_samples, n_classes], or a list of n_outputs such + arrays if n_outputs > 1. The class probabilities of the input samples. Classes are ordered by arithmetical order. """ @@ -757,11 +758,22 @@ def predict_log_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes] + p : array of shape = [n_samples, n_classes], or a list of n_outputs such + arrays if n_outputs > 1. The class log-probabilities of the input samples. Classes are ordered by arithmetical order. """ - return np.log(self.predict_proba(X)) + proba = self.predict_proba(X) + + if self.n_outputs_ == 1: + return np.log(proba) + + else: + for k in xrange(self.n_outputs_): + proba[k] = np.log(proba[k]) + + return proba + class DecisionTreeRegressor(BaseDecisionTree, RegressorMixin): From d56037250fe0b9bb6c3ca1653b53ba8ad5fb140f Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 11:57:38 +0200 Subject: [PATCH 13/33] DOC: What's new --- doc/whats_new.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index c841c10f9b161..15dadc4e17270 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -23,12 +23,15 @@ Changelog - A common testing framework for all estimators was added. + - Decision trees and forests of randomized now support multi-output + classification and regression problems, by `Gilles Louppe` + API changes summary ------------------- - - In :class:`hmm` objects, like :class:`hmm.GaussianHMM`, - :class:`hmm.MultinomialHMM`, etc., all parameters must be passed to the - object when initialising it and not through ``fit``. Now ``fit`` will + - In :class:`hmm` objects, like :class:`hmm.GaussianHMM`, + :class:`hmm.MultinomialHMM`, etc., all parameters must be passed to the + object when initialising it and not through ``fit``. Now ``fit`` will only accept the data as an input parameter. - For all SVM classes, a faulty behavior of ``gamma`` was fixed. Previously, From 9f7a0dd2f6dbd71762f43045d5474298bf12de43 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 12:11:27 +0200 Subject: [PATCH 14/33] PEP8 --- doc/whats_new.rst | 2 +- sklearn/ensemble/forest.py | 28 ++++++++++++++++++---------- sklearn/tree/tests/test_tree.py | 1 - sklearn/tree/tree.py | 28 +++++++++++++++++----------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index 15dadc4e17270..0ea30ff8f39a0 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -23,7 +23,7 @@ Changelog - A common testing framework for all estimators was added. - - Decision trees and forests of randomized now support multi-output + - Decision trees and forests of randomized trees now support multi-output classification and regression problems, by `Gilles Louppe` API changes summary diff --git a/sklearn/ensemble/forest.py b/sklearn/ensemble/forest.py index 24c812f87e06e..d73a3410216d6 100644 --- a/sklearn/ensemble/forest.py +++ b/sklearn/ensemble/forest.py @@ -289,7 +289,8 @@ def fit(self, X, y): predictions = [] for k in xrange(self.n_outputs_): - predictions.append(np.zeros((n_samples, self.n_classes_[k]))) + predictions.append(np.zeros((n_samples, + self.n_classes_[k]))) for estimator in self.estimators_: mask = np.ones(n_samples, dtype=np.bool) @@ -303,11 +304,16 @@ def fit(self, X, y): predictions[k][mask, :] += p_estimator[k] for k in xrange(self.n_outputs_): - self.oob_decision_function_.append((predictions[k] / predictions[k].sum(axis=1)[:, np.newaxis])) - self.oob_score_ += np.mean(y[:, k] == np.argmax(predictions[k], axis=1)) + decision = predictions[k] \ + / predictions[k].sum(axis=1)[:, np.newaxis] + self.oob_decision_function_.append(decision) + + self.oob_score_ += np.mean(y[:, k] \ + == np.argmax(predictions[k], axis=1)) if self.n_outputs_ == 1: - self.oob_decision_function_ = self.oob_decision_function_[0] + self.oob_decision_function_ = \ + self.oob_decision_function_[0] self.oob_score_ /= self.n_outputs_ @@ -331,7 +337,8 @@ def fit(self, X, y): self.oob_prediction_ = predictions if self.n_outputs_ == 1: - self.oob_prediction_ = self.oob_prediction_.reshape((n_samples, )) + self.oob_prediction_ = \ + self.oob_prediction_.reshape((n_samples, )) self.oob_score_ = 0.0 for k in xrange(self.n_outputs_): @@ -401,7 +408,8 @@ def predict(self, X): predictions = np.zeros((n_samples, self.n_outputs_)) for k in xrange(self.n_outputs_): - predictions[:, k] = self.classes_[k].take(np.argmax(P[k], axis=1), axis=0) + predictions[:, k] = self.classes_[k].take(np.argmax(P[k], axis=1), + axis=0) if self.n_outputs_ == 1: predictions = predictions.reshape((n_samples, )) @@ -421,8 +429,8 @@ def predict_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes], or a list of n_outputs such - arrays if n_outputs > 1. + p : array of shape = [n_samples, n_classes], or a list of n_outputs + such arrays if n_outputs > 1. The class probabilities of the input samples. Classes are ordered by arithmetical order. """ @@ -470,8 +478,8 @@ def predict_log_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes], or a list of n_outputs such - arrays if n_outputs > 1. + p : array of shape = [n_samples, n_classes], or a list of n_outputs + such arrays if n_outputs > 1. The class log-probabilities of the input samples. Classes are ordered by arithmetical order. """ diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index 2050cd82bbd41..f13b77840bc64 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -403,7 +403,6 @@ def test_multioutput(): assert_equal(y_hat.shape, (4, 2)) - if __name__ == "__main__": import nose nose.runmodule() diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index c7dbf7e6d8433..c7287be14997f 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -181,7 +181,8 @@ def __init__(self, n_classes, n_features, n_outputs, capacity=3): self.feature.fill(Tree.UNDEFINED) self.threshold = np.empty((capacity,), dtype=np.float64) - self.value = np.empty((capacity, n_outputs, np.max(n_classes)), dtype=np.float64) + self.value = np.empty((capacity, n_outputs, np.max(n_classes)), + dtype=np.float64) self.best_error = np.empty((capacity,), dtype=np.float32) self.init_error = np.empty((capacity,), dtype=np.float32) @@ -198,7 +199,8 @@ def _resize(self, capacity=None): self.children.resize((capacity, 2), refcheck=False) self.feature.resize((capacity,), refcheck=False) self.threshold.resize((capacity,), refcheck=False) - self.value.resize((capacity, self.value.shape[1], self.value.shape[2]), refcheck=False) + self.value.resize((capacity, self.value.shape[1], self.value.shape[2]), + refcheck=False) self.best_error.resize((capacity,), refcheck=False) self.init_error.resize((capacity,), refcheck=False) self.n_samples.resize((capacity,), refcheck=False) @@ -350,7 +352,8 @@ def recursive_partition(X, X_argsorted, y, sample_mask, depth, return self def predict(self, X): - out = np.empty((X.shape[0], self.value.shape[1], self.value.shape[2]), dtype=np.float64) + out = np.empty((X.shape[0], self.value.shape[1], self.value.shape[2]), + dtype=np.float64) _tree._predict_tree(X, self.children, @@ -460,7 +463,8 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): Returns self. """ # set min_samples_split sensibly - self.min_samples_split = max(self.min_samples_split, 2 * self.min_samples_leaf) + self.min_samples_split = max(self.min_samples_split, + 2 * self.min_samples_leaf) # Convert data X = np.asarray(X, dtype=DTYPE, order="F") @@ -490,7 +494,8 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): y = np.asarray(y, dtype=DTYPE, order="C") if is_classification: - criterion = CLASSIFICATION[self.criterion](self.n_outputs_, self.n_classes_) + criterion = CLASSIFICATION[self.criterion](self.n_outputs_, + self.n_classes_) else: criterion = REGRESSION[self.criterion](self.n_outputs_) @@ -585,7 +590,9 @@ def predict(self, X): predictions = np.zeros((n_samples, self.n_outputs_)) for k in xrange(self.n_outputs_): - predictions[:, k] = self.classes_[k].take(np.argmax(P[:, k], axis=1), axis=0) + predictions[:, k] = self.classes_[k].take(np.argmax(P[:, k], + axis=1), + axis=0) else: predictions = P[:, :, 0] @@ -715,8 +722,8 @@ def predict_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes], or a list of n_outputs such - arrays if n_outputs > 1. + p : array of shape = [n_samples, n_classes], or a list of n_outputs + such arrays if n_outputs > 1. The class probabilities of the input samples. Classes are ordered by arithmetical order. """ @@ -758,8 +765,8 @@ def predict_log_proba(self, X): Returns ------- - p : array of shape = [n_samples, n_classes], or a list of n_outputs such - arrays if n_outputs > 1. + p : array of shape = [n_samples, n_classes], or a list of n_outputs + such arrays if n_outputs > 1. The class log-probabilities of the input samples. Classes are ordered by arithmetical order. """ @@ -775,7 +782,6 @@ def predict_log_proba(self, X): return proba - class DecisionTreeRegressor(BaseDecisionTree, RegressorMixin): """A tree regressor. From 0cae649a652f5114f4af11cba8f52b225b78b0b4 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 13:20:27 +0200 Subject: [PATCH 15/33] ENH: graphviz --- doc/modules/tree.rst | 6 ++++++ sklearn/tree/tests/test_tree.py | 12 ++++++------ sklearn/tree/tree.py | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index 063b3a8e46fb0..a44fd1c3116fa 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -78,6 +78,7 @@ The disadvantages of decision trees include: It is therefore recommended to balance the dataset prior to fitting with the decision tree. + .. _tree_classification: Classification @@ -147,6 +148,7 @@ After being fitted, the model can then be used to predict new values:: * :ref:`example_tree_plot_iris.py` + .. _tree_regression: Regression @@ -177,6 +179,7 @@ instead of integer values:: * :ref:`example_tree_plot_tree_regression.py` + .. _tree_complexity: Complexity @@ -228,6 +231,7 @@ slowing down the algorithm significantly. Tips on practical use ===================== + * Decision trees tend to overfit on data with a large number of features. Getting the right ratio of samples to number of features is important, since a tree with few samples in high dimensional space is very likely to overfit. @@ -259,6 +263,7 @@ Tips on practical use * All decision trees use Fortran ordered ``np.float32`` arrays internally. If training data is not in this format, a copy of the dataset will be made. + .. _tree_algorithms: Tree algorithms: ID3, C4.5, C5.0 and CART @@ -297,6 +302,7 @@ scikit-learn uses an optimised version of the CART algorithm. .. _ID3: http://en.wikipedia.org/wiki/ID3_algorithm .. _CART: http://en.wikipedia.org/wiki/Predictive_analytics#Classification_and_regression_trees + .. _tree_mathematical_formulation: Mathematical formulation diff --git a/sklearn/tree/tests/test_tree.py b/sklearn/tree/tests/test_tree.py index f13b77840bc64..8092b4b342127 100644 --- a/sklearn/tree/tests/test_tree.py +++ b/sklearn/tree/tests/test_tree.py @@ -76,10 +76,10 @@ def test_graphviz_toy(): tree_toy = StringIO("digraph Tree {\n" "0 [label=\"X[0] <= 0.0000\\nerror = 0.5" - "\\nsamples = 6\\nvalue = [[ 3. 3.]]\", shape=\"box\"] ;\n" - "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 3. 0.]]\", shape=\"box\"] ;\n" + "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" + "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" "0 -> 1 ;\n" - "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 0. 3.]]\", shape=\"box\"] ;\n" + "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" "0 -> 2 ;\n" "}") contents2 = tree_toy.getvalue() @@ -95,10 +95,10 @@ def test_graphviz_toy(): tree_toy = StringIO("digraph Tree {\n" "0 [label=\"feature1 <= 0.0000\\nerror = 0.5" - "\\nsamples = 6\\nvalue = [[ 3. 3.]]\", shape=\"box\"] ;\n" - "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 3. 0.]]\", shape=\"box\"] ;\n" + "\\nsamples = 6\\nvalue = [ 3. 3.]\", shape=\"box\"] ;\n" + "1 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 3. 0.]\", shape=\"box\"] ;\n" "0 -> 1 ;\n" - "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [[ 0. 3.]]\", shape=\"box\"] ;\n" + "2 [label=\"error = 0.0000\\nsamples = 3\\nvalue = [ 0. 3.]\", shape=\"box\"] ;\n" "0 -> 2 ;\n" "}") contents2 = tree_toy.getvalue() diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index c7287be14997f..ecdd38abeb557 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -84,15 +84,23 @@ def node_to_str(tree, node_id): feature = feature_names[tree.feature[node_id]] else: feature = "X[%s]" % tree.feature[node_id] + + value = tree.value[node_id] + if tree.n_outputs == 1: + value = value[0, :] + if tree.children[node_id, 0] == Tree.LEAF: return "error = %.4f\\nsamples = %s\\nvalue = %s" \ - % (tree.init_error[node_id], tree.n_samples[node_id], - tree.value[node_id]) + % (tree.init_error[node_id], + tree.n_samples[node_id], + value) return "%s <= %.4f\\nerror = %s\\nsamples = %s\\nvalue = %s" \ - % (feature, tree.threshold[node_id], - tree.init_error[node_id], tree.n_samples[node_id], - tree.value[node_id]) + % (feature, + tree.threshold[node_id], + tree.init_error[node_id], + tree.n_samples[node_id], + value) def recurse(tree, node_id, parent=None): if node_id == Tree.LEAF: From e00d78959bf7ea3941d76903f0c1e48284aa5507 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 14:32:27 +0200 Subject: [PATCH 16/33] DOC: narrative documentation --- doc/modules/ensemble.rst | 6 +++++- doc/modules/tree.rst | 40 +++++++++++++++++++++++++++++++++++++--- sklearn/tree/tree.py | 19 ++++++++++--------- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/doc/modules/ensemble.rst b/doc/modules/ensemble.rst index 8e7f34cc7c7d1..719556c5fbcce 100644 --- a/doc/modules/ensemble.rst +++ b/doc/modules/ensemble.rst @@ -42,7 +42,7 @@ prediction of the individual classifiers. As other classifiers, forest classifiers have to be fitted with two arrays: an array X of size ``[n_samples, n_features]`` holding the training samples, and an array Y of size ``[n_samples]`` holding the -target values (class labels) for the training samples:: +target values (class labels or re) for the training samples:: >>> from sklearn.ensemble import RandomForestClassifier >>> X = [[0, 0], [1, 1]] @@ -50,6 +50,10 @@ target values (class labels) for the training samples:: >>> clf = RandomForestClassifier(n_estimators=10) >>> clf = clf.fit(X, Y) +Like :ref:`decision trees `, forests of trees also extend +to :ref:`multi-output problems ` (if Y is an array of size +``[n_samples, n_outputs]``). + Random Forests -------------- diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index a44fd1c3116fa..a0c7fdf5cff1d 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -38,6 +38,8 @@ Some advantages of decision trees are: of variable. See :ref:`algorithms ` for more information. + - Able to handle multi-output problems. + - Uses a white box model. If a given situation is observable in a model, the explanation for the condition is easily explained by boolean logic. By constrast, in a black box model (e.g., in an artificial neural @@ -88,8 +90,8 @@ Classification classification on a dataset. As other classifiers, :class:`DecisionTreeClassifier` take as input two -arrays: an array X of size [n_samples, n_features] holding the training -samples, and an array Y of integer values, size [n_samples], holding +arrays: an array X of size ``[n_samples, n_features]`` holding the training +samples, and an array Y of integer values, size ``[n_samples]``, holding the class labels for the training samples:: >>> from sklearn import tree @@ -180,6 +182,38 @@ instead of integer values:: * :ref:`example_tree_plot_tree_regression.py` +.. _tree_multioutput: + +Multi-output problems +===================== + +A multi-output problem is a supervised learning problem with several outputs +to predict, that is when Y is a 2d array of size ``[n_samples, n_outputs]``. + +When there is no correlation between the outputs, a very simple way to solve +this kind of problems is to build n independent models, i.e. one for each +output, and then to use those models to independently predict each one of the n +outputs. However, because it is likely that the output values related to the +same input are themselves correlated, an often better way is to build a single +model capable of predicting simultaneously all n outputs. + +With regard to decision trees, this strategy can readily be used to support +multi-output problems. This indeed amounts to: + + - Store n output values in leaves, instead of 1; + - Use splitting criteria that compute the average reduction across all + n outputs. + +Scikit-Learn offers support for multi-output problems by implementing this +strategy in both :class:`DecisionTreeClassifier` and +:class:`DecisionTreeRegressor`. If a decision tree is fit on an output array Y +of size ``[n_samples, n_outputs]`` then the resulting estimator will: + + - Output n_output values upon ``predict``; + - Output a list of n_output arrays of class probabilities upon + ``predict_proba``. + + .. _tree_complexity: Complexity @@ -196,7 +230,7 @@ largest reduction in entropy. This has a cost of total cost over the entire trees (by summing the cost at each node) of :math:`O(n_{features}n_{samples}^{2}log(n_{samples}))`. -Scikit-learn offers a more efficient implementation for the construction of +Scikit-Learn offers a more efficient implementation for the construction of decision trees. A naive implementation (as above) would recompute the class label histograms (for classification) or the means (for regression) at for each new split point along a given feature. By presorting the feature over all diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index ecdd38abeb557..5a746ea91562a 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -94,13 +94,13 @@ def node_to_str(tree, node_id): % (tree.init_error[node_id], tree.n_samples[node_id], value) - - return "%s <= %.4f\\nerror = %s\\nsamples = %s\\nvalue = %s" \ - % (feature, - tree.threshold[node_id], - tree.init_error[node_id], - tree.n_samples[node_id], - value) + else: + return "%s <= %.4f\\nerror = %s\\nsamples = %s\\nvalue = %s" \ + % (feature, + tree.threshold[node_id], + tree.init_error[node_id], + tree.n_samples[node_id], + value) def recurse(tree, node_id, parent=None): if node_id == Tree.LEAF: @@ -155,7 +155,7 @@ class Tree(object): The feature to split on (only for internal nodes). threshold : np.ndarray of float64 - The threshold of each node (only for leaves). + The threshold of each node (only for internal nodes). value : np.ndarray of float64, shape=(capacity, n_outputs, n_classes) Contains the constant prediction value of each node. @@ -242,6 +242,7 @@ def _add_split_node(self, parent, is_left_child, feature, threshold, self.children[parent, 1] = node_id self.node_count += 1 + return node_id def _add_leaf(self, parent, is_left_child, value, error, n_samples): @@ -262,8 +263,8 @@ def _add_leaf(self, parent, is_left_child, value, error, n_samples): self.children[parent, 1] = node_id self.children[node_id, :] = Tree.LEAF - self.node_count += 1 + return node_id def build(self, X, y, criterion, max_depth, min_samples_split, From 358884a602d0c0e43844057817202e6471ce4036 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 14:36:24 +0200 Subject: [PATCH 17/33] DOC: typo --- doc/modules/ensemble.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/modules/ensemble.rst b/doc/modules/ensemble.rst index 719556c5fbcce..3cebdf7f969a3 100644 --- a/doc/modules/ensemble.rst +++ b/doc/modules/ensemble.rst @@ -42,7 +42,7 @@ prediction of the individual classifiers. As other classifiers, forest classifiers have to be fitted with two arrays: an array X of size ``[n_samples, n_features]`` holding the training samples, and an array Y of size ``[n_samples]`` holding the -target values (class labels or re) for the training samples:: +target values (class labels) for the training samples:: >>> from sklearn.ensemble import RandomForestClassifier >>> X = [[0, 0], [1, 1]] From c549cb64189c40e71e5bba952fabd88809a61afb Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 15:18:59 +0200 Subject: [PATCH 18/33] DOC: Scikit-Learn -> scikit-learn --- doc/modules/tree.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index a0c7fdf5cff1d..7670052a48407 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -204,7 +204,7 @@ multi-output problems. This indeed amounts to: - Use splitting criteria that compute the average reduction across all n outputs. -Scikit-Learn offers support for multi-output problems by implementing this +This module offers support for multi-output problems by implementing this strategy in both :class:`DecisionTreeClassifier` and :class:`DecisionTreeRegressor`. If a decision tree is fit on an output array Y of size ``[n_samples, n_outputs]`` then the resulting estimator will: @@ -230,7 +230,7 @@ largest reduction in entropy. This has a cost of total cost over the entire trees (by summing the cost at each node) of :math:`O(n_{features}n_{samples}^{2}log(n_{samples}))`. -Scikit-Learn offers a more efficient implementation for the construction of +Scikit-learn offers a more efficient implementation for the construction of decision trees. A naive implementation (as above) would recompute the class label histograms (for classification) or the means (for regression) at for each new split point along a given feature. By presorting the feature over all From 0d4719ed8436c1c67a83f3afc8fdb8adb036a374 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 16:09:58 +0200 Subject: [PATCH 19/33] ENH: Cython improved code --- sklearn/tree/_tree.c | 1632 ++++++++++++++++++---------------------- sklearn/tree/_tree.pyx | 13 +- 2 files changed, 757 insertions(+), 888 deletions(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index f39176f7c6dd5..c072421757db4 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Fri Jun 29 14:07:08 2012 */ +/* Generated by Cython 0.16 on Mon Jul 2 16:09:42 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -723,7 +723,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion { }; -/* "sklearn/tree/_tree.pyx":252 +/* "sklearn/tree/_tree.pyx":253 * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -735,7 +735,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Gini { }; -/* "sklearn/tree/_tree.pyx":303 +/* "sklearn/tree/_tree.pyx":304 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -747,7 +747,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Entropy { }; -/* "sklearn/tree/_tree.pyx":345 +/* "sklearn/tree/_tree.pyx":346 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -771,7 +771,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion { }; -/* "sklearn/tree/_tree.pyx":573 +/* "sklearn/tree/_tree.pyx":574 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -802,7 +802,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; -/* "sklearn/tree/_tree.pyx":345 +/* "sklearn/tree/_tree.pyx":346 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -816,7 +816,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; -/* "sklearn/tree/_tree.pyx":573 +/* "sklearn/tree/_tree.pyx":574 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -844,7 +844,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; -/* "sklearn/tree/_tree.pyx":252 +/* "sklearn/tree/_tree.pyx":253 * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -858,7 +858,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini *__pyx_vtabptr_7sklearn_4tree_5_tree_Gini; -/* "sklearn/tree/_tree.pyx":303 +/* "sklearn/tree/_tree.pyx":304 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -1013,10 +1013,10 @@ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* o __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0) static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); /*proto*/ @@ -1191,9 +1191,6 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename); /*proto*/ - static int __Pyx_check_binary_version(void); static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ @@ -2351,23 +2348,16 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct int *__pyx_v_label_count_right; int __pyx_v_n_left; int __pyx_v_n_right; + int __pyx_v_idx; int __pyx_v_k; int __pyx_v_c; - int __pyx_v_idx; - PyObject *__pyx_v_s = NULL; + int __pyx_v_s; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; + int __pyx_t_2; + int __pyx_t_3; int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("update", 0); /* "sklearn/tree/_tree.pyx":205 @@ -2420,11 +2410,11 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct * cdef int n_left = self.n_left * cdef int n_right = self.n_right # <<<<<<<<<<<<<< * - * cdef int k + * cdef int idx, k, c, s */ __pyx_v_n_right = __pyx_v_self->n_right; - /* "sklearn/tree/_tree.pyx":216 + /* "sklearn/tree/_tree.pyx":215 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -2434,31 +2424,26 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":217 + /* "sklearn/tree/_tree.pyx":216 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * s = X_argsorted_i[idx] # <<<<<<<<<<<<<< * * if sample_mask[s] == 0: */ - __pyx_t_2 = PyInt_FromLong((__pyx_v_X_argsorted_i[__pyx_v_idx])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_v_s); - __pyx_v_s = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_s = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":219 + /* "sklearn/tree/_tree.pyx":218 * s = X_argsorted_i[idx] * * if sample_mask[s] == 0: # <<<<<<<<<<<<<< * continue * */ - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_s); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = ((__pyx_v_sample_mask[__pyx_t_3]) == 0); - if (__pyx_t_4) { + __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_s]) == 0); + if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":220 + /* "sklearn/tree/_tree.pyx":219 * * if sample_mask[s] == 0: * continue # <<<<<<<<<<<<<< @@ -2470,60 +2455,47 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":222 + /* "sklearn/tree/_tree.pyx":221 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< * c = y[s * y_stride + k] * label_count_right[k * label_count_stride + c] -= 1 */ - __pyx_t_5 = __pyx_v_n_outputs; - for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) { + __pyx_t_3 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":223 + /* "sklearn/tree/_tree.pyx":222 * * for k from 0 <= k < n_outputs: * c = y[s * y_stride + k] # <<<<<<<<<<<<<< * label_count_right[k * label_count_stride + c] -= 1 * label_count_left[k * label_count_stride + c] += 1 */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_y_stride); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyNumber_Multiply(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_c = ((int)(__pyx_v_y[__pyx_t_3])); + __pyx_v_c = ((int)(__pyx_v_y[((__pyx_v_s * __pyx_v_y_stride) + __pyx_v_k)])); - /* "sklearn/tree/_tree.pyx":224 + /* "sklearn/tree/_tree.pyx":223 * for k from 0 <= k < n_outputs: * c = y[s * y_stride + k] * label_count_right[k * label_count_stride + c] -= 1 # <<<<<<<<<<<<<< * label_count_left[k * label_count_stride + c] += 1 * */ - __pyx_t_8 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); - (__pyx_v_label_count_right[__pyx_t_8]) = ((__pyx_v_label_count_right[__pyx_t_8]) - 1); + __pyx_t_4 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); + (__pyx_v_label_count_right[__pyx_t_4]) = ((__pyx_v_label_count_right[__pyx_t_4]) - 1); - /* "sklearn/tree/_tree.pyx":225 + /* "sklearn/tree/_tree.pyx":224 * c = y[s * y_stride + k] * label_count_right[k * label_count_stride + c] -= 1 * label_count_left[k * label_count_stride + c] += 1 # <<<<<<<<<<<<<< * * n_left += 1 */ - __pyx_t_8 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); - (__pyx_v_label_count_left[__pyx_t_8]) = ((__pyx_v_label_count_left[__pyx_t_8]) + 1); + __pyx_t_4 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); + (__pyx_v_label_count_left[__pyx_t_4]) = ((__pyx_v_label_count_left[__pyx_t_4]) + 1); } - /* "sklearn/tree/_tree.pyx":227 + /* "sklearn/tree/_tree.pyx":226 * label_count_left[k * label_count_stride + c] += 1 * * n_left += 1 # <<<<<<<<<<<<<< @@ -2532,7 +2504,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_n_left = (__pyx_v_n_left + 1); - /* "sklearn/tree/_tree.pyx":228 + /* "sklearn/tree/_tree.pyx":227 * * n_left += 1 * n_right -=1 # <<<<<<<<<<<<<< @@ -2543,7 +2515,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":230 + /* "sklearn/tree/_tree.pyx":229 * n_right -=1 * * self.n_left = n_left # <<<<<<<<<<<<<< @@ -2552,7 +2524,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_self->n_left = __pyx_v_n_left; - /* "sklearn/tree/_tree.pyx":231 + /* "sklearn/tree/_tree.pyx":230 * * self.n_left = n_left * self.n_right = n_right # <<<<<<<<<<<<<< @@ -2561,7 +2533,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_self->n_right = __pyx_v_n_right; - /* "sklearn/tree/_tree.pyx":233 + /* "sklearn/tree/_tree.pyx":232 * self.n_right = n_right * * return n_left # <<<<<<<<<<<<<< @@ -2571,21 +2543,13 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_r = __pyx_v_n_left; goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_WriteUnraisable("sklearn.tree._tree.ClassificationCriterion.update", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_s); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "sklearn/tree/_tree.pyx":235 +/* "sklearn/tree/_tree.pyx":234 * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -2603,7 +2567,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(CYTHO return __pyx_r; } -/* "sklearn/tree/_tree.pyx":238 +/* "sklearn/tree/_tree.pyx":237 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -2618,8 +2582,8 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in int __pyx_v_label_count_stride; int *__pyx_v_label_count_init; PyArrayObject *__pyx_v_value = 0; - PyObject *__pyx_v_k = NULL; - PyObject *__pyx_v_c = NULL; + int __pyx_v_k; + int __pyx_v_c; __Pyx_LocalBuf_ND __pyx_pybuffernd_value; __Pyx_Buffer __pyx_pybuffer_value; PyArrayObject *__pyx_r = NULL; @@ -2630,10 +2594,9 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in PyObject *__pyx_t_4 = NULL; PyArrayObject *__pyx_t_5 = NULL; int __pyx_t_6; - long __pyx_t_7; - Py_ssize_t __pyx_t_8; + int __pyx_t_7; + int __pyx_t_8; int __pyx_t_9; - long __pyx_t_10; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -2646,13 +2609,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2661,7 +2624,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":239 + /* "sklearn/tree/_tree.pyx":238 * * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2670,7 +2633,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":240 + /* "sklearn/tree/_tree.pyx":239 * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2679,7 +2642,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_n_classes = __pyx_v_self->n_classes; - /* "sklearn/tree/_tree.pyx":241 + /* "sklearn/tree/_tree.pyx":240 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2688,7 +2651,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; - /* "sklearn/tree/_tree.pyx":242 + /* "sklearn/tree/_tree.pyx":241 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< @@ -2697,23 +2660,23 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_label_count_init = __pyx_v_self->label_count_init; - /* "sklearn/tree/_tree.pyx":244 + /* "sklearn/tree/_tree.pyx":243 * cdef int* label_count_init = self.label_count_init * * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) # <<<<<<<<<<<<<< * - * for k from 0 <= k < n_outputs: + * cdef int k, c */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -2721,29 +2684,29 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_GIVEREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__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_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; } } @@ -2751,99 +2714,40 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __pyx_v_value = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":246 - * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + /* "sklearn/tree/_tree.pyx":247 + * cdef int k, c * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< * for c from 0 <= c < n_classes[k]: * value[k, c] = (label_count_init[k * label_count_stride + c]) */ __pyx_t_6 = __pyx_v_n_outputs; - for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7++) { - __pyx_t_1 = PyInt_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_k); - __pyx_v_k = __pyx_t_1; - __pyx_t_1 = 0; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":247 + /* "sklearn/tree/_tree.pyx":248 * * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< * value[k, c] = (label_count_init[k * label_count_stride + c]) * */ - __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = (__pyx_v_n_classes[__pyx_t_8]); - for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10++) { - __pyx_t_1 = PyInt_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_c); - __pyx_v_c = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_7 = (__pyx_v_n_classes[__pyx_v_k]); + for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_7; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":248 + /* "sklearn/tree/_tree.pyx":249 * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: * value[k, c] = (label_count_init[k * label_count_stride + c]) # <<<<<<<<<<<<<< * * return value */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyNumber_Multiply(__pyx_v_k, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble(((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_label_count_init[__pyx_t_8]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_k); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_k); - __Pyx_GIVEREF(__pyx_v_k); - __Pyx_INCREF(__pyx_v_c); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_c); - __Pyx_GIVEREF(__pyx_v_c); - if (PyObject_SetItem(((PyObject *)__pyx_v_value), ((PyObject *)__pyx_t_4), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_10 = __Pyx_PyInt_AsLong(__pyx_v_c); if (unlikely((__pyx_t_10 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __pyx_v_k; + __pyx_t_9 = __pyx_v_c; + *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_value.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_value.diminfo[1].strides) = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_label_count_init[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)])); } - - /* "sklearn/tree/_tree.pyx":247 - * - * for k from 0 <= k < n_outputs: - * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< - * value[k, c] = (label_count_init[k * label_count_stride + c]) - * - */ - __pyx_t_1 = PyInt_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_c); - __pyx_v_c = __pyx_t_1; - __pyx_t_1 = 0; - __pyx_t_7 = __Pyx_PyInt_AsLong(__pyx_v_k); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "sklearn/tree/_tree.pyx":246 - * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) - * - * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< - * for c from 0 <= c < n_classes[k]: - * value[k, c] = (label_count_init[k * label_count_stride + c]) - */ - __pyx_t_1 = PyInt_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_k); - __pyx_v_k = __pyx_t_1; - __pyx_t_1 = 0; - - /* "sklearn/tree/_tree.pyx":250 + /* "sklearn/tree/_tree.pyx":251 * value[k, c] = (label_count_init[k * label_count_stride + c]) * * return value # <<<<<<<<<<<<<< @@ -2873,8 +2777,6 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_value.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_value); - __Pyx_XDECREF(__pyx_v_k); - __Pyx_XDECREF(__pyx_v_c); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -2891,7 +2793,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":238 +/* "sklearn/tree/_tree.pyx":237 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -2908,7 +2810,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2926,7 +2828,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":259 +/* "sklearn/tree/_tree.pyx":260 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -2957,7 +2859,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":261 + /* "sklearn/tree/_tree.pyx":262 * cdef double eval(self): * """Returns Gini index of left branch + Gini index of right branch. """ * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -2966,7 +2868,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; - /* "sklearn/tree/_tree.pyx":262 + /* "sklearn/tree/_tree.pyx":263 * """Returns Gini index of left branch + Gini index of right branch. """ * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2975,7 +2877,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":263 + /* "sklearn/tree/_tree.pyx":264 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2984,7 +2886,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; - /* "sklearn/tree/_tree.pyx":264 + /* "sklearn/tree/_tree.pyx":265 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2993,7 +2895,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; - /* "sklearn/tree/_tree.pyx":265 + /* "sklearn/tree/_tree.pyx":266 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -3002,7 +2904,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; - /* "sklearn/tree/_tree.pyx":266 + /* "sklearn/tree/_tree.pyx":267 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -3011,7 +2913,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; - /* "sklearn/tree/_tree.pyx":267 + /* "sklearn/tree/_tree.pyx":268 * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< @@ -3020,7 +2922,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":268 + /* "sklearn/tree/_tree.pyx":269 * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< @@ -3029,7 +2931,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); - /* "sklearn/tree/_tree.pyx":270 + /* "sklearn/tree/_tree.pyx":271 * cdef double n_right = self.n_right * * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -3038,7 +2940,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":275 + /* "sklearn/tree/_tree.pyx":276 * cdef int k, c, count_left, count_right * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3048,7 +2950,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":276 + /* "sklearn/tree/_tree.pyx":277 * * for k from 0 <= k < n_outputs: * H_left = n_left * n_left # <<<<<<<<<<<<<< @@ -3057,7 +2959,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_H_left = (__pyx_v_n_left * __pyx_v_n_left); - /* "sklearn/tree/_tree.pyx":277 + /* "sklearn/tree/_tree.pyx":278 * for k from 0 <= k < n_outputs: * H_left = n_left * n_left * H_right = n_right * n_right # <<<<<<<<<<<<<< @@ -3066,7 +2968,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_H_right = (__pyx_v_n_right * __pyx_v_n_right); - /* "sklearn/tree/_tree.pyx":279 + /* "sklearn/tree/_tree.pyx":280 * H_right = n_right * n_right * * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -3076,7 +2978,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":280 + /* "sklearn/tree/_tree.pyx":281 * * for c from 0 <= c < n_classes[k]: * count_left = label_count_left[k * label_count_stride + c] # <<<<<<<<<<<<<< @@ -3085,7 +2987,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_count_left = (__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":281 + /* "sklearn/tree/_tree.pyx":282 * for c from 0 <= c < n_classes[k]: * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: # <<<<<<<<<<<<<< @@ -3095,7 +2997,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_left > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":282 + /* "sklearn/tree/_tree.pyx":283 * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: * H_left -= (count_left * count_left) # <<<<<<<<<<<<<< @@ -3107,7 +3009,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":284 + /* "sklearn/tree/_tree.pyx":285 * H_left -= (count_left * count_left) * * count_right = label_count_right[k * label_count_stride + c] # <<<<<<<<<<<<<< @@ -3116,7 +3018,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_count_right = (__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":285 + /* "sklearn/tree/_tree.pyx":286 * * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: # <<<<<<<<<<<<<< @@ -3126,7 +3028,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_right > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":286 + /* "sklearn/tree/_tree.pyx":287 * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: * H_right -= (count_right * count_right) # <<<<<<<<<<<<<< @@ -3139,7 +3041,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":288 + /* "sklearn/tree/_tree.pyx":289 * H_right -= (count_right * count_right) * * if n_left == 0: # <<<<<<<<<<<<<< @@ -3149,7 +3051,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_left == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":289 + /* "sklearn/tree/_tree.pyx":290 * * if n_left == 0: * H_left = 0 # <<<<<<<<<<<<<< @@ -3161,7 +3063,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":291 + /* "sklearn/tree/_tree.pyx":292 * H_left = 0 * else: * H_left /= n_left # <<<<<<<<<<<<<< @@ -3172,7 +3074,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L9:; - /* "sklearn/tree/_tree.pyx":293 + /* "sklearn/tree/_tree.pyx":294 * H_left /= n_left * * if n_right == 0: # <<<<<<<<<<<<<< @@ -3182,7 +3084,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_right == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":294 + /* "sklearn/tree/_tree.pyx":295 * * if n_right == 0: * H_right = 0 # <<<<<<<<<<<<<< @@ -3194,7 +3096,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":296 + /* "sklearn/tree/_tree.pyx":297 * H_right = 0 * else: * H_right /= n_right # <<<<<<<<<<<<<< @@ -3205,7 +3107,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L10:; - /* "sklearn/tree/_tree.pyx":298 + /* "sklearn/tree/_tree.pyx":299 * H_right /= n_right * * total += (H_left + H_right) # <<<<<<<<<<<<<< @@ -3215,7 +3117,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_v_total = (__pyx_v_total + (__pyx_v_H_left + __pyx_v_H_right)); } - /* "sklearn/tree/_tree.pyx":300 + /* "sklearn/tree/_tree.pyx":301 * total += (H_left + H_right) * * return total / (n_samples * n_outputs) # <<<<<<<<<<<<<< @@ -3231,7 +3133,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn return __pyx_r; } -/* "sklearn/tree/_tree.pyx":309 +/* "sklearn/tree/_tree.pyx":310 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -3262,7 +3164,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":311 + /* "sklearn/tree/_tree.pyx":312 * cdef double eval(self): * """Returns Entropy of left branch + Entropy index of right branch. """ * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -3271,7 +3173,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; - /* "sklearn/tree/_tree.pyx":312 + /* "sklearn/tree/_tree.pyx":313 * """Returns Entropy of left branch + Entropy index of right branch. """ * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -3280,7 +3182,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":313 + /* "sklearn/tree/_tree.pyx":314 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -3289,7 +3191,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; - /* "sklearn/tree/_tree.pyx":314 + /* "sklearn/tree/_tree.pyx":315 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -3298,7 +3200,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; - /* "sklearn/tree/_tree.pyx":315 + /* "sklearn/tree/_tree.pyx":316 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -3307,7 +3209,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; - /* "sklearn/tree/_tree.pyx":316 + /* "sklearn/tree/_tree.pyx":317 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -3316,7 +3218,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; - /* "sklearn/tree/_tree.pyx":317 + /* "sklearn/tree/_tree.pyx":318 * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< @@ -3325,7 +3227,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":318 + /* "sklearn/tree/_tree.pyx":319 * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< @@ -3334,7 +3236,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); - /* "sklearn/tree/_tree.pyx":320 + /* "sklearn/tree/_tree.pyx":321 * cdef double n_right = self.n_right * * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -3343,7 +3245,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":326 + /* "sklearn/tree/_tree.pyx":327 * cdef double e1, e2 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3353,7 +3255,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":327 + /* "sklearn/tree/_tree.pyx":328 * * for k from 0 <= k < n_outputs: * H_left = 0.0 # <<<<<<<<<<<<<< @@ -3362,7 +3264,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_H_left = 0.0; - /* "sklearn/tree/_tree.pyx":328 + /* "sklearn/tree/_tree.pyx":329 * for k from 0 <= k < n_outputs: * H_left = 0.0 * H_right = 0.0 # <<<<<<<<<<<<<< @@ -3371,7 +3273,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_H_right = 0.0; - /* "sklearn/tree/_tree.pyx":330 + /* "sklearn/tree/_tree.pyx":331 * H_right = 0.0 * * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -3381,7 +3283,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":331 + /* "sklearn/tree/_tree.pyx":332 * * for c from 0 <= c < n_classes[k]: * if label_count_left[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< @@ -3391,7 +3293,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_3 = ((__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":332 + /* "sklearn/tree/_tree.pyx":333 * for c from 0 <= c < n_classes[k]: * if label_count_left[k * label_count_stride + c] > 0: * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) # <<<<<<<<<<<<<< @@ -3403,7 +3305,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":334 + /* "sklearn/tree/_tree.pyx":335 * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) * * if self.label_count_right[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< @@ -3413,7 +3315,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_3 = ((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":335 + /* "sklearn/tree/_tree.pyx":336 * * if self.label_count_right[k * label_count_stride + c] > 0: * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) # <<<<<<<<<<<<<< @@ -3426,7 +3328,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":337 + /* "sklearn/tree/_tree.pyx":338 * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) * * e1 = (n_left / n_samples) * H_left # <<<<<<<<<<<<<< @@ -3435,7 +3337,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_e1 = ((__pyx_v_n_left / __pyx_v_n_samples) * __pyx_v_H_left); - /* "sklearn/tree/_tree.pyx":338 + /* "sklearn/tree/_tree.pyx":339 * * e1 = (n_left / n_samples) * H_left * e2 = (n_right / n_samples) * H_right # <<<<<<<<<<<<<< @@ -3444,7 +3346,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_e2 = ((__pyx_v_n_right / __pyx_v_n_samples) * __pyx_v_H_right); - /* "sklearn/tree/_tree.pyx":340 + /* "sklearn/tree/_tree.pyx":341 * e2 = (n_right / n_samples) * H_right * * total += e1 + e2 # <<<<<<<<<<<<<< @@ -3454,7 +3356,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_v_total = (__pyx_v_total + (__pyx_v_e1 + __pyx_v_e2)); } - /* "sklearn/tree/_tree.pyx":342 + /* "sklearn/tree/_tree.pyx":343 * total += e1 + e2 * * return total / n_outputs # <<<<<<<<<<<<<< @@ -3496,18 +3398,18 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3518,7 +3420,7 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje return __pyx_r; } -/* "sklearn/tree/_tree.pyx":399 +/* "sklearn/tree/_tree.pyx":400 * cdef int n_left * * def __init__(self, int n_outputs): # <<<<<<<<<<<<<< @@ -3532,7 +3434,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "sklearn/tree/_tree.pyx":400 + /* "sklearn/tree/_tree.pyx":401 * * def __init__(self, int n_outputs): * cdef int k = 0 # <<<<<<<<<<<<<< @@ -3541,7 +3443,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":402 + /* "sklearn/tree/_tree.pyx":403 * cdef int k = 0 * * self.n_outputs = n_outputs # <<<<<<<<<<<<<< @@ -3550,7 +3452,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_outputs = __pyx_v_n_outputs; - /* "sklearn/tree/_tree.pyx":404 + /* "sklearn/tree/_tree.pyx":405 * self.n_outputs = n_outputs * * self.n_samples = 0 # <<<<<<<<<<<<<< @@ -3559,7 +3461,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_samples = 0; - /* "sklearn/tree/_tree.pyx":405 + /* "sklearn/tree/_tree.pyx":406 * * self.n_samples = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -3568,7 +3470,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":406 + /* "sklearn/tree/_tree.pyx":407 * self.n_samples = 0 * self.n_left = 0 * self.n_right = 0 # <<<<<<<<<<<<<< @@ -3577,7 +3479,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_right = 0; - /* "sklearn/tree/_tree.pyx":408 + /* "sklearn/tree/_tree.pyx":409 * self.n_right = 0 * * self.mean_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3586,7 +3488,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":409 + /* "sklearn/tree/_tree.pyx":410 * * self.mean_left = calloc(n_outputs, sizeof(double)) * self.mean_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3595,7 +3497,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":410 + /* "sklearn/tree/_tree.pyx":411 * self.mean_left = calloc(n_outputs, sizeof(double)) * self.mean_right = calloc(n_outputs, sizeof(double)) * self.mean_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3604,7 +3506,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":411 + /* "sklearn/tree/_tree.pyx":412 * self.mean_right = calloc(n_outputs, sizeof(double)) * self.mean_init = calloc(n_outputs, sizeof(double)) * self.sq_sum_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3613,7 +3515,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":412 + /* "sklearn/tree/_tree.pyx":413 * self.mean_init = calloc(n_outputs, sizeof(double)) * self.sq_sum_left = calloc(n_outputs, sizeof(double)) * self.sq_sum_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3622,7 +3524,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":413 + /* "sklearn/tree/_tree.pyx":414 * self.sq_sum_left = calloc(n_outputs, sizeof(double)) * self.sq_sum_right = calloc(n_outputs, sizeof(double)) * self.sq_sum_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3631,7 +3533,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":414 + /* "sklearn/tree/_tree.pyx":415 * self.sq_sum_right = calloc(n_outputs, sizeof(double)) * self.sq_sum_init = calloc(n_outputs, sizeof(double)) * self.var_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3640,7 +3542,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->var_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":415 + /* "sklearn/tree/_tree.pyx":416 * self.sq_sum_init = calloc(n_outputs, sizeof(double)) * self.var_left = calloc(n_outputs, sizeof(double)) * self.var_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3665,7 +3567,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3__del__(P return __pyx_r; } -/* "sklearn/tree/_tree.pyx":417 +/* "sklearn/tree/_tree.pyx":418 * self.var_right = calloc(n_outputs, sizeof(double)) * * def __del__(self): # <<<<<<<<<<<<<< @@ -3678,7 +3580,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); - /* "sklearn/tree/_tree.pyx":418 + /* "sklearn/tree/_tree.pyx":419 * * def __del__(self): * free(self.mean_left) # <<<<<<<<<<<<<< @@ -3687,7 +3589,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_left); - /* "sklearn/tree/_tree.pyx":419 + /* "sklearn/tree/_tree.pyx":420 * def __del__(self): * free(self.mean_left) * free(self.mean_right) # <<<<<<<<<<<<<< @@ -3696,7 +3598,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_right); - /* "sklearn/tree/_tree.pyx":420 + /* "sklearn/tree/_tree.pyx":421 * free(self.mean_left) * free(self.mean_right) * free(self.mean_init) # <<<<<<<<<<<<<< @@ -3705,7 +3607,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_init); - /* "sklearn/tree/_tree.pyx":421 + /* "sklearn/tree/_tree.pyx":422 * free(self.mean_right) * free(self.mean_init) * free(self.sq_sum_left) # <<<<<<<<<<<<<< @@ -3714,7 +3616,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_left); - /* "sklearn/tree/_tree.pyx":422 + /* "sklearn/tree/_tree.pyx":423 * free(self.mean_init) * free(self.sq_sum_left) * free(self.sq_sum_right) # <<<<<<<<<<<<<< @@ -3723,7 +3625,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_right); - /* "sklearn/tree/_tree.pyx":423 + /* "sklearn/tree/_tree.pyx":424 * free(self.sq_sum_left) * free(self.sq_sum_right) * free(self.sq_sum_init) # <<<<<<<<<<<<<< @@ -3732,7 +3634,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_init); - /* "sklearn/tree/_tree.pyx":424 + /* "sklearn/tree/_tree.pyx":425 * free(self.sq_sum_right) * free(self.sq_sum_init) * free(self.var_left) # <<<<<<<<<<<<<< @@ -3741,7 +3643,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->var_left); - /* "sklearn/tree/_tree.pyx":425 + /* "sklearn/tree/_tree.pyx":426 * free(self.sq_sum_init) * free(self.var_left) * free(self.var_right) # <<<<<<<<<<<<<< @@ -3756,7 +3658,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s return __pyx_r; } -/* "sklearn/tree/_tree.pyx":427 +/* "sklearn/tree/_tree.pyx":428 * free(self.var_right) * * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< @@ -3784,7 +3686,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py int __pyx_t_4; __Pyx_RefNannySetupContext("init", 0); - /* "sklearn/tree/_tree.pyx":435 + /* "sklearn/tree/_tree.pyx":436 * are in the right branch and store the mean and squared * sum in `self.mean_init` and `self.sq_sum_init`. """ * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -3793,7 +3695,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":436 + /* "sklearn/tree/_tree.pyx":437 * sum in `self.mean_init` and `self.sq_sum_init`. """ * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -3802,7 +3704,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":437 + /* "sklearn/tree/_tree.pyx":438 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -3811,7 +3713,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":438 + /* "sklearn/tree/_tree.pyx":439 * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -3820,7 +3722,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":439 + /* "sklearn/tree/_tree.pyx":440 * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -3829,7 +3731,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":440 + /* "sklearn/tree/_tree.pyx":441 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< @@ -3838,7 +3740,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; - /* "sklearn/tree/_tree.pyx":441 + /* "sklearn/tree/_tree.pyx":442 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -3847,7 +3749,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":442 + /* "sklearn/tree/_tree.pyx":443 * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -3856,7 +3758,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":443 + /* "sklearn/tree/_tree.pyx":444 * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -3865,7 +3767,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":445 + /* "sklearn/tree/_tree.pyx":446 * cdef int n_outputs = self.n_outputs * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -3874,7 +3776,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":447 + /* "sklearn/tree/_tree.pyx":448 * cdef int k = 0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3884,7 +3786,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":448 + /* "sklearn/tree/_tree.pyx":449 * * for k from 0 <= k < n_outputs: * mean_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3893,7 +3795,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":449 + /* "sklearn/tree/_tree.pyx":450 * for k from 0 <= k < n_outputs: * mean_left[k] = 0.0 * mean_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3902,7 +3804,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":450 + /* "sklearn/tree/_tree.pyx":451 * mean_left[k] = 0.0 * mean_right[k] = 0.0 * mean_init[k] = 0.0 # <<<<<<<<<<<<<< @@ -3911,7 +3813,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":451 + /* "sklearn/tree/_tree.pyx":452 * mean_right[k] = 0.0 * mean_init[k] = 0.0 * sq_sum_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3920,7 +3822,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":452 + /* "sklearn/tree/_tree.pyx":453 * mean_init[k] = 0.0 * sq_sum_right[k] = 0.0 * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3929,7 +3831,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":453 + /* "sklearn/tree/_tree.pyx":454 * sq_sum_right[k] = 0.0 * sq_sum_left[k] = 0.0 * sq_sum_init[k] = 0.0 # <<<<<<<<<<<<<< @@ -3938,7 +3840,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":454 + /* "sklearn/tree/_tree.pyx":455 * sq_sum_left[k] = 0.0 * sq_sum_init[k] = 0.0 * var_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3947,7 +3849,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":455 + /* "sklearn/tree/_tree.pyx":456 * sq_sum_init[k] = 0.0 * var_left[k] = 0.0 * var_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3957,7 +3859,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py (__pyx_v_var_right[__pyx_v_k]) = 0.0; } - /* "sklearn/tree/_tree.pyx":457 + /* "sklearn/tree/_tree.pyx":458 * var_right[k] = 0.0 * * self.n_samples = n_samples # <<<<<<<<<<<<<< @@ -3966,7 +3868,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_self->n_samples = __pyx_v_n_samples; - /* "sklearn/tree/_tree.pyx":459 + /* "sklearn/tree/_tree.pyx":460 * self.n_samples = n_samples * * cdef int j = 0 # <<<<<<<<<<<<<< @@ -3975,7 +3877,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_j = 0; - /* "sklearn/tree/_tree.pyx":460 + /* "sklearn/tree/_tree.pyx":461 * * cdef int j = 0 * cdef DTYPE_t y_jk = 0.0 # <<<<<<<<<<<<<< @@ -3984,7 +3886,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_y_jk = 0.0; - /* "sklearn/tree/_tree.pyx":462 + /* "sklearn/tree/_tree.pyx":463 * cdef DTYPE_t y_jk = 0.0 * * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< @@ -3994,7 +3896,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_total_samples; for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_1; __pyx_v_j++) { - /* "sklearn/tree/_tree.pyx":463 + /* "sklearn/tree/_tree.pyx":464 * * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -4004,7 +3906,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":464 + /* "sklearn/tree/_tree.pyx":465 * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -4016,7 +3918,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":466 + /* "sklearn/tree/_tree.pyx":467 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4026,7 +3928,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":467 + /* "sklearn/tree/_tree.pyx":468 * * for k from 0 <= k < n_outputs: * y_jk = y[j * y_stride + k] # <<<<<<<<<<<<<< @@ -4035,7 +3937,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_y_jk = (__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)]); - /* "sklearn/tree/_tree.pyx":468 + /* "sklearn/tree/_tree.pyx":469 * for k from 0 <= k < n_outputs: * y_jk = y[j * y_stride + k] * sq_sum_init[k] += y_jk * y_jk # <<<<<<<<<<<<<< @@ -4045,7 +3947,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_init[__pyx_t_4]) = ((__pyx_v_sq_sum_init[__pyx_t_4]) + (__pyx_v_y_jk * __pyx_v_y_jk)); - /* "sklearn/tree/_tree.pyx":469 + /* "sklearn/tree/_tree.pyx":470 * y_jk = y[j * y_stride + k] * sq_sum_init[k] += y_jk * y_jk * mean_init[k] += y_jk # <<<<<<<<<<<<<< @@ -4058,7 +3960,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_L5_continue:; } - /* "sklearn/tree/_tree.pyx":471 + /* "sklearn/tree/_tree.pyx":472 * mean_init[k] += y_jk * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4068,7 +3970,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":472 + /* "sklearn/tree/_tree.pyx":473 * * for k from 0 <= k < n_outputs: * mean_init[k] /= n_samples # <<<<<<<<<<<<<< @@ -4079,7 +3981,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py (__pyx_v_mean_init[__pyx_t_3]) = ((__pyx_v_mean_init[__pyx_t_3]) / __pyx_v_n_samples); } - /* "sklearn/tree/_tree.pyx":474 + /* "sklearn/tree/_tree.pyx":475 * mean_init[k] /= n_samples * * self.reset() # <<<<<<<<<<<<<< @@ -4091,7 +3993,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":476 +/* "sklearn/tree/_tree.pyx":477 * self.reset() * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -4115,7 +4017,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p int __pyx_t_1; __Pyx_RefNannySetupContext("reset", 0); - /* "sklearn/tree/_tree.pyx":483 + /* "sklearn/tree/_tree.pyx":484 * right branch. * """ * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -4124,7 +4026,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":484 + /* "sklearn/tree/_tree.pyx":485 * """ * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -4133,7 +4035,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":485 + /* "sklearn/tree/_tree.pyx":486 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -4142,7 +4044,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":486 + /* "sklearn/tree/_tree.pyx":487 * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -4151,7 +4053,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":487 + /* "sklearn/tree/_tree.pyx":488 * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -4160,7 +4062,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":488 + /* "sklearn/tree/_tree.pyx":489 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< @@ -4169,7 +4071,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; - /* "sklearn/tree/_tree.pyx":489 + /* "sklearn/tree/_tree.pyx":490 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4178,7 +4080,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":490 + /* "sklearn/tree/_tree.pyx":491 * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4187,7 +4089,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":492 + /* "sklearn/tree/_tree.pyx":493 * cdef double* var_right = self.var_right * * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -4196,7 +4098,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_n_samples = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":493 + /* "sklearn/tree/_tree.pyx":494 * * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4205,7 +4107,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":495 + /* "sklearn/tree/_tree.pyx":496 * cdef int n_outputs = self.n_outputs * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -4214,7 +4116,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":497 + /* "sklearn/tree/_tree.pyx":498 * cdef int k = 0 * * self.n_right = self.n_samples # <<<<<<<<<<<<<< @@ -4223,7 +4125,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_self->n_right = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":498 + /* "sklearn/tree/_tree.pyx":499 * * self.n_right = self.n_samples * self.n_left = 0 # <<<<<<<<<<<<<< @@ -4232,7 +4134,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":500 + /* "sklearn/tree/_tree.pyx":501 * self.n_left = 0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4242,7 +4144,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":501 + /* "sklearn/tree/_tree.pyx":502 * * for k from 0 <= k < n_outputs: * mean_right[k] = mean_init[k] # <<<<<<<<<<<<<< @@ -4251,7 +4153,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_mean_right[__pyx_v_k]) = (__pyx_v_mean_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":502 + /* "sklearn/tree/_tree.pyx":503 * for k from 0 <= k < n_outputs: * mean_right[k] = mean_init[k] * mean_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4260,7 +4162,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":503 + /* "sklearn/tree/_tree.pyx":504 * mean_right[k] = mean_init[k] * mean_left[k] = 0.0 * sq_sum_right[k] = sq_sum_init[k] # <<<<<<<<<<<<<< @@ -4269,7 +4171,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_sq_sum_right[__pyx_v_k]) = (__pyx_v_sq_sum_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":504 + /* "sklearn/tree/_tree.pyx":505 * mean_left[k] = 0.0 * sq_sum_right[k] = sq_sum_init[k] * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4278,7 +4180,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":505 + /* "sklearn/tree/_tree.pyx":506 * sq_sum_right[k] = sq_sum_init[k] * sq_sum_left[k] = 0.0 * var_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4287,7 +4189,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":506 + /* "sklearn/tree/_tree.pyx":507 * sq_sum_left[k] = 0.0 * var_left[k] = 0.0 * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< @@ -4300,7 +4202,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":508 +/* "sklearn/tree/_tree.pyx":509 * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) * * cdef int update(self, int a, # <<<<<<<<<<<<<< @@ -4331,7 +4233,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p int __pyx_t_4; __Pyx_RefNannySetupContext("update", 0); - /* "sklearn/tree/_tree.pyx":516 + /* "sklearn/tree/_tree.pyx":517 * """Update the criteria for each value in interval [a,b) (where a and b * are indices in `X_argsorted_i`).""" * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -4340,7 +4242,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":517 + /* "sklearn/tree/_tree.pyx":518 * are indices in `X_argsorted_i`).""" * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -4349,7 +4251,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":518 + /* "sklearn/tree/_tree.pyx":519 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -4358,7 +4260,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":519 + /* "sklearn/tree/_tree.pyx":520 * cdef double* mean_right = self.mean_right * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -4367,7 +4269,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":520 + /* "sklearn/tree/_tree.pyx":521 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4376,7 +4278,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":521 + /* "sklearn/tree/_tree.pyx":522 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4385,7 +4287,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":523 + /* "sklearn/tree/_tree.pyx":524 * cdef double* var_right = self.var_right * * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -4394,7 +4296,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_samples = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":524 + /* "sklearn/tree/_tree.pyx":525 * * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4403,7 +4305,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":525 + /* "sklearn/tree/_tree.pyx":526 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int n_left = self.n_left # <<<<<<<<<<<<<< @@ -4412,7 +4314,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_left = __pyx_v_self->n_left; - /* "sklearn/tree/_tree.pyx":526 + /* "sklearn/tree/_tree.pyx":527 * cdef int n_outputs = self.n_outputs * cdef int n_left = self.n_left * cdef int n_right = self.n_right # <<<<<<<<<<<<<< @@ -4421,7 +4323,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_right = __pyx_v_self->n_right; - /* "sklearn/tree/_tree.pyx":528 + /* "sklearn/tree/_tree.pyx":529 * cdef int n_right = self.n_right * * cdef double y_idx = 0.0 # <<<<<<<<<<<<<< @@ -4430,7 +4332,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_y_idx = 0.0; - /* "sklearn/tree/_tree.pyx":532 + /* "sklearn/tree/_tree.pyx":533 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -4440,7 +4342,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":533 + /* "sklearn/tree/_tree.pyx":534 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -4449,7 +4351,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":535 + /* "sklearn/tree/_tree.pyx":536 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -4459,7 +4361,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":536 + /* "sklearn/tree/_tree.pyx":537 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -4471,7 +4373,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":538 + /* "sklearn/tree/_tree.pyx":539 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4481,7 +4383,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":539 + /* "sklearn/tree/_tree.pyx":540 * * for k from 0 <= k < n_outputs: * y_idx = y[k * y_stride + j] # <<<<<<<<<<<<<< @@ -4490,7 +4392,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_k * __pyx_v_y_stride) + __pyx_v_j)]); - /* "sklearn/tree/_tree.pyx":540 + /* "sklearn/tree/_tree.pyx":541 * for k from 0 <= k < n_outputs: * y_idx = y[k * y_stride + j] * sq_sum_left[k] += (y_idx * y_idx) # <<<<<<<<<<<<<< @@ -4500,7 +4402,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_left[__pyx_t_4]) = ((__pyx_v_sq_sum_left[__pyx_t_4]) + (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":541 + /* "sklearn/tree/_tree.pyx":542 * y_idx = y[k * y_stride + j] * sq_sum_left[k] += (y_idx * y_idx) * sq_sum_right[k] -= (y_idx * y_idx) # <<<<<<<<<<<<<< @@ -4510,7 +4412,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_right[__pyx_t_4]) = ((__pyx_v_sq_sum_right[__pyx_t_4]) - (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":543 + /* "sklearn/tree/_tree.pyx":544 * sq_sum_right[k] -= (y_idx * y_idx) * * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) # <<<<<<<<<<<<<< @@ -4519,7 +4421,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ (__pyx_v_mean_left[__pyx_v_k]) = (((__pyx_v_n_left * (__pyx_v_mean_left[__pyx_v_k])) + __pyx_v_y_idx) / ((double)(__pyx_v_n_left + 1))); - /* "sklearn/tree/_tree.pyx":544 + /* "sklearn/tree/_tree.pyx":545 * * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) # <<<<<<<<<<<<<< @@ -4529,7 +4431,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p (__pyx_v_mean_right[__pyx_v_k]) = ((((__pyx_v_n_samples - __pyx_v_n_left) * (__pyx_v_mean_right[__pyx_v_k])) - __pyx_v_y_idx) / ((double)((__pyx_v_n_samples - __pyx_v_n_left) - 1))); } - /* "sklearn/tree/_tree.pyx":546 + /* "sklearn/tree/_tree.pyx":547 * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) * * n_left += 1 # <<<<<<<<<<<<<< @@ -4538,7 +4440,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_left = (__pyx_v_n_left + 1); - /* "sklearn/tree/_tree.pyx":547 + /* "sklearn/tree/_tree.pyx":548 * * n_left += 1 * self.n_left = n_left # <<<<<<<<<<<<<< @@ -4547,7 +4449,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_self->n_left = __pyx_v_n_left; - /* "sklearn/tree/_tree.pyx":548 + /* "sklearn/tree/_tree.pyx":549 * n_left += 1 * self.n_left = n_left * n_right -= 1 # <<<<<<<<<<<<<< @@ -4556,7 +4458,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_right = (__pyx_v_n_right - 1); - /* "sklearn/tree/_tree.pyx":549 + /* "sklearn/tree/_tree.pyx":550 * self.n_left = n_left * n_right -= 1 * self.n_right = n_right # <<<<<<<<<<<<<< @@ -4565,7 +4467,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_self->n_right = __pyx_v_n_right; - /* "sklearn/tree/_tree.pyx":551 + /* "sklearn/tree/_tree.pyx":552 * self.n_right = n_right * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4575,7 +4477,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":552 + /* "sklearn/tree/_tree.pyx":553 * * for k from 0 <= k < n_outputs: * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) # <<<<<<<<<<<<<< @@ -4584,7 +4486,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ (__pyx_v_var_left[__pyx_v_k]) = ((__pyx_v_sq_sum_left[__pyx_v_k]) - (__pyx_v_n_left * ((__pyx_v_mean_left[__pyx_v_k]) * (__pyx_v_mean_left[__pyx_v_k])))); - /* "sklearn/tree/_tree.pyx":553 + /* "sklearn/tree/_tree.pyx":554 * for k from 0 <= k < n_outputs: * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< @@ -4596,7 +4498,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":555 + /* "sklearn/tree/_tree.pyx":556 * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) * * return n_left # <<<<<<<<<<<<<< @@ -4612,7 +4514,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p return __pyx_r; } -/* "sklearn/tree/_tree.pyx":557 +/* "sklearn/tree/_tree.pyx":558 * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -4630,7 +4532,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(CYTHON_UN return __pyx_r; } -/* "sklearn/tree/_tree.pyx":560 +/* "sklearn/tree/_tree.pyx":561 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -4668,13 +4570,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4683,7 +4585,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":561 + /* "sklearn/tree/_tree.pyx":562 * * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4692,7 +4594,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":562 + /* "sklearn/tree/_tree.pyx":563 * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -4701,21 +4603,21 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":564 + /* "sklearn/tree/_tree.pyx":565 * cdef double* mean_init = self.mean_init * * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, 1), dtype=DTYPE) # <<<<<<<<<<<<<< * cdef int k * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -4723,29 +4625,29 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; } } @@ -4753,7 +4655,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_v_value = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; - /* "sklearn/tree/_tree.pyx":567 + /* "sklearn/tree/_tree.pyx":568 * cdef int k * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4763,7 +4665,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_t_6 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":568 + /* "sklearn/tree/_tree.pyx":569 * * for k from 0 <= k < n_outputs: * value[k, 0] = (mean_init[k]) # <<<<<<<<<<<<<< @@ -4775,7 +4677,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_value.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_value.diminfo[1].strides) = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_mean_init[__pyx_v_k])); } - /* "sklearn/tree/_tree.pyx":570 + /* "sklearn/tree/_tree.pyx":571 * value[k, 0] = (mean_init[k]) * * return value # <<<<<<<<<<<<<< @@ -4821,7 +4723,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":560 +/* "sklearn/tree/_tree.pyx":561 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -4838,7 +4740,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_valu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4856,7 +4758,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":579 +/* "sklearn/tree/_tree.pyx":580 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -4875,7 +4777,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ int __pyx_t_1; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":580 + /* "sklearn/tree/_tree.pyx":581 * * cdef double eval(self): * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4884,7 +4786,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_var_left = __pyx_v_self->__pyx_base.var_left; - /* "sklearn/tree/_tree.pyx":581 + /* "sklearn/tree/_tree.pyx":582 * cdef double eval(self): * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4893,7 +4795,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_var_right = __pyx_v_self->__pyx_base.var_right; - /* "sklearn/tree/_tree.pyx":583 + /* "sklearn/tree/_tree.pyx":584 * cdef double* var_right = self.var_right * * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4902,7 +4804,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":586 + /* "sklearn/tree/_tree.pyx":587 * * cdef int k * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -4911,7 +4813,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":588 + /* "sklearn/tree/_tree.pyx":589 * cdef double total = 0.0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4921,7 +4823,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":589 + /* "sklearn/tree/_tree.pyx":590 * * for k from 0 <= k < n_outputs: * total += var_left[k] # <<<<<<<<<<<<<< @@ -4930,7 +4832,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_total = (__pyx_v_total + (__pyx_v_var_left[__pyx_v_k])); - /* "sklearn/tree/_tree.pyx":590 + /* "sklearn/tree/_tree.pyx":591 * for k from 0 <= k < n_outputs: * total += var_left[k] * total += var_right[k] # <<<<<<<<<<<<<< @@ -4940,7 +4842,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ __pyx_v_total = (__pyx_v_total + (__pyx_v_var_right[__pyx_v_k])); } - /* "sklearn/tree/_tree.pyx":592 + /* "sklearn/tree/_tree.pyx":593 * total += var_right[k] * * return total / n_outputs # <<<<<<<<<<<<<< @@ -4991,17 +4893,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_total_in_bag); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -5010,13 +4912,13 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } - __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_random_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._random_sample_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5027,7 +4929,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":601 +/* "sklearn/tree/_tree.pyx":602 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< @@ -5071,33 +4973,33 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_pybuffernd_sample_mask.data = NULL; __pyx_pybuffernd_sample_mask.rcbuffer = &__pyx_pybuffer_sample_mask; - /* "sklearn/tree/_tree.pyx":620 + /* "sklearn/tree/_tree.pyx":621 * """ * cdef np.ndarray[np.float64_t, ndim=1, mode="c"] rand = \ * random_state.rand(n_total_samples) # <<<<<<<<<<<<<< * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rand.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_rand = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_rand.diminfo[0].strides = __pyx_pybuffernd_rand.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rand.diminfo[0].shape = __pyx_pybuffernd_rand.rcbuffer->pybuffer.shape[0]; } } @@ -5105,51 +5007,51 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_rand = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":622 + /* "sklearn/tree/_tree.pyx":623 * random_state.rand(n_total_samples) * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) # <<<<<<<<<<<<<< * * cdef int n_bagged = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__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 = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_sample_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_sample_mask.diminfo[0].strides = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_mask.diminfo[0].shape = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.shape[0]; } } @@ -5157,7 +5059,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_sample_mask = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":624 + /* "sklearn/tree/_tree.pyx":625 * np.zeros((n_total_samples,), dtype=np.int8) * * cdef int n_bagged = 0 # <<<<<<<<<<<<<< @@ -5166,7 +5068,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_n_bagged = 0; - /* "sklearn/tree/_tree.pyx":625 + /* "sklearn/tree/_tree.pyx":626 * * cdef int n_bagged = 0 * cdef int i = 0 # <<<<<<<<<<<<<< @@ -5175,7 +5077,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":626 + /* "sklearn/tree/_tree.pyx":627 * cdef int n_bagged = 0 * cdef int i = 0 * for i in range(n_total_samples): # <<<<<<<<<<<<<< @@ -5186,7 +5088,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9; - /* "sklearn/tree/_tree.pyx":627 + /* "sklearn/tree/_tree.pyx":628 * cdef int i = 0 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): # <<<<<<<<<<<<<< @@ -5197,7 +5099,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_t_11 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_rand.diminfo[0].strides)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); if (__pyx_t_11) { - /* "sklearn/tree/_tree.pyx":628 + /* "sklearn/tree/_tree.pyx":629 * for i in range(n_total_samples): * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 # <<<<<<<<<<<<<< @@ -5207,7 +5109,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_t_12 = __pyx_v_i; *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_sample_mask.diminfo[0].strides) = 1; - /* "sklearn/tree/_tree.pyx":629 + /* "sklearn/tree/_tree.pyx":630 * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 * n_bagged += 1 # <<<<<<<<<<<<<< @@ -5220,7 +5122,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_L5:; } - /* "sklearn/tree/_tree.pyx":631 + /* "sklearn/tree/_tree.pyx":632 * n_bagged += 1 * * return sample_mask.astype(np.bool) # <<<<<<<<<<<<<< @@ -5228,19 +5130,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -5314,29 +5216,29 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__out); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -5355,17 +5257,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._apply_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_out); goto __pyx_L0; __pyx_L1_error:; @@ -5375,7 +5277,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel return __pyx_r; } -/* "sklearn/tree/_tree.pyx":634 +/* "sklearn/tree/_tree.pyx":635 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5443,31 +5345,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out; { __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 = 634; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; - /* "sklearn/tree/_tree.pyx":641 + /* "sklearn/tree/_tree.pyx":642 * """Finds the terminal region (=leaf node) for each sample in * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 # <<<<<<<<<<<<<< @@ -5476,7 +5378,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":642 + /* "sklearn/tree/_tree.pyx":643 * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< @@ -5485,7 +5387,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":643 + /* "sklearn/tree/_tree.pyx":644 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< @@ -5494,7 +5396,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":644 + /* "sklearn/tree/_tree.pyx":645 * cdef int n = X.shape[0] * cdef int node_id = 0 * for i in xrange(n): # <<<<<<<<<<<<<< @@ -5505,7 +5407,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "sklearn/tree/_tree.pyx":645 + /* "sklearn/tree/_tree.pyx":646 * cdef int node_id = 0 * for i in xrange(n): * node_id = 0 # <<<<<<<<<<<<<< @@ -5514,7 +5416,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":647 + /* "sklearn/tree/_tree.pyx":648 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5535,7 +5437,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj } if (!__pyx_t_9) break; - /* "sklearn/tree/_tree.pyx":648 + /* "sklearn/tree/_tree.pyx":649 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -5549,7 +5451,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); if (__pyx_t_9) { - /* "sklearn/tree/_tree.pyx":649 + /* "sklearn/tree/_tree.pyx":650 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -5563,7 +5465,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj } /*else*/ { - /* "sklearn/tree/_tree.pyx":651 + /* "sklearn/tree/_tree.pyx":652 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< @@ -5577,7 +5479,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":652 + /* "sklearn/tree/_tree.pyx":653 * else: * node_id = children[node_id, 1] * out[i] = node_id # <<<<<<<<<<<<<< @@ -5655,35 +5557,35 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__values); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -5704,18 +5606,18 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._predict_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_values, __pyx_v_pred); goto __pyx_L0; __pyx_L1_error:; @@ -5725,7 +5627,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s return __pyx_r; } -/* "sklearn/tree/_tree.pyx":655 +/* "sklearn/tree/_tree.pyx":656 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5735,12 +5637,12 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_X, PyArrayObject *__pyx_v_children, PyArrayObject *__pyx_v_feature, PyArrayObject *__pyx_v_threshold, PyArrayObject *__pyx_v_values, PyArrayObject *__pyx_v_pred) { int __pyx_v_i; + int __pyx_v_k; + int __pyx_v_c; int __pyx_v_n; int __pyx_v_node_id; int __pyx_v_n_outputs; int __pyx_v_n_classes; - int __pyx_v_k; - int __pyx_v_c; __Pyx_LocalBuf_ND __pyx_pybuffernd_X; __Pyx_Buffer __pyx_pybuffer_X; __Pyx_LocalBuf_ND __pyx_pybuffernd_children; @@ -5757,21 +5659,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - int __pyx_t_3; - long __pyx_t_4; + long __pyx_t_3; + int __pyx_t_4; int __pyx_t_5; - int __pyx_t_6; - long __pyx_t_7; + long __pyx_t_6; + int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; - int __pyx_t_11; - __pyx_t_5numpy_int32_t __pyx_t_12; + __pyx_t_5numpy_int32_t __pyx_t_11; + int __pyx_t_12; int __pyx_t_13; - int __pyx_t_14; - long __pyx_t_15; - int __pyx_t_16; - long __pyx_t_17; + long __pyx_t_14; + int __pyx_t_15; + long __pyx_t_16; + int __pyx_t_17; int __pyx_t_18; int __pyx_t_19; int __pyx_t_20; @@ -5779,9 +5681,6 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO int __pyx_t_22; int __pyx_t_23; int __pyx_t_24; - int __pyx_t_25; - int __pyx_t_26; - int __pyx_t_27; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5812,55 +5711,46 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_pybuffernd_pred.rcbuffer = &__pyx_pybuffer_pred; { __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 = 655; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_values.diminfo[2].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_values.diminfo[2].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[2]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_pred.diminfo[0].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred.diminfo[0].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred.diminfo[1].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred.diminfo[1].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_pred.diminfo[2].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_pred.diminfo[2].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[2]; - /* "sklearn/tree/_tree.pyx":662 - * np.ndarray[np.float64_t, ndim=3] pred): - * """Finds the terminal region (=leaf node) values for each sample. """ - * cdef int i = 0 # <<<<<<<<<<<<<< - * cdef int n = X.shape[0] - * cdef int node_id = 0 - */ - __pyx_v_i = 0; - - /* "sklearn/tree/_tree.pyx":663 + /* "sklearn/tree/_tree.pyx":664 * """Finds the terminal region (=leaf node) values for each sample. """ - * cdef int i = 0 + * cdef int i, k, c * cdef int n = X.shape[0] # <<<<<<<<<<<<<< * cdef int node_id = 0 * cdef int n_outputs = values.shape[1] */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":664 - * cdef int i = 0 + /* "sklearn/tree/_tree.pyx":665 + * cdef int i, k, c * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< * cdef int n_outputs = values.shape[1] @@ -5868,7 +5758,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":665 + /* "sklearn/tree/_tree.pyx":666 * cdef int n = X.shape[0] * cdef int node_id = 0 * cdef int n_outputs = values.shape[1] # <<<<<<<<<<<<<< @@ -5877,36 +5767,35 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_n_outputs = (__pyx_v_values->dimensions[1]); - /* "sklearn/tree/_tree.pyx":666 + /* "sklearn/tree/_tree.pyx":667 * cdef int node_id = 0 * cdef int n_outputs = values.shape[1] * cdef int n_classes = values.shape[2] # <<<<<<<<<<<<<< * - * for i in xrange(n): + * for i from 0 <= i < n: */ __pyx_v_n_classes = (__pyx_v_values->dimensions[2]); - /* "sklearn/tree/_tree.pyx":668 + /* "sklearn/tree/_tree.pyx":669 * cdef int n_classes = values.shape[2] * - * for i in xrange(n): # <<<<<<<<<<<<<< + * for i from 0 <= i < n: # <<<<<<<<<<<<<< * node_id = 0 * # While node_id not a leaf */ __pyx_t_1 = __pyx_v_n; - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_i = __pyx_t_2; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - /* "sklearn/tree/_tree.pyx":669 + /* "sklearn/tree/_tree.pyx":670 * - * for i in xrange(n): + * for i from 0 <= i < n: * node_id = 0 # <<<<<<<<<<<<<< * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":671 + /* "sklearn/tree/_tree.pyx":672 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5914,97 +5803,95 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO * node_id = children[node_id, 0] */ while (1) { - __pyx_t_3 = __pyx_v_node_id; - __pyx_t_4 = 0; - __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); - if (__pyx_t_5) { - __pyx_t_6 = __pyx_v_node_id; - __pyx_t_7 = 1; - __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); - __pyx_t_9 = __pyx_t_8; + __pyx_t_2 = __pyx_v_node_id; + __pyx_t_3 = 0; + __pyx_t_4 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + if (__pyx_t_4) { + __pyx_t_5 = __pyx_v_node_id; + __pyx_t_6 = 1; + __pyx_t_7 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_8 = __pyx_t_7; } else { - __pyx_t_9 = __pyx_t_5; + __pyx_t_8 = __pyx_t_4; } - if (!__pyx_t_9) break; + if (!__pyx_t_8) break; - /* "sklearn/tree/_tree.pyx":672 + /* "sklearn/tree/_tree.pyx":673 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< * node_id = children[node_id, 0] * else: */ - __pyx_t_10 = __pyx_v_node_id; - __pyx_t_11 = __pyx_v_i; - __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_feature.diminfo[0].strides)); - __pyx_t_13 = __pyx_v_node_id; - __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); - if (__pyx_t_9) { + __pyx_t_9 = __pyx_v_node_id; + __pyx_t_10 = __pyx_v_i; + __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_feature.diminfo[0].strides)); + __pyx_t_12 = __pyx_v_node_id; + __pyx_t_8 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_threshold.diminfo[0].strides))); + if (__pyx_t_8) { - /* "sklearn/tree/_tree.pyx":673 + /* "sklearn/tree/_tree.pyx":674 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< * else: * node_id = children[node_id, 1] */ - __pyx_t_14 = __pyx_v_node_id; - __pyx_t_15 = 0; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_t_13 = __pyx_v_node_id; + __pyx_t_14 = 0; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_children.diminfo[1].strides)); goto __pyx_L7; } /*else*/ { - /* "sklearn/tree/_tree.pyx":675 + /* "sklearn/tree/_tree.pyx":676 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< * - * for k in xrange(n_outputs): + * for k from 0 <= k < n_outputs: */ - __pyx_t_16 = __pyx_v_node_id; - __pyx_t_17 = 1; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_node_id; + __pyx_t_16 = 1; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_children.diminfo[1].strides)); } __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":677 + /* "sklearn/tree/_tree.pyx":678 * node_id = children[node_id, 1] * - * for k in xrange(n_outputs): # <<<<<<<<<<<<<< - * for c in xrange(n_classes): + * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< + * for c from 0 <= c < n_classes: * pred[i, k, c] = values[node_id, k, c] */ - __pyx_t_18 = __pyx_v_n_outputs; - for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { - __pyx_v_k = __pyx_t_19; + __pyx_t_17 = __pyx_v_n_outputs; + for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_17; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":678 + /* "sklearn/tree/_tree.pyx":679 * - * for k in xrange(n_outputs): - * for c in xrange(n_classes): # <<<<<<<<<<<<<< + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes: # <<<<<<<<<<<<<< * pred[i, k, c] = values[node_id, k, c] * */ - __pyx_t_20 = __pyx_v_n_classes; - for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) { - __pyx_v_c = __pyx_t_21; + __pyx_t_18 = __pyx_v_n_classes; + for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_18; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":679 - * for k in xrange(n_outputs): - * for c in xrange(n_classes): + /* "sklearn/tree/_tree.pyx":680 + * for k from 0 <= k < n_outputs: + * for c from 0 <= c < n_classes: * pred[i, k, c] = values[node_id, k, c] # <<<<<<<<<<<<<< * * */ - __pyx_t_22 = __pyx_v_node_id; + __pyx_t_19 = __pyx_v_node_id; + __pyx_t_20 = __pyx_v_k; + __pyx_t_21 = __pyx_v_c; + __pyx_t_22 = __pyx_v_i; __pyx_t_23 = __pyx_v_k; __pyx_t_24 = __pyx_v_c; - __pyx_t_25 = __pyx_v_i; - __pyx_t_26 = __pyx_v_k; - __pyx_t_27 = __pyx_v_c; - *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_pred.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_pred.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_pred.diminfo[1].strides, __pyx_t_27, __pyx_pybuffernd_pred.diminfo[2].strides) = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_values.diminfo[1].strides, __pyx_t_24, __pyx_pybuffernd_values.diminfo[2].strides)); + *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_pred.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_pred.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_pred.diminfo[1].strides, __pyx_t_24, __pyx_pybuffernd_pred.diminfo[2].strides) = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_values.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_values.diminfo[0].strides, __pyx_t_20, __pyx_pybuffernd_values.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_values.diminfo[2].strides)); } } } @@ -6074,23 +5961,23 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6103,19 +5990,19 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ __pyx_v_y = ((PyArrayObject *)values[0]); __pyx_v_sample_mask = ((PyArrayObject *)values[1]); __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[2]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._error_at_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(__pyx_self, __pyx_v_y, __pyx_v_sample_mask, __pyx_v_criterion, __pyx_v_n_samples); goto __pyx_L0; __pyx_L1_error:; @@ -6125,7 +6012,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":682 +/* "sklearn/tree/_tree.pyx":683 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< @@ -6153,11 +6040,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":688 + /* "sklearn/tree/_tree.pyx":689 * """Compute criterion error at leaf with terminal region defined * by `sample_mask`. """ * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -6166,7 +6053,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":689 + /* "sklearn/tree/_tree.pyx":690 * by `sample_mask`. """ * cdef DTYPE_t* y_ptr = y.data * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -6175,7 +6062,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":690 + /* "sklearn/tree/_tree.pyx":691 * cdef DTYPE_t* y_ptr = y.data * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int n_total_samples = y.shape[0] # <<<<<<<<<<<<<< @@ -6184,7 +6071,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_n_total_samples = (__pyx_v_y->dimensions[0]); - /* "sklearn/tree/_tree.pyx":691 + /* "sklearn/tree/_tree.pyx":692 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int n_total_samples = y.shape[0] * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -6193,7 +6080,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":693 + /* "sklearn/tree/_tree.pyx":694 * cdef BOOL_t *sample_mask_ptr = sample_mask.data * * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -6202,7 +6089,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":695 + /* "sklearn/tree/_tree.pyx":696 * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * * return criterion.eval() # <<<<<<<<<<<<<< @@ -6210,7 +6097,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6235,7 +6122,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":698 +/* "sklearn/tree/_tree.pyx":699 * * * cdef int smallest_sample_larger_than(int sample_idx, DTYPE_t *X_i, # <<<<<<<<<<<<<< @@ -6253,7 +6140,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v int __pyx_t_2; __Pyx_RefNannySetupContext("smallest_sample_larger_than", 0); - /* "sklearn/tree/_tree.pyx":715 + /* "sklearn/tree/_tree.pyx":716 * -1 if no such element exists. * """ * cdef int idx = 0, j # <<<<<<<<<<<<<< @@ -6262,7 +6149,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_idx = 0; - /* "sklearn/tree/_tree.pyx":716 + /* "sklearn/tree/_tree.pyx":717 * """ * cdef int idx = 0, j * cdef DTYPE_t threshold = -DBL_MAX # <<<<<<<<<<<<<< @@ -6271,7 +6158,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_threshold = (-DBL_MAX); - /* "sklearn/tree/_tree.pyx":718 + /* "sklearn/tree/_tree.pyx":719 * cdef DTYPE_t threshold = -DBL_MAX * * if sample_idx > -1: # <<<<<<<<<<<<<< @@ -6281,7 +6168,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = (__pyx_v_sample_idx > -1); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":719 + /* "sklearn/tree/_tree.pyx":720 * * if sample_idx > -1: * threshold = X_i[X_argsorted_i[sample_idx]] # <<<<<<<<<<<<<< @@ -6293,7 +6180,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":721 + /* "sklearn/tree/_tree.pyx":722 * threshold = X_i[X_argsorted_i[sample_idx]] * * for idx from sample_idx < idx < n_total_samples: # <<<<<<<<<<<<<< @@ -6303,7 +6190,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_2 = __pyx_v_n_total_samples; for (__pyx_v_idx = __pyx_v_sample_idx+1; __pyx_v_idx < __pyx_t_2; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":722 + /* "sklearn/tree/_tree.pyx":723 * * for idx from sample_idx < idx < n_total_samples: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -6312,7 +6199,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":724 + /* "sklearn/tree/_tree.pyx":725 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -6322,7 +6209,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":725 + /* "sklearn/tree/_tree.pyx":726 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -6334,7 +6221,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L6:; - /* "sklearn/tree/_tree.pyx":727 + /* "sklearn/tree/_tree.pyx":728 * continue * * if X_i[j] > threshold + 1.e-7: # <<<<<<<<<<<<<< @@ -6344,7 +6231,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_X_i[__pyx_v_j]) > (__pyx_v_threshold + 1.e-7)); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":728 + /* "sklearn/tree/_tree.pyx":729 * * if X_i[j] > threshold + 1.e-7: * return idx # <<<<<<<<<<<<<< @@ -6359,7 +6246,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_L4_continue:; } - /* "sklearn/tree/_tree.pyx":730 + /* "sklearn/tree/_tree.pyx":731 * return idx * * return -1 # <<<<<<<<<<<<<< @@ -6422,53 +6309,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -6487,25 +6374,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -6515,7 +6402,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":733 +/* "sklearn/tree/_tree.pyx":734 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< @@ -6596,21 +6483,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":792 + /* "sklearn/tree/_tree.pyx":793 * """ * # Variables declarations * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -6619,7 +6506,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":793 + /* "sklearn/tree/_tree.pyx":794 * # Variables declarations * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -6628,7 +6515,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":794 + /* "sklearn/tree/_tree.pyx":795 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 # <<<<<<<<<<<<<< @@ -6637,7 +6524,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":795 + /* "sklearn/tree/_tree.pyx":796 * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -6646,7 +6533,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":796 + /* "sklearn/tree/_tree.pyx":797 * cdef int i, a, b, best_i = -1 * cdef np.int32_t feature_idx = -1 * cdef int n_left = 0 # <<<<<<<<<<<<<< @@ -6655,31 +6542,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = 0; - /* "sklearn/tree/_tree.pyx":798 + /* "sklearn/tree/_tree.pyx":799 * cdef int n_left = 0 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":799 + /* "sklearn/tree/_tree.pyx":800 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< @@ -6688,7 +6575,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":800 + /* "sklearn/tree/_tree.pyx":801 * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< @@ -6697,7 +6584,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":801 + /* "sklearn/tree/_tree.pyx":802 * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -6706,7 +6593,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":802 + /* "sklearn/tree/_tree.pyx":803 * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -6715,7 +6602,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":803 + /* "sklearn/tree/_tree.pyx":804 * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< @@ -6727,7 +6614,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } @@ -6735,7 +6622,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":807 + /* "sklearn/tree/_tree.pyx":808 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -6744,7 +6631,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":808 + /* "sklearn/tree/_tree.pyx":809 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -6753,7 +6640,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":809 + /* "sklearn/tree/_tree.pyx":810 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -6762,7 +6649,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":810 + /* "sklearn/tree/_tree.pyx":811 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -6771,7 +6658,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":811 + /* "sklearn/tree/_tree.pyx":812 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -6780,7 +6667,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":812 + /* "sklearn/tree/_tree.pyx":813 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -6789,7 +6676,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":813 + /* "sklearn/tree/_tree.pyx":814 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -6798,7 +6685,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":816 + /* "sklearn/tree/_tree.pyx":817 * * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -6807,7 +6694,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":817 + /* "sklearn/tree/_tree.pyx":818 * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -6816,7 +6703,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":818 + /* "sklearn/tree/_tree.pyx":819 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -6825,7 +6712,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":820 + /* "sklearn/tree/_tree.pyx":821 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -6835,7 +6722,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":821 + /* "sklearn/tree/_tree.pyx":822 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, initial_error, initial_error # <<<<<<<<<<<<<< @@ -6843,15 +6730,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -6872,7 +6759,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":823 + /* "sklearn/tree/_tree.pyx":824 * return best_i, best_t, initial_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -6881,40 +6768,40 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":826 + /* "sklearn/tree/_tree.pyx":827 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -6930,14 +6817,14 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":827 + /* "sklearn/tree/_tree.pyx":828 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< @@ -6953,7 +6840,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":828 + /* "sklearn/tree/_tree.pyx":829 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -6965,28 +6852,28 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } /*else*/ { - /* "sklearn/tree/_tree.pyx":830 + /* "sklearn/tree/_tree.pyx":831 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_v_features)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7002,7 +6889,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); @@ -7011,7 +6898,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":833 + /* "sklearn/tree/_tree.pyx":834 * * # Look for the best split * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< @@ -7021,7 +6908,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_9 = __pyx_v_max_features; for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":834 + /* "sklearn/tree/_tree.pyx":835 * # Look for the best split * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< @@ -7031,7 +6918,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_15 = __pyx_v_feature_idx; __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":836 + /* "sklearn/tree/_tree.pyx":837 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -7040,7 +6927,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":837 + /* "sklearn/tree/_tree.pyx":838 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -7049,7 +6936,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":840 + /* "sklearn/tree/_tree.pyx":841 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -7058,7 +6945,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":843 + /* "sklearn/tree/_tree.pyx":844 * * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 # <<<<<<<<<<<<<< @@ -7067,7 +6954,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":844 + /* "sklearn/tree/_tree.pyx":845 * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -7078,7 +6965,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":845 + /* "sklearn/tree/_tree.pyx":846 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -7088,7 +6975,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":848 + /* "sklearn/tree/_tree.pyx":849 * * # Consider splits between two consecutive samples * while True: # <<<<<<<<<<<<<< @@ -7098,7 +6985,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":851 + /* "sklearn/tree/_tree.pyx":852 * # Find the following larger sample * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) # <<<<<<<<<<<<<< @@ -7107,7 +6994,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_b = __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(__pyx_v_a, __pyx_v_X_i, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":852 + /* "sklearn/tree/_tree.pyx":853 * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) * if b == -1: # <<<<<<<<<<<<<< @@ -7117,7 +7004,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_14 = (__pyx_v_b == -1); if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":853 + /* "sklearn/tree/_tree.pyx":854 * sample_mask_ptr, n_total_samples) * if b == -1: * break # <<<<<<<<<<<<<< @@ -7129,7 +7016,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":856 + /* "sklearn/tree/_tree.pyx":857 * * # Better split than the best so far? * n_left = criterion.update(a, b, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -7138,7 +7025,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":859 + /* "sklearn/tree/_tree.pyx":860 * * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -7154,7 +7041,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":860 + /* "sklearn/tree/_tree.pyx":861 * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b # <<<<<<<<<<<<<< @@ -7163,7 +7050,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = __pyx_v_b; - /* "sklearn/tree/_tree.pyx":861 + /* "sklearn/tree/_tree.pyx":862 * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b * continue # <<<<<<<<<<<<<< @@ -7175,7 +7062,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":863 + /* "sklearn/tree/_tree.pyx":864 * continue * * error = criterion.eval() # <<<<<<<<<<<<<< @@ -7184,7 +7071,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":865 + /* "sklearn/tree/_tree.pyx":866 * error = criterion.eval() * * if error < best_error: # <<<<<<<<<<<<<< @@ -7194,7 +7081,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_13 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":867 + /* "sklearn/tree/_tree.pyx":868 * if error < best_error: * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) # <<<<<<<<<<<<<< @@ -7203,7 +7090,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_t = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) + (((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])) / 2.0)); - /* "sklearn/tree/_tree.pyx":868 + /* "sklearn/tree/_tree.pyx":869 * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -7213,7 +7100,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":869 + /* "sklearn/tree/_tree.pyx":870 * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -7225,7 +7112,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L14:; - /* "sklearn/tree/_tree.pyx":870 + /* "sklearn/tree/_tree.pyx":871 * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] * best_i = i # <<<<<<<<<<<<<< @@ -7234,7 +7121,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":871 + /* "sklearn/tree/_tree.pyx":872 * t = X_i[X_argsorted_i[a]] * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -7243,7 +7130,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":872 + /* "sklearn/tree/_tree.pyx":873 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -7255,7 +7142,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L13:; - /* "sklearn/tree/_tree.pyx":875 + /* "sklearn/tree/_tree.pyx":876 * * # Proceed to the next interval * a = b # <<<<<<<<<<<<<< @@ -7268,7 +7155,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_L10_break:; } - /* "sklearn/tree/_tree.pyx":877 + /* "sklearn/tree/_tree.pyx":878 * a = b * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -7276,15 +7163,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); @@ -7379,53 +7266,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -7444,25 +7331,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_random_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -7472,7 +7359,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje return __pyx_r; } -/* "sklearn/tree/_tree.pyx":879 +/* "sklearn/tree/_tree.pyx":880 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< @@ -7554,21 +7441,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":938 + /* "sklearn/tree/_tree.pyx":939 * """ * # Variables * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -7577,7 +7464,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":939 + /* "sklearn/tree/_tree.pyx":940 * # Variables * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -7586,7 +7473,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":940 + /* "sklearn/tree/_tree.pyx":941 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 # <<<<<<<<<<<<<< @@ -7595,7 +7482,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":941 + /* "sklearn/tree/_tree.pyx":942 * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -7604,31 +7491,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":943 + /* "sklearn/tree/_tree.pyx":944 * cdef np.int32_t feature_idx = -1 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_best_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":944 + /* "sklearn/tree/_tree.pyx":945 * cdef DTYPE_t t, initial_error, error * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< @@ -7637,7 +7524,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":945 + /* "sklearn/tree/_tree.pyx":946 * cdef DTYPE_t best_error = np.inf, best_t = np.inf * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< @@ -7646,7 +7533,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":946 + /* "sklearn/tree/_tree.pyx":947 * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -7655,7 +7542,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":947 + /* "sklearn/tree/_tree.pyx":948 * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -7664,7 +7551,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":948 + /* "sklearn/tree/_tree.pyx":949 * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< @@ -7676,7 +7563,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } @@ -7684,7 +7571,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":952 + /* "sklearn/tree/_tree.pyx":953 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -7693,7 +7580,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":953 + /* "sklearn/tree/_tree.pyx":954 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -7702,7 +7589,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":954 + /* "sklearn/tree/_tree.pyx":955 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -7711,7 +7598,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":955 + /* "sklearn/tree/_tree.pyx":956 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -7720,7 +7607,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":956 + /* "sklearn/tree/_tree.pyx":957 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -7729,7 +7616,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":957 + /* "sklearn/tree/_tree.pyx":958 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -7738,7 +7625,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":958 + /* "sklearn/tree/_tree.pyx":959 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -7747,7 +7634,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":961 + /* "sklearn/tree/_tree.pyx":962 * * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -7756,7 +7643,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":962 + /* "sklearn/tree/_tree.pyx":963 * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -7765,7 +7652,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":963 + /* "sklearn/tree/_tree.pyx":964 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -7774,7 +7661,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":965 + /* "sklearn/tree/_tree.pyx":966 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< @@ -7784,7 +7671,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_5 = (__pyx_v_initial_error == 0.0); if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":966 + /* "sklearn/tree/_tree.pyx":967 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -7792,15 +7679,15 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -7821,7 +7708,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":968 + /* "sklearn/tree/_tree.pyx":969 * return best_i, best_t, best_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -7830,40 +7717,40 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":971 + /* "sklearn/tree/_tree.pyx":972 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7879,14 +7766,14 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":972 + /* "sklearn/tree/_tree.pyx":973 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< @@ -7902,7 +7789,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":973 + /* "sklearn/tree/_tree.pyx":974 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -7914,28 +7801,28 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } /*else*/ { - /* "sklearn/tree/_tree.pyx":975 + /* "sklearn/tree/_tree.pyx":976 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best random split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_v_features)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -7951,7 +7838,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); @@ -7960,7 +7847,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":978 + /* "sklearn/tree/_tree.pyx":979 * * # Look for the best random split * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< @@ -7970,7 +7857,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_9 = __pyx_v_max_features; for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":979 + /* "sklearn/tree/_tree.pyx":980 * # Look for the best random split * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< @@ -7980,7 +7867,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_15 = __pyx_v_feature_idx; __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":981 + /* "sklearn/tree/_tree.pyx":982 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -7989,7 +7876,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":982 + /* "sklearn/tree/_tree.pyx":983 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -7998,7 +7885,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":985 + /* "sklearn/tree/_tree.pyx":986 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -8007,7 +7894,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":988 + /* "sklearn/tree/_tree.pyx":989 * * # Find min and max * a = 0 # <<<<<<<<<<<<<< @@ -8016,7 +7903,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":989 + /* "sklearn/tree/_tree.pyx":990 * # Find min and max * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -8027,7 +7914,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":990 + /* "sklearn/tree/_tree.pyx":991 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -8037,7 +7924,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":992 + /* "sklearn/tree/_tree.pyx":993 * a = a + 1 * * b = n_total_samples - 1 # <<<<<<<<<<<<<< @@ -8046,7 +7933,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_b = (__pyx_v_n_total_samples - 1); - /* "sklearn/tree/_tree.pyx":993 + /* "sklearn/tree/_tree.pyx":994 * * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: # <<<<<<<<<<<<<< @@ -8057,7 +7944,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_b])]) == 0); if (!__pyx_t_14) break; - /* "sklearn/tree/_tree.pyx":994 + /* "sklearn/tree/_tree.pyx":995 * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: * b = b - 1 # <<<<<<<<<<<<<< @@ -8067,7 +7954,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_b = (__pyx_v_b - 1); } - /* "sklearn/tree/_tree.pyx":996 + /* "sklearn/tree/_tree.pyx":997 * b = b - 1 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -8083,7 +7970,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":997 + /* "sklearn/tree/_tree.pyx":998 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: * continue # <<<<<<<<<<<<<< @@ -8095,43 +7982,43 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":1000 + /* "sklearn/tree/_tree.pyx":1001 * * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * # <<<<<<<<<<<<<< * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: */ - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":1001 + /* "sklearn/tree/_tree.pyx":1002 * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) # <<<<<<<<<<<<<< * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] */ - __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_t = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":1002 + /* "sklearn/tree/_tree.pyx":1003 * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< @@ -8141,7 +8028,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":1003 + /* "sklearn/tree/_tree.pyx":1004 * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -8153,7 +8040,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":1006 + /* "sklearn/tree/_tree.pyx":1007 * * # Find the sample just greater than t * c = a + 1 # <<<<<<<<<<<<<< @@ -8162,7 +8049,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_c = (__pyx_v_a + 1); - /* "sklearn/tree/_tree.pyx":1008 + /* "sklearn/tree/_tree.pyx":1009 * c = a + 1 * * while True: # <<<<<<<<<<<<<< @@ -8172,7 +8059,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":1009 + /* "sklearn/tree/_tree.pyx":1010 * * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: # <<<<<<<<<<<<<< @@ -8182,7 +8069,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_c])]) != 0); if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":1010 + /* "sklearn/tree/_tree.pyx":1011 * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: # <<<<<<<<<<<<<< @@ -8198,7 +8085,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_5) { - /* "sklearn/tree/_tree.pyx":1011 + /* "sklearn/tree/_tree.pyx":1012 * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: * break # <<<<<<<<<<<<<< @@ -8213,7 +8100,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L15:; - /* "sklearn/tree/_tree.pyx":1013 + /* "sklearn/tree/_tree.pyx":1014 * break * * c += 1 # <<<<<<<<<<<<<< @@ -8224,7 +8111,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L14_break:; - /* "sklearn/tree/_tree.pyx":1016 + /* "sklearn/tree/_tree.pyx":1017 * * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -8233,7 +8120,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, 0, __pyx_v_c, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":1017 + /* "sklearn/tree/_tree.pyx":1018 * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) * error = criterion.eval() # <<<<<<<<<<<<<< @@ -8242,7 +8129,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":1019 + /* "sklearn/tree/_tree.pyx":1020 * error = criterion.eval() * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< @@ -8258,7 +8145,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":1020 + /* "sklearn/tree/_tree.pyx":1021 * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * continue # <<<<<<<<<<<<<< @@ -8270,7 +8157,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L17:; - /* "sklearn/tree/_tree.pyx":1022 + /* "sklearn/tree/_tree.pyx":1023 * continue * * if error < best_error: # <<<<<<<<<<<<<< @@ -8280,7 +8167,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_t_14 = (__pyx_v_error < __pyx_v_best_error); if (__pyx_t_14) { - /* "sklearn/tree/_tree.pyx":1023 + /* "sklearn/tree/_tree.pyx":1024 * * if error < best_error: * best_i = i # <<<<<<<<<<<<<< @@ -8289,7 +8176,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":1024 + /* "sklearn/tree/_tree.pyx":1025 * if error < best_error: * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -8298,7 +8185,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":1025 + /* "sklearn/tree/_tree.pyx":1026 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -8312,21 +8199,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_L5_continue:; } - /* "sklearn/tree/_tree.pyx":1027 + /* "sklearn/tree/_tree.pyx":1028 * best_error = error * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); @@ -11450,11 +11337,11 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION >= 3 - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -11551,14 +11438,14 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_11)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); - /* "sklearn/tree/_tree.pyx":601 + /* "sklearn/tree/_tree.pyx":602 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_13); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_n_s__n_total_samples)); @@ -11582,16 +11469,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_13, 6, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); - __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 601, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 602, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":634 + /* "sklearn/tree/_tree.pyx":635 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_17); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__X)); @@ -11618,16 +11505,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_17, 7, ((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); - __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 634, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 635, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":655 + /* "sklearn/tree/_tree.pyx":656 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_19 = PyTuple_New(13); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_19 = PyTuple_New(13); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_19); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_n_s__X)); @@ -11650,35 +11537,35 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); PyTuple_SET_ITEM(__pyx_k_tuple_19, 6, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__k)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 7, ((PyObject *)__pyx_n_s__k)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__c)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 8, ((PyObject *)__pyx_n_s__c)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 7, ((PyObject *)__pyx_n_s__n)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 9, ((PyObject *)__pyx_n_s__n)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n)); __Pyx_INCREF(((PyObject *)__pyx_n_s__node_id)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 8, ((PyObject *)__pyx_n_s__node_id)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 10, ((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_outputs)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 9, ((PyObject *)__pyx_n_s__n_outputs)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 11, ((PyObject *)__pyx_n_s__n_outputs)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_outputs)); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_classes)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 10, ((PyObject *)__pyx_n_s__n_classes)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 12, ((PyObject *)__pyx_n_s__n_classes)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_classes)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__k)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 11, ((PyObject *)__pyx_n_s__k)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__c)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 12, ((PyObject *)__pyx_n_s__c)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 655, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 656, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":682 + /* "sklearn/tree/_tree.pyx":683 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< * np.ndarray sample_mask, * Criterion criterion, */ - __pyx_k_tuple_21 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_21 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__y)); @@ -11705,16 +11592,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_21, 7, ((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 682, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 683, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":733 + /* "sklearn/tree/_tree.pyx":734 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_25 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_25 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_25); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__X)); @@ -11819,16 +11706,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_25, 33, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); - __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 733, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 734, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":879 + /* "sklearn/tree/_tree.pyx":880 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_27 = PyTuple_New(35); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_27 = PyTuple_New(35); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_27); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__X)); @@ -11936,7 +11823,7 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_27, 34, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); - __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 879, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 880, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -12045,17 +11932,17 @@ PyMODINIT_FUNC PyInit__tree(void) __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_4Gini_eval; __pyx_type_7sklearn_4tree_5_tree_Gini.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Gini = &__pyx_type_7sklearn_4tree_5_tree_Gini; __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy = &__pyx_vtable_7sklearn_4tree_5_tree_Entropy; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_7Entropy_eval; __pyx_type_7sklearn_4tree_5_tree_Entropy.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Entropy = &__pyx_type_7sklearn_4tree_5_tree_Entropy; __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; @@ -12065,17 +11952,17 @@ PyMODINIT_FUNC PyInit__tree(void) __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_value; __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtabptr_7sklearn_4tree_5_tree_MSE = &__pyx_vtable_7sklearn_4tree_5_tree_MSE; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_3MSE_eval; __pyx_type_7sklearn_4tree_5_tree_MSE.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_MSE = &__pyx_type_7sklearn_4tree_5_tree_MSE; /*--- Type import code ---*/ __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -12114,76 +12001,76 @@ PyMODINIT_FUNC PyInit__tree(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":601 + /* "sklearn/tree/_tree.pyx":602 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":634 + /* "sklearn/tree/_tree.pyx":635 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":655 + /* "sklearn/tree/_tree.pyx":656 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":682 + /* "sklearn/tree/_tree.pyx":683 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< * np.ndarray sample_mask, * Criterion criterion, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":733 + /* "sklearn/tree/_tree.pyx":734 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":879 + /* "sklearn/tree/_tree.pyx":880 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "sklearn/tree/_tree.pyx":1 @@ -13925,25 +13812,6 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -} - static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index 238b140a75357..4920eb4324e05 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -209,8 +209,7 @@ cdef class ClassificationCriterion(Criterion): cdef int n_left = self.n_left cdef int n_right = self.n_right - cdef int k - cdef int c + cdef int idx, k, c, s # post condition: all samples from [0:b) are on the left side for idx from a <= idx < b: @@ -243,6 +242,8 @@ cdef class ClassificationCriterion(Criterion): cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) + cdef int k, c + for k from 0 <= k < n_outputs: for c from 0 <= c < n_classes[k]: value[k, c] = (label_count_init[k * label_count_stride + c]) @@ -659,13 +660,13 @@ def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, np.ndarray[np.float64_t, ndim=3] values, np.ndarray[np.float64_t, ndim=3] pred): """Finds the terminal region (=leaf node) values for each sample. """ - cdef int i = 0 + cdef int i, k, c cdef int n = X.shape[0] cdef int node_id = 0 cdef int n_outputs = values.shape[1] cdef int n_classes = values.shape[2] - for i in xrange(n): + for i from 0 <= i < n: node_id = 0 # While node_id not a leaf while children[node_id, 0] != -1 and children[node_id, 1] != -1: @@ -674,8 +675,8 @@ def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, else: node_id = children[node_id, 1] - for k in xrange(n_outputs): - for c in xrange(n_classes): + for k from 0 <= k < n_outputs: + for c from 0 <= c < n_classes: pred[i, k, c] = values[node_id, k, c] From 18a2e23ba8530d9ab8db7868de51ae07c0854f31 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 2 Jul 2012 16:32:44 +0200 Subject: [PATCH 20/33] ENH: Cython improved code (2) --- sklearn/tree/_tree.c | 2212 ++++++++++++++++++++-------------------- sklearn/tree/_tree.pyx | 10 +- 2 files changed, 1100 insertions(+), 1122 deletions(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index c072421757db4..37756c0d1ad62 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Mon Jul 2 16:09:42 2012 */ +/* Generated by Cython 0.16 on Mon Jul 2 16:31:14 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -689,7 +689,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; */ typedef npy_cdouble __pyx_t_5numpy_complex_t; -/* "sklearn/tree/_tree.pyx":45 +/* "sklearn/tree/_tree.pyx":47 * # be the proportion of class k observations in node m * * cdef class Criterion: # <<<<<<<<<<<<<< @@ -702,7 +702,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Criterion { }; -/* "sklearn/tree/_tree.pyx":79 +/* "sklearn/tree/_tree.pyx":81 * * * cdef class ClassificationCriterion(Criterion): # <<<<<<<<<<<<<< @@ -723,7 +723,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion { }; -/* "sklearn/tree/_tree.pyx":253 +/* "sklearn/tree/_tree.pyx":255 * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -735,7 +735,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Gini { }; -/* "sklearn/tree/_tree.pyx":304 +/* "sklearn/tree/_tree.pyx":306 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -747,7 +747,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_Entropy { }; -/* "sklearn/tree/_tree.pyx":346 +/* "sklearn/tree/_tree.pyx":348 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -771,7 +771,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_RegressionCriterion { }; -/* "sklearn/tree/_tree.pyx":574 +/* "sklearn/tree/_tree.pyx":576 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -784,7 +784,7 @@ struct __pyx_obj_7sklearn_4tree_5_tree_MSE { -/* "sklearn/tree/_tree.pyx":45 +/* "sklearn/tree/_tree.pyx":47 * # be the proportion of class k observations in node m * * cdef class Criterion: # <<<<<<<<<<<<<< @@ -802,7 +802,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; -/* "sklearn/tree/_tree.pyx":346 +/* "sklearn/tree/_tree.pyx":348 * * * cdef class RegressionCriterion(Criterion): # <<<<<<<<<<<<<< @@ -816,7 +816,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; -/* "sklearn/tree/_tree.pyx":574 +/* "sklearn/tree/_tree.pyx":576 * * * cdef class MSE(RegressionCriterion): # <<<<<<<<<<<<<< @@ -830,7 +830,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_MSE *__pyx_vtabptr_7sklearn_4tree_5_tree_MSE; -/* "sklearn/tree/_tree.pyx":79 +/* "sklearn/tree/_tree.pyx":81 * * * cdef class ClassificationCriterion(Criterion): # <<<<<<<<<<<<<< @@ -844,7 +844,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; -/* "sklearn/tree/_tree.pyx":253 +/* "sklearn/tree/_tree.pyx":255 * return value * * cdef class Gini(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -858,7 +858,7 @@ struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini { static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Gini *__pyx_vtabptr_7sklearn_4tree_5_tree_Gini; -/* "sklearn/tree/_tree.pyx":304 +/* "sklearn/tree/_tree.pyx":306 * * * cdef class Entropy(ClassificationCriterion): # <<<<<<<<<<<<<< @@ -924,8 +924,6 @@ static struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Entropy *__pyx_vtabptr_7skl #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, @@ -1009,6 +1007,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); @@ -1256,6 +1256,7 @@ static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Gini = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Entropy = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_MSE = 0; +static __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_7sklearn_4tree_5_tree_inf; static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; @@ -1265,9 +1266,8 @@ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "int32_t", NU int __pyx_module_is_main_sklearn__tree___tree = 0; /* Implementation of 'sklearn.tree._tree' */ -static PyObject *__pyx_builtin_range; -static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_RuntimeError; static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *__pyx_v_self); /* proto */ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(struct __pyx_obj_7sklearn_4tree_5_tree_ClassificationCriterion *__pyx_v_self, int __pyx_v_n_outputs, PyObject *__pyx_v_n_classes); /* proto */ @@ -1341,7 +1341,6 @@ static char __pyx_k__best_i[] = "best_i"; static char __pyx_k__best_t[] = "best_t"; static char __pyx_k__n_left[] = "n_left"; static char __pyx_k__values[] = "values"; -static char __pyx_k__xrange[] = "xrange"; static char __pyx_k__feature[] = "feature"; static char __pyx_k__float32[] = "float32"; static char __pyx_k__node_id[] = "node_id"; @@ -1460,7 +1459,6 @@ static PyObject *__pyx_n_s__sample_mask_ptr; static PyObject *__pyx_n_s__t; static PyObject *__pyx_n_s__threshold; static PyObject *__pyx_n_s__values; -static PyObject *__pyx_n_s__xrange; static PyObject *__pyx_n_s__y; static PyObject *__pyx_n_s__y_ptr; static PyObject *__pyx_n_s__y_stride; @@ -1486,7 +1484,7 @@ static PyObject *__pyx_k_codeobj_22; static PyObject *__pyx_k_codeobj_26; static PyObject *__pyx_k_codeobj_28; -/* "sklearn/tree/_tree.pyx":48 +/* "sklearn/tree/_tree.pyx":50 * """Interface for splitting criteria (regression and classification)""" * * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< @@ -1501,7 +1499,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_init(CYTHON_UNUSED struct _ __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":56 +/* "sklearn/tree/_tree.pyx":58 * pass * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -1516,7 +1514,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_9Criterion_reset(CYTHON_UNUSED struct __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":60 +/* "sklearn/tree/_tree.pyx":62 * pass * * cdef int update(self, int a, # <<<<<<<<<<<<<< @@ -1534,7 +1532,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_9Criterion_update(CYTHON_UNUSED struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":70 +/* "sklearn/tree/_tree.pyx":72 * pass * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -1552,7 +1550,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_9Criterion_eval(CYTHON_UNUSED struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":74 +/* "sklearn/tree/_tree.pyx":76 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -1574,13 +1572,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1589,7 +1587,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value(CYTHON __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":76 + /* "sklearn/tree/_tree.pyx":78 * cpdef np.ndarray init_value(self): * """Get the init value of the criterion - `init` must be called before.""" * pass # <<<<<<<<<<<<<< @@ -1622,7 +1620,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9Criterion_1init_value(PyObject return __pyx_r; } -/* "sklearn/tree/_tree.pyx":74 +/* "sklearn/tree/_tree.pyx":76 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -1639,7 +1637,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_9Criterion_init_value(struct __p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self->__pyx_vtab)->init_value(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self->__pyx_vtab)->init_value(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1687,11 +1685,11 @@ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(Py values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_classes); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1699,12 +1697,12 @@ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(Py values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_n_classes = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree.ClassificationCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -1715,7 +1713,7 @@ static int __pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_1__init__(Py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":118 +/* "sklearn/tree/_tree.pyx":120 * cdef int n_right * * def __init__(self, int n_outputs, object n_classes): # <<<<<<<<<<<<<< @@ -1739,7 +1737,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "sklearn/tree/_tree.pyx":119 + /* "sklearn/tree/_tree.pyx":121 * * def __init__(self, int n_outputs, object n_classes): * cdef int k = 0 # <<<<<<<<<<<<<< @@ -1748,7 +1746,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":121 + /* "sklearn/tree/_tree.pyx":123 * cdef int k = 0 * * self.n_outputs = n_outputs # <<<<<<<<<<<<<< @@ -1757,7 +1755,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->n_outputs = __pyx_v_n_outputs; - /* "sklearn/tree/_tree.pyx":122 + /* "sklearn/tree/_tree.pyx":124 * * self.n_outputs = n_outputs * self.n_classes = calloc(n_outputs, sizeof(int)) # <<<<<<<<<<<<<< @@ -1766,7 +1764,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->n_classes = ((int *)calloc(__pyx_v_n_outputs, (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":123 + /* "sklearn/tree/_tree.pyx":125 * self.n_outputs = n_outputs * self.n_classes = calloc(n_outputs, sizeof(int)) * cdef int label_count_stride = -1 # <<<<<<<<<<<<<< @@ -1775,7 +1773,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_label_count_stride = -1; - /* "sklearn/tree/_tree.pyx":125 + /* "sklearn/tree/_tree.pyx":127 * cdef int label_count_stride = -1 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -1785,48 +1783,48 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":126 + /* "sklearn/tree/_tree.pyx":128 * * for k from 0 <= k < n_outputs: * self.n_classes[k] = n_classes[k] # <<<<<<<<<<<<<< * * if n_classes[k] > label_count_stride: */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; (__pyx_v_self->n_classes[__pyx_v_k]) = __pyx_t_3; - /* "sklearn/tree/_tree.pyx":128 + /* "sklearn/tree/_tree.pyx":130 * self.n_classes[k] = n_classes[k] * * if n_classes[k] > label_count_stride: # <<<<<<<<<<<<<< * label_count_stride = n_classes[k] * */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { - /* "sklearn/tree/_tree.pyx":129 + /* "sklearn/tree/_tree.pyx":131 * * if n_classes[k] > label_count_stride: * label_count_stride = n_classes[k] # <<<<<<<<<<<<<< * * self.label_count_stride = label_count_stride */ - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_n_classes, __pyx_v_k, sizeof(int), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_label_count_stride = __pyx_t_3; goto __pyx_L5; @@ -1834,7 +1832,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str __pyx_L5:; } - /* "sklearn/tree/_tree.pyx":131 + /* "sklearn/tree/_tree.pyx":133 * label_count_stride = n_classes[k] * * self.label_count_stride = label_count_stride # <<<<<<<<<<<<<< @@ -1843,7 +1841,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->label_count_stride = __pyx_v_label_count_stride; - /* "sklearn/tree/_tree.pyx":132 + /* "sklearn/tree/_tree.pyx":134 * * self.label_count_stride = label_count_stride * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< @@ -1852,7 +1850,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->label_count_left = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":133 + /* "sklearn/tree/_tree.pyx":135 * self.label_count_stride = label_count_stride * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< @@ -1861,7 +1859,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->label_count_right = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":134 + /* "sklearn/tree/_tree.pyx":136 * self.label_count_left = calloc(n_outputs * label_count_stride, sizeof(int)) * self.label_count_right = calloc(n_outputs * label_count_stride, sizeof(int)) * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) # <<<<<<<<<<<<<< @@ -1870,7 +1868,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->label_count_init = ((int *)calloc((__pyx_v_n_outputs * __pyx_v_label_count_stride), (sizeof(int)))); - /* "sklearn/tree/_tree.pyx":136 + /* "sklearn/tree/_tree.pyx":138 * self.label_count_init = calloc(n_outputs * label_count_stride, sizeof(int)) * * self.n_samples = 0 # <<<<<<<<<<<<<< @@ -1879,7 +1877,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->n_samples = 0; - /* "sklearn/tree/_tree.pyx":137 + /* "sklearn/tree/_tree.pyx":139 * * self.n_samples = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -1888,7 +1886,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion___init__(str */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":138 + /* "sklearn/tree/_tree.pyx":140 * self.n_samples = 0 * self.n_left = 0 * self.n_right = 0 # <<<<<<<<<<<<<< @@ -1921,7 +1919,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_3__del return __pyx_r; } -/* "sklearn/tree/_tree.pyx":140 +/* "sklearn/tree/_tree.pyx":142 * self.n_right = 0 * * def __del__(self): # <<<<<<<<<<<<<< @@ -1934,7 +1932,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); - /* "sklearn/tree/_tree.pyx":141 + /* "sklearn/tree/_tree.pyx":143 * * def __del__(self): * free(self.n_classes) # <<<<<<<<<<<<<< @@ -1943,7 +1941,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del */ free(__pyx_v_self->n_classes); - /* "sklearn/tree/_tree.pyx":142 + /* "sklearn/tree/_tree.pyx":144 * def __del__(self): * free(self.n_classes) * free(self.label_count_left) # <<<<<<<<<<<<<< @@ -1952,7 +1950,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del */ free(__pyx_v_self->label_count_left); - /* "sklearn/tree/_tree.pyx":143 + /* "sklearn/tree/_tree.pyx":145 * free(self.n_classes) * free(self.label_count_left) * free(self.label_count_right) # <<<<<<<<<<<<<< @@ -1961,7 +1959,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del */ free(__pyx_v_self->label_count_right); - /* "sklearn/tree/_tree.pyx":144 + /* "sklearn/tree/_tree.pyx":146 * free(self.label_count_left) * free(self.label_count_right) * free(self.label_count_init) # <<<<<<<<<<<<<< @@ -1976,7 +1974,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_2__del return __pyx_r; } -/* "sklearn/tree/_tree.pyx":146 +/* "sklearn/tree/_tree.pyx":148 * free(self.label_count_init) * * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< @@ -1999,7 +1997,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct int __pyx_t_4; __Pyx_RefNannySetupContext("init", 0); - /* "sklearn/tree/_tree.pyx":152 + /* "sklearn/tree/_tree.pyx":154 * int n_total_samples): * """Initialise the criterion class.""" * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2008,7 +2006,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":153 + /* "sklearn/tree/_tree.pyx":155 * """Initialise the criterion class.""" * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2017,7 +2015,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_n_classes = __pyx_v_self->n_classes; - /* "sklearn/tree/_tree.pyx":154 + /* "sklearn/tree/_tree.pyx":156 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2026,7 +2024,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; - /* "sklearn/tree/_tree.pyx":155 + /* "sklearn/tree/_tree.pyx":157 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< @@ -2035,7 +2033,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_label_count_init = __pyx_v_self->label_count_init; - /* "sklearn/tree/_tree.pyx":157 + /* "sklearn/tree/_tree.pyx":159 * cdef int* label_count_init = self.label_count_init * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -2044,7 +2042,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":158 + /* "sklearn/tree/_tree.pyx":160 * * cdef int k = 0 * cdef int c = 0 # <<<<<<<<<<<<<< @@ -2053,7 +2051,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_c = 0; - /* "sklearn/tree/_tree.pyx":159 + /* "sklearn/tree/_tree.pyx":161 * cdef int k = 0 * cdef int c = 0 * cdef int j = 0 # <<<<<<<<<<<<<< @@ -2062,7 +2060,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_j = 0; - /* "sklearn/tree/_tree.pyx":161 + /* "sklearn/tree/_tree.pyx":163 * cdef int j = 0 * * self.n_samples = n_samples # <<<<<<<<<<<<<< @@ -2071,7 +2069,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_self->n_samples = __pyx_v_n_samples; - /* "sklearn/tree/_tree.pyx":163 + /* "sklearn/tree/_tree.pyx":165 * self.n_samples = n_samples * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2081,7 +2079,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":164 + /* "sklearn/tree/_tree.pyx":166 * * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -2091,7 +2089,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":165 + /* "sklearn/tree/_tree.pyx":167 * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: * label_count_init[k * label_count_stride + c] = 0 # <<<<<<<<<<<<<< @@ -2102,7 +2100,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct } } - /* "sklearn/tree/_tree.pyx":167 + /* "sklearn/tree/_tree.pyx":169 * label_count_init[k * label_count_stride + c] = 0 * * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< @@ -2112,7 +2110,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_t_1 = __pyx_v_n_total_samples; for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_1; __pyx_v_j++) { - /* "sklearn/tree/_tree.pyx":168 + /* "sklearn/tree/_tree.pyx":170 * * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -2122,7 +2120,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_t_3 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":169 + /* "sklearn/tree/_tree.pyx":171 * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -2134,7 +2132,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct } __pyx_L9:; - /* "sklearn/tree/_tree.pyx":171 + /* "sklearn/tree/_tree.pyx":173 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2144,7 +2142,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_t_2 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":172 + /* "sklearn/tree/_tree.pyx":174 * * for k from 0 <= k < n_outputs: * c = y[j * y_stride + k] # <<<<<<<<<<<<<< @@ -2153,7 +2151,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct */ __pyx_v_c = ((int)(__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)])); - /* "sklearn/tree/_tree.pyx":173 + /* "sklearn/tree/_tree.pyx":175 * for k from 0 <= k < n_outputs: * c = y[j * y_stride + k] * label_count_init[k * label_count_stride + c] += 1 # <<<<<<<<<<<<<< @@ -2166,7 +2164,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __pyx_L7_continue:; } - /* "sklearn/tree/_tree.pyx":175 + /* "sklearn/tree/_tree.pyx":177 * label_count_init[k * label_count_stride + c] += 1 * * self.reset() # <<<<<<<<<<<<<< @@ -2178,7 +2176,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init(struct __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":177 +/* "sklearn/tree/_tree.pyx":179 * self.reset() * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -2200,7 +2198,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct int __pyx_t_2; __Pyx_RefNannySetupContext("reset", 0); - /* "sklearn/tree/_tree.pyx":180 + /* "sklearn/tree/_tree.pyx":182 * """Reset label_counts by setting `label_count_left to zero * and copying the init array into the right.""" * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2209,7 +2207,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":181 + /* "sklearn/tree/_tree.pyx":183 * and copying the init array into the right.""" * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2218,7 +2216,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_n_classes = __pyx_v_self->n_classes; - /* "sklearn/tree/_tree.pyx":182 + /* "sklearn/tree/_tree.pyx":184 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2227,7 +2225,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; - /* "sklearn/tree/_tree.pyx":183 + /* "sklearn/tree/_tree.pyx":185 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< @@ -2236,7 +2234,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_label_count_init = __pyx_v_self->label_count_init; - /* "sklearn/tree/_tree.pyx":184 + /* "sklearn/tree/_tree.pyx":186 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_init = self.label_count_init * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -2245,7 +2243,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_label_count_left = __pyx_v_self->label_count_left; - /* "sklearn/tree/_tree.pyx":185 + /* "sklearn/tree/_tree.pyx":187 * cdef int* label_count_init = self.label_count_init * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -2254,7 +2252,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_label_count_right = __pyx_v_self->label_count_right; - /* "sklearn/tree/_tree.pyx":187 + /* "sklearn/tree/_tree.pyx":189 * cdef int* label_count_right = self.label_count_right * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -2263,7 +2261,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":188 + /* "sklearn/tree/_tree.pyx":190 * * cdef int k = 0 * cdef int c = 0 # <<<<<<<<<<<<<< @@ -2272,7 +2270,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_c = 0; - /* "sklearn/tree/_tree.pyx":189 + /* "sklearn/tree/_tree.pyx":191 * cdef int k = 0 * cdef int c = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -2281,7 +2279,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":190 + /* "sklearn/tree/_tree.pyx":192 * cdef int c = 0 * self.n_left = 0 * self.n_right = self.n_samples # <<<<<<<<<<<<<< @@ -2290,7 +2288,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ __pyx_v_self->n_right = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":192 + /* "sklearn/tree/_tree.pyx":194 * self.n_right = self.n_samples * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2300,7 +2298,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":193 + /* "sklearn/tree/_tree.pyx":195 * * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -2310,7 +2308,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":194 + /* "sklearn/tree/_tree.pyx":196 * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: * label_count_left[k * label_count_stride + c] = 0 # <<<<<<<<<<<<<< @@ -2319,7 +2317,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct */ (__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) = 0; - /* "sklearn/tree/_tree.pyx":195 + /* "sklearn/tree/_tree.pyx":197 * for c from 0 <= c < n_classes[k]: * label_count_left[k * label_count_stride + c] = 0 * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] # <<<<<<<<<<<<<< @@ -2333,7 +2331,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_reset(struct __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":197 +/* "sklearn/tree/_tree.pyx":199 * label_count_right[k * label_count_stride + c] = label_count_init[k * label_count_stride + c] * * cdef int update(self, int a, # <<<<<<<<<<<<<< @@ -2360,7 +2358,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct int __pyx_t_4; __Pyx_RefNannySetupContext("update", 0); - /* "sklearn/tree/_tree.pyx":205 + /* "sklearn/tree/_tree.pyx":207 * """Update the criteria for each value in interval [a,b) (where a and b * are indices in `X_argsorted_i`).""" * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2369,7 +2367,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":206 + /* "sklearn/tree/_tree.pyx":208 * are indices in `X_argsorted_i`).""" * cdef int n_outputs = self.n_outputs * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2378,7 +2376,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; - /* "sklearn/tree/_tree.pyx":207 + /* "sklearn/tree/_tree.pyx":209 * cdef int n_outputs = self.n_outputs * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -2387,7 +2385,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_label_count_left = __pyx_v_self->label_count_left; - /* "sklearn/tree/_tree.pyx":208 + /* "sklearn/tree/_tree.pyx":210 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -2396,7 +2394,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_label_count_right = __pyx_v_self->label_count_right; - /* "sklearn/tree/_tree.pyx":209 + /* "sklearn/tree/_tree.pyx":211 * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right * cdef int n_left = self.n_left # <<<<<<<<<<<<<< @@ -2405,7 +2403,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_n_left = __pyx_v_self->n_left; - /* "sklearn/tree/_tree.pyx":210 + /* "sklearn/tree/_tree.pyx":212 * cdef int* label_count_right = self.label_count_right * cdef int n_left = self.n_left * cdef int n_right = self.n_right # <<<<<<<<<<<<<< @@ -2414,7 +2412,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_n_right = __pyx_v_self->n_right; - /* "sklearn/tree/_tree.pyx":215 + /* "sklearn/tree/_tree.pyx":217 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -2424,7 +2422,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":216 + /* "sklearn/tree/_tree.pyx":218 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * s = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -2433,7 +2431,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_s = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":218 + /* "sklearn/tree/_tree.pyx":220 * s = X_argsorted_i[idx] * * if sample_mask[s] == 0: # <<<<<<<<<<<<<< @@ -2443,7 +2441,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_s]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":219 + /* "sklearn/tree/_tree.pyx":221 * * if sample_mask[s] == 0: * continue # <<<<<<<<<<<<<< @@ -2455,7 +2453,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":221 + /* "sklearn/tree/_tree.pyx":223 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2465,7 +2463,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":222 + /* "sklearn/tree/_tree.pyx":224 * * for k from 0 <= k < n_outputs: * c = y[s * y_stride + k] # <<<<<<<<<<<<<< @@ -2474,7 +2472,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_c = ((int)(__pyx_v_y[((__pyx_v_s * __pyx_v_y_stride) + __pyx_v_k)])); - /* "sklearn/tree/_tree.pyx":223 + /* "sklearn/tree/_tree.pyx":225 * for k from 0 <= k < n_outputs: * c = y[s * y_stride + k] * label_count_right[k * label_count_stride + c] -= 1 # <<<<<<<<<<<<<< @@ -2484,7 +2482,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_t_4 = ((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c); (__pyx_v_label_count_right[__pyx_t_4]) = ((__pyx_v_label_count_right[__pyx_t_4]) - 1); - /* "sklearn/tree/_tree.pyx":224 + /* "sklearn/tree/_tree.pyx":226 * c = y[s * y_stride + k] * label_count_right[k * label_count_stride + c] -= 1 * label_count_left[k * label_count_stride + c] += 1 # <<<<<<<<<<<<<< @@ -2495,7 +2493,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct (__pyx_v_label_count_left[__pyx_t_4]) = ((__pyx_v_label_count_left[__pyx_t_4]) + 1); } - /* "sklearn/tree/_tree.pyx":226 + /* "sklearn/tree/_tree.pyx":228 * label_count_left[k * label_count_stride + c] += 1 * * n_left += 1 # <<<<<<<<<<<<<< @@ -2504,7 +2502,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_n_left = (__pyx_v_n_left + 1); - /* "sklearn/tree/_tree.pyx":227 + /* "sklearn/tree/_tree.pyx":229 * * n_left += 1 * n_right -=1 # <<<<<<<<<<<<<< @@ -2515,7 +2513,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":229 + /* "sklearn/tree/_tree.pyx":231 * n_right -=1 * * self.n_left = n_left # <<<<<<<<<<<<<< @@ -2524,7 +2522,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_self->n_left = __pyx_v_n_left; - /* "sklearn/tree/_tree.pyx":230 + /* "sklearn/tree/_tree.pyx":232 * * self.n_left = n_left * self.n_right = n_right # <<<<<<<<<<<<<< @@ -2533,7 +2531,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct */ __pyx_v_self->n_right = __pyx_v_n_right; - /* "sklearn/tree/_tree.pyx":232 + /* "sklearn/tree/_tree.pyx":234 * self.n_right = n_right * * return n_left # <<<<<<<<<<<<<< @@ -2549,7 +2547,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_update(struct return __pyx_r; } -/* "sklearn/tree/_tree.pyx":234 +/* "sklearn/tree/_tree.pyx":236 * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -2567,7 +2565,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval(CYTHO return __pyx_r; } -/* "sklearn/tree/_tree.pyx":237 +/* "sklearn/tree/_tree.pyx":239 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -2609,13 +2607,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2624,7 +2622,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":238 + /* "sklearn/tree/_tree.pyx":240 * * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2633,7 +2631,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":239 + /* "sklearn/tree/_tree.pyx":241 * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2642,7 +2640,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_n_classes = __pyx_v_self->n_classes; - /* "sklearn/tree/_tree.pyx":240 + /* "sklearn/tree/_tree.pyx":242 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2651,7 +2649,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_label_count_stride = __pyx_v_self->label_count_stride; - /* "sklearn/tree/_tree.pyx":241 + /* "sklearn/tree/_tree.pyx":243 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_init = self.label_count_init # <<<<<<<<<<<<<< @@ -2660,23 +2658,23 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in */ __pyx_v_label_count_init = __pyx_v_self->label_count_init; - /* "sklearn/tree/_tree.pyx":243 + /* "sklearn/tree/_tree.pyx":245 * cdef int* label_count_init = self.label_count_init * * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, label_count_stride), dtype=DTYPE) # <<<<<<<<<<<<<< * * cdef int k, c */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_label_count_stride); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -2684,29 +2682,29 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __Pyx_GIVEREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; } } @@ -2714,7 +2712,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __pyx_v_value = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":247 + /* "sklearn/tree/_tree.pyx":249 * cdef int k, c * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2724,7 +2722,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __pyx_t_6 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":248 + /* "sklearn/tree/_tree.pyx":250 * * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -2734,7 +2732,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in __pyx_t_7 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_7; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":249 + /* "sklearn/tree/_tree.pyx":251 * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes[k]: * value[k, c] = (label_count_init[k * label_count_stride + c]) # <<<<<<<<<<<<<< @@ -2747,7 +2745,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_in } } - /* "sklearn/tree/_tree.pyx":251 + /* "sklearn/tree/_tree.pyx":253 * value[k, c] = (label_count_init[k * label_count_stride + c]) * * return value # <<<<<<<<<<<<<< @@ -2793,7 +2791,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_23ClassificationCriterion_5init_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":237 +/* "sklearn/tree/_tree.pyx":239 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -2810,7 +2808,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_ClassificationCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2828,7 +2826,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_23ClassificationCriterion_4init_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":260 +/* "sklearn/tree/_tree.pyx":262 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -2859,7 +2857,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":262 + /* "sklearn/tree/_tree.pyx":264 * cdef double eval(self): * """Returns Gini index of left branch + Gini index of right branch. """ * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -2868,7 +2866,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; - /* "sklearn/tree/_tree.pyx":263 + /* "sklearn/tree/_tree.pyx":265 * """Returns Gini index of left branch + Gini index of right branch. """ * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -2877,7 +2875,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":264 + /* "sklearn/tree/_tree.pyx":266 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -2886,7 +2884,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; - /* "sklearn/tree/_tree.pyx":265 + /* "sklearn/tree/_tree.pyx":267 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -2895,7 +2893,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; - /* "sklearn/tree/_tree.pyx":266 + /* "sklearn/tree/_tree.pyx":268 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -2904,7 +2902,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; - /* "sklearn/tree/_tree.pyx":267 + /* "sklearn/tree/_tree.pyx":269 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -2913,7 +2911,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; - /* "sklearn/tree/_tree.pyx":268 + /* "sklearn/tree/_tree.pyx":270 * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< @@ -2922,7 +2920,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":269 + /* "sklearn/tree/_tree.pyx":271 * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< @@ -2931,7 +2929,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); - /* "sklearn/tree/_tree.pyx":271 + /* "sklearn/tree/_tree.pyx":273 * cdef double n_right = self.n_right * * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -2940,7 +2938,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":276 + /* "sklearn/tree/_tree.pyx":278 * cdef int k, c, count_left, count_right * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -2950,7 +2948,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":277 + /* "sklearn/tree/_tree.pyx":279 * * for k from 0 <= k < n_outputs: * H_left = n_left * n_left # <<<<<<<<<<<<<< @@ -2959,7 +2957,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_H_left = (__pyx_v_n_left * __pyx_v_n_left); - /* "sklearn/tree/_tree.pyx":278 + /* "sklearn/tree/_tree.pyx":280 * for k from 0 <= k < n_outputs: * H_left = n_left * n_left * H_right = n_right * n_right # <<<<<<<<<<<<<< @@ -2968,7 +2966,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_H_right = (__pyx_v_n_right * __pyx_v_n_right); - /* "sklearn/tree/_tree.pyx":280 + /* "sklearn/tree/_tree.pyx":282 * H_right = n_right * n_right * * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -2978,7 +2976,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":281 + /* "sklearn/tree/_tree.pyx":283 * * for c from 0 <= c < n_classes[k]: * count_left = label_count_left[k * label_count_stride + c] # <<<<<<<<<<<<<< @@ -2987,7 +2985,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_count_left = (__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":282 + /* "sklearn/tree/_tree.pyx":284 * for c from 0 <= c < n_classes[k]: * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: # <<<<<<<<<<<<<< @@ -2997,7 +2995,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_left > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":283 + /* "sklearn/tree/_tree.pyx":285 * count_left = label_count_left[k * label_count_stride + c] * if count_left > 0: * H_left -= (count_left * count_left) # <<<<<<<<<<<<<< @@ -3009,7 +3007,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":285 + /* "sklearn/tree/_tree.pyx":287 * H_left -= (count_left * count_left) * * count_right = label_count_right[k * label_count_stride + c] # <<<<<<<<<<<<<< @@ -3018,7 +3016,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn */ __pyx_v_count_right = (__pyx_v_label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]); - /* "sklearn/tree/_tree.pyx":286 + /* "sklearn/tree/_tree.pyx":288 * * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: # <<<<<<<<<<<<<< @@ -3028,7 +3026,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_count_right > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":287 + /* "sklearn/tree/_tree.pyx":289 * count_right = label_count_right[k * label_count_stride + c] * if count_right > 0: * H_right -= (count_right * count_right) # <<<<<<<<<<<<<< @@ -3041,7 +3039,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":289 + /* "sklearn/tree/_tree.pyx":291 * H_right -= (count_right * count_right) * * if n_left == 0: # <<<<<<<<<<<<<< @@ -3051,7 +3049,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_left == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":290 + /* "sklearn/tree/_tree.pyx":292 * * if n_left == 0: * H_left = 0 # <<<<<<<<<<<<<< @@ -3063,7 +3061,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":292 + /* "sklearn/tree/_tree.pyx":294 * H_left = 0 * else: * H_left /= n_left # <<<<<<<<<<<<<< @@ -3074,7 +3072,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L9:; - /* "sklearn/tree/_tree.pyx":294 + /* "sklearn/tree/_tree.pyx":296 * H_left /= n_left * * if n_right == 0: # <<<<<<<<<<<<<< @@ -3084,7 +3082,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_t_3 = (__pyx_v_n_right == 0.0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":295 + /* "sklearn/tree/_tree.pyx":297 * * if n_right == 0: * H_right = 0 # <<<<<<<<<<<<<< @@ -3096,7 +3094,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } /*else*/ { - /* "sklearn/tree/_tree.pyx":297 + /* "sklearn/tree/_tree.pyx":299 * H_right = 0 * else: * H_right /= n_right # <<<<<<<<<<<<<< @@ -3107,7 +3105,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn } __pyx_L10:; - /* "sklearn/tree/_tree.pyx":299 + /* "sklearn/tree/_tree.pyx":301 * H_right /= n_right * * total += (H_left + H_right) # <<<<<<<<<<<<<< @@ -3117,7 +3115,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn __pyx_v_total = (__pyx_v_total + (__pyx_v_H_left + __pyx_v_H_right)); } - /* "sklearn/tree/_tree.pyx":301 + /* "sklearn/tree/_tree.pyx":303 * total += (H_left + H_right) * * return total / (n_samples * n_outputs) # <<<<<<<<<<<<<< @@ -3133,7 +3131,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_4Gini_eval(struct __pyx_obj_7sklearn return __pyx_r; } -/* "sklearn/tree/_tree.pyx":310 +/* "sklearn/tree/_tree.pyx":312 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -3164,7 +3162,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle int __pyx_t_3; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":312 + /* "sklearn/tree/_tree.pyx":314 * cdef double eval(self): * """Returns Entropy of left branch + Entropy index of right branch. """ * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -3173,7 +3171,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_samples = __pyx_v_self->__pyx_base.n_samples; - /* "sklearn/tree/_tree.pyx":313 + /* "sklearn/tree/_tree.pyx":315 * """Returns Entropy of left branch + Entropy index of right branch. """ * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -3182,7 +3180,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":314 + /* "sklearn/tree/_tree.pyx":316 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes # <<<<<<<<<<<<<< @@ -3191,7 +3189,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_classes = __pyx_v_self->__pyx_base.n_classes; - /* "sklearn/tree/_tree.pyx":315 + /* "sklearn/tree/_tree.pyx":317 * cdef int n_outputs = self.n_outputs * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride # <<<<<<<<<<<<<< @@ -3200,7 +3198,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_stride = __pyx_v_self->__pyx_base.label_count_stride; - /* "sklearn/tree/_tree.pyx":316 + /* "sklearn/tree/_tree.pyx":318 * cdef int* n_classes = self.n_classes * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left # <<<<<<<<<<<<<< @@ -3209,7 +3207,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_left = __pyx_v_self->__pyx_base.label_count_left; - /* "sklearn/tree/_tree.pyx":317 + /* "sklearn/tree/_tree.pyx":319 * cdef int label_count_stride = self.label_count_stride * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right # <<<<<<<<<<<<<< @@ -3218,7 +3216,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_label_count_right = __pyx_v_self->__pyx_base.label_count_right; - /* "sklearn/tree/_tree.pyx":318 + /* "sklearn/tree/_tree.pyx":320 * cdef int* label_count_left = self.label_count_left * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left # <<<<<<<<<<<<<< @@ -3227,7 +3225,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_left = ((double)__pyx_v_self->__pyx_base.n_left); - /* "sklearn/tree/_tree.pyx":319 + /* "sklearn/tree/_tree.pyx":321 * cdef int* label_count_right = self.label_count_right * cdef double n_left = self.n_left * cdef double n_right = self.n_right # <<<<<<<<<<<<<< @@ -3236,7 +3234,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_n_right = ((double)__pyx_v_self->__pyx_base.n_right); - /* "sklearn/tree/_tree.pyx":321 + /* "sklearn/tree/_tree.pyx":323 * cdef double n_right = self.n_right * * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -3245,7 +3243,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":327 + /* "sklearn/tree/_tree.pyx":329 * cdef double e1, e2 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3255,7 +3253,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":328 + /* "sklearn/tree/_tree.pyx":330 * * for k from 0 <= k < n_outputs: * H_left = 0.0 # <<<<<<<<<<<<<< @@ -3264,7 +3262,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_H_left = 0.0; - /* "sklearn/tree/_tree.pyx":329 + /* "sklearn/tree/_tree.pyx":331 * for k from 0 <= k < n_outputs: * H_left = 0.0 * H_right = 0.0 # <<<<<<<<<<<<<< @@ -3273,7 +3271,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_H_right = 0.0; - /* "sklearn/tree/_tree.pyx":331 + /* "sklearn/tree/_tree.pyx":333 * H_right = 0.0 * * for c from 0 <= c < n_classes[k]: # <<<<<<<<<<<<<< @@ -3283,7 +3281,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_2 = (__pyx_v_n_classes[__pyx_v_k]); for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_2; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":332 + /* "sklearn/tree/_tree.pyx":334 * * for c from 0 <= c < n_classes[k]: * if label_count_left[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< @@ -3293,7 +3291,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_3 = ((__pyx_v_label_count_left[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":333 + /* "sklearn/tree/_tree.pyx":335 * for c from 0 <= c < n_classes[k]: * if label_count_left[k * label_count_stride + c] > 0: * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) # <<<<<<<<<<<<<< @@ -3305,7 +3303,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":335 + /* "sklearn/tree/_tree.pyx":337 * H_left -= ((label_count_left[k * label_count_stride + c] / n_left) * log(label_count_left[k * label_count_stride + c] / n_left)) * * if self.label_count_right[k * label_count_stride + c] > 0: # <<<<<<<<<<<<<< @@ -3315,7 +3313,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_t_3 = ((__pyx_v_self->__pyx_base.label_count_right[((__pyx_v_k * __pyx_v_label_count_stride) + __pyx_v_c)]) > 0); if (__pyx_t_3) { - /* "sklearn/tree/_tree.pyx":336 + /* "sklearn/tree/_tree.pyx":338 * * if self.label_count_right[k * label_count_stride + c] > 0: * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) # <<<<<<<<<<<<<< @@ -3328,7 +3326,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_L8:; } - /* "sklearn/tree/_tree.pyx":338 + /* "sklearn/tree/_tree.pyx":340 * H_right -= ((label_count_right[k * label_count_stride + c] / n_right) * log(label_count_right[k * label_count_stride + c] / n_right)) * * e1 = (n_left / n_samples) * H_left # <<<<<<<<<<<<<< @@ -3337,7 +3335,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_e1 = ((__pyx_v_n_left / __pyx_v_n_samples) * __pyx_v_H_left); - /* "sklearn/tree/_tree.pyx":339 + /* "sklearn/tree/_tree.pyx":341 * * e1 = (n_left / n_samples) * H_left * e2 = (n_right / n_samples) * H_right # <<<<<<<<<<<<<< @@ -3346,7 +3344,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle */ __pyx_v_e2 = ((__pyx_v_n_right / __pyx_v_n_samples) * __pyx_v_H_right); - /* "sklearn/tree/_tree.pyx":341 + /* "sklearn/tree/_tree.pyx":343 * e2 = (n_right / n_samples) * H_right * * total += e1 + e2 # <<<<<<<<<<<<<< @@ -3356,7 +3354,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_7Entropy_eval(struct __pyx_obj_7skle __pyx_v_total = (__pyx_v_total + (__pyx_v_e1 + __pyx_v_e2)); } - /* "sklearn/tree/_tree.pyx":343 + /* "sklearn/tree/_tree.pyx":345 * total += e1 + e2 * * return total / n_outputs # <<<<<<<<<<<<<< @@ -3398,18 +3396,18 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_outputs = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_outputs == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree.RegressionCriterion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3420,7 +3418,7 @@ static int __pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_1__init__(PyObje return __pyx_r; } -/* "sklearn/tree/_tree.pyx":400 +/* "sklearn/tree/_tree.pyx":402 * cdef int n_left * * def __init__(self, int n_outputs): # <<<<<<<<<<<<<< @@ -3434,7 +3432,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "sklearn/tree/_tree.pyx":401 + /* "sklearn/tree/_tree.pyx":403 * * def __init__(self, int n_outputs): * cdef int k = 0 # <<<<<<<<<<<<<< @@ -3443,7 +3441,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":403 + /* "sklearn/tree/_tree.pyx":405 * cdef int k = 0 * * self.n_outputs = n_outputs # <<<<<<<<<<<<<< @@ -3452,7 +3450,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_outputs = __pyx_v_n_outputs; - /* "sklearn/tree/_tree.pyx":405 + /* "sklearn/tree/_tree.pyx":407 * self.n_outputs = n_outputs * * self.n_samples = 0 # <<<<<<<<<<<<<< @@ -3461,7 +3459,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_samples = 0; - /* "sklearn/tree/_tree.pyx":406 + /* "sklearn/tree/_tree.pyx":408 * * self.n_samples = 0 * self.n_left = 0 # <<<<<<<<<<<<<< @@ -3470,7 +3468,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":407 + /* "sklearn/tree/_tree.pyx":409 * self.n_samples = 0 * self.n_left = 0 * self.n_right = 0 # <<<<<<<<<<<<<< @@ -3479,7 +3477,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->n_right = 0; - /* "sklearn/tree/_tree.pyx":409 + /* "sklearn/tree/_tree.pyx":411 * self.n_right = 0 * * self.mean_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3488,7 +3486,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":410 + /* "sklearn/tree/_tree.pyx":412 * * self.mean_left = calloc(n_outputs, sizeof(double)) * self.mean_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3497,7 +3495,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":411 + /* "sklearn/tree/_tree.pyx":413 * self.mean_left = calloc(n_outputs, sizeof(double)) * self.mean_right = calloc(n_outputs, sizeof(double)) * self.mean_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3506,7 +3504,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->mean_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":412 + /* "sklearn/tree/_tree.pyx":414 * self.mean_right = calloc(n_outputs, sizeof(double)) * self.mean_init = calloc(n_outputs, sizeof(double)) * self.sq_sum_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3515,7 +3513,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":413 + /* "sklearn/tree/_tree.pyx":415 * self.mean_init = calloc(n_outputs, sizeof(double)) * self.sq_sum_left = calloc(n_outputs, sizeof(double)) * self.sq_sum_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3524,7 +3522,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_right = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":414 + /* "sklearn/tree/_tree.pyx":416 * self.sq_sum_left = calloc(n_outputs, sizeof(double)) * self.sq_sum_right = calloc(n_outputs, sizeof(double)) * self.sq_sum_init = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3533,7 +3531,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->sq_sum_init = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":415 + /* "sklearn/tree/_tree.pyx":417 * self.sq_sum_right = calloc(n_outputs, sizeof(double)) * self.sq_sum_init = calloc(n_outputs, sizeof(double)) * self.var_left = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3542,7 +3540,7 @@ static int __pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion___init__(struct */ __pyx_v_self->var_left = ((double *)calloc(__pyx_v_n_outputs, (sizeof(double)))); - /* "sklearn/tree/_tree.pyx":416 + /* "sklearn/tree/_tree.pyx":418 * self.sq_sum_init = calloc(n_outputs, sizeof(double)) * self.var_left = calloc(n_outputs, sizeof(double)) * self.var_right = calloc(n_outputs, sizeof(double)) # <<<<<<<<<<<<<< @@ -3567,7 +3565,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_3__del__(P return __pyx_r; } -/* "sklearn/tree/_tree.pyx":418 +/* "sklearn/tree/_tree.pyx":420 * self.var_right = calloc(n_outputs, sizeof(double)) * * def __del__(self): # <<<<<<<<<<<<<< @@ -3580,7 +3578,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); - /* "sklearn/tree/_tree.pyx":419 + /* "sklearn/tree/_tree.pyx":421 * * def __del__(self): * free(self.mean_left) # <<<<<<<<<<<<<< @@ -3589,7 +3587,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_left); - /* "sklearn/tree/_tree.pyx":420 + /* "sklearn/tree/_tree.pyx":422 * def __del__(self): * free(self.mean_left) * free(self.mean_right) # <<<<<<<<<<<<<< @@ -3598,7 +3596,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_right); - /* "sklearn/tree/_tree.pyx":421 + /* "sklearn/tree/_tree.pyx":423 * free(self.mean_left) * free(self.mean_right) * free(self.mean_init) # <<<<<<<<<<<<<< @@ -3607,7 +3605,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->mean_init); - /* "sklearn/tree/_tree.pyx":422 + /* "sklearn/tree/_tree.pyx":424 * free(self.mean_right) * free(self.mean_init) * free(self.sq_sum_left) # <<<<<<<<<<<<<< @@ -3616,7 +3614,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_left); - /* "sklearn/tree/_tree.pyx":423 + /* "sklearn/tree/_tree.pyx":425 * free(self.mean_init) * free(self.sq_sum_left) * free(self.sq_sum_right) # <<<<<<<<<<<<<< @@ -3625,7 +3623,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_right); - /* "sklearn/tree/_tree.pyx":424 + /* "sklearn/tree/_tree.pyx":426 * free(self.sq_sum_left) * free(self.sq_sum_right) * free(self.sq_sum_init) # <<<<<<<<<<<<<< @@ -3634,7 +3632,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->sq_sum_init); - /* "sklearn/tree/_tree.pyx":425 + /* "sklearn/tree/_tree.pyx":427 * free(self.sq_sum_right) * free(self.sq_sum_init) * free(self.var_left) # <<<<<<<<<<<<<< @@ -3643,7 +3641,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s */ free(__pyx_v_self->var_left); - /* "sklearn/tree/_tree.pyx":426 + /* "sklearn/tree/_tree.pyx":428 * free(self.sq_sum_init) * free(self.var_left) * free(self.var_right) # <<<<<<<<<<<<<< @@ -3658,7 +3656,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_2__del__(s return __pyx_r; } -/* "sklearn/tree/_tree.pyx":428 +/* "sklearn/tree/_tree.pyx":430 * free(self.var_right) * * cdef void init(self, DTYPE_t* y, # <<<<<<<<<<<<<< @@ -3686,7 +3684,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py int __pyx_t_4; __Pyx_RefNannySetupContext("init", 0); - /* "sklearn/tree/_tree.pyx":436 + /* "sklearn/tree/_tree.pyx":438 * are in the right branch and store the mean and squared * sum in `self.mean_init` and `self.sq_sum_init`. """ * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -3695,7 +3693,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":437 + /* "sklearn/tree/_tree.pyx":439 * sum in `self.mean_init` and `self.sq_sum_init`. """ * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -3704,7 +3702,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":438 + /* "sklearn/tree/_tree.pyx":440 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -3713,7 +3711,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":439 + /* "sklearn/tree/_tree.pyx":441 * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -3722,7 +3720,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":440 + /* "sklearn/tree/_tree.pyx":442 * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -3731,7 +3729,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":441 + /* "sklearn/tree/_tree.pyx":443 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< @@ -3740,7 +3738,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; - /* "sklearn/tree/_tree.pyx":442 + /* "sklearn/tree/_tree.pyx":444 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -3749,7 +3747,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":443 + /* "sklearn/tree/_tree.pyx":445 * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -3758,7 +3756,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":444 + /* "sklearn/tree/_tree.pyx":446 * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -3767,7 +3765,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":446 + /* "sklearn/tree/_tree.pyx":448 * cdef int n_outputs = self.n_outputs * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -3776,7 +3774,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":448 + /* "sklearn/tree/_tree.pyx":450 * cdef int k = 0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3786,7 +3784,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":449 + /* "sklearn/tree/_tree.pyx":451 * * for k from 0 <= k < n_outputs: * mean_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3795,7 +3793,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":450 + /* "sklearn/tree/_tree.pyx":452 * for k from 0 <= k < n_outputs: * mean_left[k] = 0.0 * mean_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3804,7 +3802,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":451 + /* "sklearn/tree/_tree.pyx":453 * mean_left[k] = 0.0 * mean_right[k] = 0.0 * mean_init[k] = 0.0 # <<<<<<<<<<<<<< @@ -3813,7 +3811,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_mean_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":452 + /* "sklearn/tree/_tree.pyx":454 * mean_right[k] = 0.0 * mean_init[k] = 0.0 * sq_sum_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3822,7 +3820,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_right[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":453 + /* "sklearn/tree/_tree.pyx":455 * mean_init[k] = 0.0 * sq_sum_right[k] = 0.0 * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3831,7 +3829,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":454 + /* "sklearn/tree/_tree.pyx":456 * sq_sum_right[k] = 0.0 * sq_sum_left[k] = 0.0 * sq_sum_init[k] = 0.0 # <<<<<<<<<<<<<< @@ -3840,7 +3838,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_sq_sum_init[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":455 + /* "sklearn/tree/_tree.pyx":457 * sq_sum_left[k] = 0.0 * sq_sum_init[k] = 0.0 * var_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -3849,7 +3847,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":456 + /* "sklearn/tree/_tree.pyx":458 * sq_sum_init[k] = 0.0 * var_left[k] = 0.0 * var_right[k] = 0.0 # <<<<<<<<<<<<<< @@ -3859,7 +3857,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py (__pyx_v_var_right[__pyx_v_k]) = 0.0; } - /* "sklearn/tree/_tree.pyx":458 + /* "sklearn/tree/_tree.pyx":460 * var_right[k] = 0.0 * * self.n_samples = n_samples # <<<<<<<<<<<<<< @@ -3868,7 +3866,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_self->n_samples = __pyx_v_n_samples; - /* "sklearn/tree/_tree.pyx":460 + /* "sklearn/tree/_tree.pyx":462 * self.n_samples = n_samples * * cdef int j = 0 # <<<<<<<<<<<<<< @@ -3877,7 +3875,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_j = 0; - /* "sklearn/tree/_tree.pyx":461 + /* "sklearn/tree/_tree.pyx":463 * * cdef int j = 0 * cdef DTYPE_t y_jk = 0.0 # <<<<<<<<<<<<<< @@ -3886,7 +3884,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_y_jk = 0.0; - /* "sklearn/tree/_tree.pyx":463 + /* "sklearn/tree/_tree.pyx":465 * cdef DTYPE_t y_jk = 0.0 * * for j from 0 <= j < n_total_samples: # <<<<<<<<<<<<<< @@ -3896,7 +3894,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_total_samples; for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_1; __pyx_v_j++) { - /* "sklearn/tree/_tree.pyx":464 + /* "sklearn/tree/_tree.pyx":466 * * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -3906,7 +3904,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":465 + /* "sklearn/tree/_tree.pyx":467 * for j from 0 <= j < n_total_samples: * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -3918,7 +3916,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py } __pyx_L7:; - /* "sklearn/tree/_tree.pyx":467 + /* "sklearn/tree/_tree.pyx":469 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3928,7 +3926,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":468 + /* "sklearn/tree/_tree.pyx":470 * * for k from 0 <= k < n_outputs: * y_jk = y[j * y_stride + k] # <<<<<<<<<<<<<< @@ -3937,7 +3935,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py */ __pyx_v_y_jk = (__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)]); - /* "sklearn/tree/_tree.pyx":469 + /* "sklearn/tree/_tree.pyx":471 * for k from 0 <= k < n_outputs: * y_jk = y[j * y_stride + k] * sq_sum_init[k] += y_jk * y_jk # <<<<<<<<<<<<<< @@ -3947,7 +3945,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_init[__pyx_t_4]) = ((__pyx_v_sq_sum_init[__pyx_t_4]) + (__pyx_v_y_jk * __pyx_v_y_jk)); - /* "sklearn/tree/_tree.pyx":470 + /* "sklearn/tree/_tree.pyx":472 * y_jk = y[j * y_stride + k] * sq_sum_init[k] += y_jk * y_jk * mean_init[k] += y_jk # <<<<<<<<<<<<<< @@ -3960,7 +3958,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_L5_continue:; } - /* "sklearn/tree/_tree.pyx":472 + /* "sklearn/tree/_tree.pyx":474 * mean_init[k] += y_jk * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -3970,7 +3968,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":473 + /* "sklearn/tree/_tree.pyx":475 * * for k from 0 <= k < n_outputs: * mean_init[k] /= n_samples # <<<<<<<<<<<<<< @@ -3981,7 +3979,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py (__pyx_v_mean_init[__pyx_t_3]) = ((__pyx_v_mean_init[__pyx_t_3]) / __pyx_v_n_samples); } - /* "sklearn/tree/_tree.pyx":475 + /* "sklearn/tree/_tree.pyx":477 * mean_init[k] /= n_samples * * self.reset() # <<<<<<<<<<<<<< @@ -3993,7 +3991,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init(struct __py __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":477 +/* "sklearn/tree/_tree.pyx":479 * self.reset() * * cdef void reset(self): # <<<<<<<<<<<<<< @@ -4017,7 +4015,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p int __pyx_t_1; __Pyx_RefNannySetupContext("reset", 0); - /* "sklearn/tree/_tree.pyx":484 + /* "sklearn/tree/_tree.pyx":486 * right branch. * """ * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -4026,7 +4024,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":485 + /* "sklearn/tree/_tree.pyx":487 * """ * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -4035,7 +4033,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":486 + /* "sklearn/tree/_tree.pyx":488 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -4044,7 +4042,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":487 + /* "sklearn/tree/_tree.pyx":489 * cdef double* mean_right = self.mean_right * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -4053,7 +4051,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":488 + /* "sklearn/tree/_tree.pyx":490 * cdef double* mean_init = self.mean_init * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -4062,7 +4060,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":489 + /* "sklearn/tree/_tree.pyx":491 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init # <<<<<<<<<<<<<< @@ -4071,7 +4069,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_sq_sum_init = __pyx_v_self->sq_sum_init; - /* "sklearn/tree/_tree.pyx":490 + /* "sklearn/tree/_tree.pyx":492 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4080,7 +4078,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":491 + /* "sklearn/tree/_tree.pyx":493 * cdef double* sq_sum_init = self.sq_sum_init * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4089,7 +4087,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":493 + /* "sklearn/tree/_tree.pyx":495 * cdef double* var_right = self.var_right * * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -4098,7 +4096,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_n_samples = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":494 + /* "sklearn/tree/_tree.pyx":496 * * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4107,7 +4105,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":496 + /* "sklearn/tree/_tree.pyx":498 * cdef int n_outputs = self.n_outputs * * cdef int k = 0 # <<<<<<<<<<<<<< @@ -4116,7 +4114,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_k = 0; - /* "sklearn/tree/_tree.pyx":498 + /* "sklearn/tree/_tree.pyx":500 * cdef int k = 0 * * self.n_right = self.n_samples # <<<<<<<<<<<<<< @@ -4125,7 +4123,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_self->n_right = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":499 + /* "sklearn/tree/_tree.pyx":501 * * self.n_right = self.n_samples * self.n_left = 0 # <<<<<<<<<<<<<< @@ -4134,7 +4132,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ __pyx_v_self->n_left = 0; - /* "sklearn/tree/_tree.pyx":501 + /* "sklearn/tree/_tree.pyx":503 * self.n_left = 0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4144,7 +4142,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":502 + /* "sklearn/tree/_tree.pyx":504 * * for k from 0 <= k < n_outputs: * mean_right[k] = mean_init[k] # <<<<<<<<<<<<<< @@ -4153,7 +4151,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_mean_right[__pyx_v_k]) = (__pyx_v_mean_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":503 + /* "sklearn/tree/_tree.pyx":505 * for k from 0 <= k < n_outputs: * mean_right[k] = mean_init[k] * mean_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4162,7 +4160,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_mean_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":504 + /* "sklearn/tree/_tree.pyx":506 * mean_right[k] = mean_init[k] * mean_left[k] = 0.0 * sq_sum_right[k] = sq_sum_init[k] # <<<<<<<<<<<<<< @@ -4171,7 +4169,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_sq_sum_right[__pyx_v_k]) = (__pyx_v_sq_sum_init[__pyx_v_k]); - /* "sklearn/tree/_tree.pyx":505 + /* "sklearn/tree/_tree.pyx":507 * mean_left[k] = 0.0 * sq_sum_right[k] = sq_sum_init[k] * sq_sum_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4180,7 +4178,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_sq_sum_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":506 + /* "sklearn/tree/_tree.pyx":508 * sq_sum_right[k] = sq_sum_init[k] * sq_sum_left[k] = 0.0 * var_left[k] = 0.0 # <<<<<<<<<<<<<< @@ -4189,7 +4187,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p */ (__pyx_v_var_left[__pyx_v_k]) = 0.0; - /* "sklearn/tree/_tree.pyx":507 + /* "sklearn/tree/_tree.pyx":509 * sq_sum_left[k] = 0.0 * var_left[k] = 0.0 * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< @@ -4202,7 +4200,7 @@ static void __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_reset(struct __p __Pyx_RefNannyFinishContext(); } -/* "sklearn/tree/_tree.pyx":509 +/* "sklearn/tree/_tree.pyx":511 * var_right[k] = sq_sum_right[k] - n_samples * (mean_right[k] * mean_right[k]) * * cdef int update(self, int a, # <<<<<<<<<<<<<< @@ -4233,7 +4231,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p int __pyx_t_4; __Pyx_RefNannySetupContext("update", 0); - /* "sklearn/tree/_tree.pyx":517 + /* "sklearn/tree/_tree.pyx":519 * """Update the criteria for each value in interval [a,b) (where a and b * are indices in `X_argsorted_i`).""" * cdef double* mean_left = self.mean_left # <<<<<<<<<<<<<< @@ -4242,7 +4240,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_mean_left = __pyx_v_self->mean_left; - /* "sklearn/tree/_tree.pyx":518 + /* "sklearn/tree/_tree.pyx":520 * are indices in `X_argsorted_i`).""" * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right # <<<<<<<<<<<<<< @@ -4251,7 +4249,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_mean_right = __pyx_v_self->mean_right; - /* "sklearn/tree/_tree.pyx":519 + /* "sklearn/tree/_tree.pyx":521 * cdef double* mean_left = self.mean_left * cdef double* mean_right = self.mean_right * cdef double* sq_sum_left = self.sq_sum_left # <<<<<<<<<<<<<< @@ -4260,7 +4258,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_sq_sum_left = __pyx_v_self->sq_sum_left; - /* "sklearn/tree/_tree.pyx":520 + /* "sklearn/tree/_tree.pyx":522 * cdef double* mean_right = self.mean_right * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right # <<<<<<<<<<<<<< @@ -4269,7 +4267,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_sq_sum_right = __pyx_v_self->sq_sum_right; - /* "sklearn/tree/_tree.pyx":521 + /* "sklearn/tree/_tree.pyx":523 * cdef double* sq_sum_left = self.sq_sum_left * cdef double* sq_sum_right = self.sq_sum_right * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4278,7 +4276,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_var_left = __pyx_v_self->var_left; - /* "sklearn/tree/_tree.pyx":522 + /* "sklearn/tree/_tree.pyx":524 * cdef double* sq_sum_right = self.sq_sum_right * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4287,7 +4285,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_var_right = __pyx_v_self->var_right; - /* "sklearn/tree/_tree.pyx":524 + /* "sklearn/tree/_tree.pyx":526 * cdef double* var_right = self.var_right * * cdef int n_samples = self.n_samples # <<<<<<<<<<<<<< @@ -4296,7 +4294,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_samples = __pyx_v_self->n_samples; - /* "sklearn/tree/_tree.pyx":525 + /* "sklearn/tree/_tree.pyx":527 * * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4305,7 +4303,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":526 + /* "sklearn/tree/_tree.pyx":528 * cdef int n_samples = self.n_samples * cdef int n_outputs = self.n_outputs * cdef int n_left = self.n_left # <<<<<<<<<<<<<< @@ -4314,7 +4312,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_left = __pyx_v_self->n_left; - /* "sklearn/tree/_tree.pyx":527 + /* "sklearn/tree/_tree.pyx":529 * cdef int n_outputs = self.n_outputs * cdef int n_left = self.n_left * cdef int n_right = self.n_right # <<<<<<<<<<<<<< @@ -4323,7 +4321,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_right = __pyx_v_self->n_right; - /* "sklearn/tree/_tree.pyx":529 + /* "sklearn/tree/_tree.pyx":531 * cdef int n_right = self.n_right * * cdef double y_idx = 0.0 # <<<<<<<<<<<<<< @@ -4332,7 +4330,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_y_idx = 0.0; - /* "sklearn/tree/_tree.pyx":533 + /* "sklearn/tree/_tree.pyx":535 * * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: # <<<<<<<<<<<<<< @@ -4342,7 +4340,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_1 = __pyx_v_b; for (__pyx_v_idx = __pyx_v_a; __pyx_v_idx < __pyx_t_1; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":534 + /* "sklearn/tree/_tree.pyx":536 * # post condition: all samples from [0:b) are on the left side * for idx from a <= idx < b: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -4351,7 +4349,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":536 + /* "sklearn/tree/_tree.pyx":538 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -4361,7 +4359,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_2 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":537 + /* "sklearn/tree/_tree.pyx":539 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -4373,7 +4371,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p } __pyx_L5:; - /* "sklearn/tree/_tree.pyx":539 + /* "sklearn/tree/_tree.pyx":541 * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4383,7 +4381,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":540 + /* "sklearn/tree/_tree.pyx":542 * * for k from 0 <= k < n_outputs: * y_idx = y[k * y_stride + j] # <<<<<<<<<<<<<< @@ -4392,7 +4390,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_k * __pyx_v_y_stride) + __pyx_v_j)]); - /* "sklearn/tree/_tree.pyx":541 + /* "sklearn/tree/_tree.pyx":543 * for k from 0 <= k < n_outputs: * y_idx = y[k * y_stride + j] * sq_sum_left[k] += (y_idx * y_idx) # <<<<<<<<<<<<<< @@ -4402,7 +4400,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_left[__pyx_t_4]) = ((__pyx_v_sq_sum_left[__pyx_t_4]) + (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":542 + /* "sklearn/tree/_tree.pyx":544 * y_idx = y[k * y_stride + j] * sq_sum_left[k] += (y_idx * y_idx) * sq_sum_right[k] -= (y_idx * y_idx) # <<<<<<<<<<<<<< @@ -4412,7 +4410,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_4 = __pyx_v_k; (__pyx_v_sq_sum_right[__pyx_t_4]) = ((__pyx_v_sq_sum_right[__pyx_t_4]) - (__pyx_v_y_idx * __pyx_v_y_idx)); - /* "sklearn/tree/_tree.pyx":544 + /* "sklearn/tree/_tree.pyx":546 * sq_sum_right[k] -= (y_idx * y_idx) * * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) # <<<<<<<<<<<<<< @@ -4421,7 +4419,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ (__pyx_v_mean_left[__pyx_v_k]) = (((__pyx_v_n_left * (__pyx_v_mean_left[__pyx_v_k])) + __pyx_v_y_idx) / ((double)(__pyx_v_n_left + 1))); - /* "sklearn/tree/_tree.pyx":545 + /* "sklearn/tree/_tree.pyx":547 * * mean_left[k] = (n_left * mean_left[k] + y_idx) / (n_left + 1) * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) # <<<<<<<<<<<<<< @@ -4431,7 +4429,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p (__pyx_v_mean_right[__pyx_v_k]) = ((((__pyx_v_n_samples - __pyx_v_n_left) * (__pyx_v_mean_right[__pyx_v_k])) - __pyx_v_y_idx) / ((double)((__pyx_v_n_samples - __pyx_v_n_left) - 1))); } - /* "sklearn/tree/_tree.pyx":547 + /* "sklearn/tree/_tree.pyx":549 * mean_right[k] = ((n_samples - n_left) * mean_right[k] - y_idx) / (n_samples - n_left - 1) * * n_left += 1 # <<<<<<<<<<<<<< @@ -4440,7 +4438,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_left = (__pyx_v_n_left + 1); - /* "sklearn/tree/_tree.pyx":548 + /* "sklearn/tree/_tree.pyx":550 * * n_left += 1 * self.n_left = n_left # <<<<<<<<<<<<<< @@ -4449,7 +4447,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_self->n_left = __pyx_v_n_left; - /* "sklearn/tree/_tree.pyx":549 + /* "sklearn/tree/_tree.pyx":551 * n_left += 1 * self.n_left = n_left * n_right -= 1 # <<<<<<<<<<<<<< @@ -4458,7 +4456,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_n_right = (__pyx_v_n_right - 1); - /* "sklearn/tree/_tree.pyx":550 + /* "sklearn/tree/_tree.pyx":552 * self.n_left = n_left * n_right -= 1 * self.n_right = n_right # <<<<<<<<<<<<<< @@ -4467,7 +4465,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ __pyx_v_self->n_right = __pyx_v_n_right; - /* "sklearn/tree/_tree.pyx":552 + /* "sklearn/tree/_tree.pyx":554 * self.n_right = n_right * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4477,7 +4475,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_t_3 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":553 + /* "sklearn/tree/_tree.pyx":555 * * for k from 0 <= k < n_outputs: * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) # <<<<<<<<<<<<<< @@ -4486,7 +4484,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p */ (__pyx_v_var_left[__pyx_v_k]) = ((__pyx_v_sq_sum_left[__pyx_v_k]) - (__pyx_v_n_left * ((__pyx_v_mean_left[__pyx_v_k]) * (__pyx_v_mean_left[__pyx_v_k])))); - /* "sklearn/tree/_tree.pyx":554 + /* "sklearn/tree/_tree.pyx":556 * for k from 0 <= k < n_outputs: * var_left[k] = sq_sum_left[k] - n_left * (mean_left[k] * mean_left[k]) * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) # <<<<<<<<<<<<<< @@ -4498,7 +4496,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p __pyx_L3_continue:; } - /* "sklearn/tree/_tree.pyx":556 + /* "sklearn/tree/_tree.pyx":558 * var_right[k] = sq_sum_right[k] - n_right * (mean_right[k] * mean_right[k]) * * return n_left # <<<<<<<<<<<<<< @@ -4514,7 +4512,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p return __pyx_r; } -/* "sklearn/tree/_tree.pyx":558 +/* "sklearn/tree/_tree.pyx":560 * return n_left * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -4532,7 +4530,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval(CYTHON_UN return __pyx_r; } -/* "sklearn/tree/_tree.pyx":561 +/* "sklearn/tree/_tree.pyx":563 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -4570,13 +4568,13 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v if (unlikely(__pyx_skip_dispatch)) ; /* Check if overriden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__init_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_value)) { __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4585,7 +4583,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "sklearn/tree/_tree.pyx":562 + /* "sklearn/tree/_tree.pyx":564 * * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4594,7 +4592,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v */ __pyx_v_n_outputs = __pyx_v_self->n_outputs; - /* "sklearn/tree/_tree.pyx":563 + /* "sklearn/tree/_tree.pyx":565 * cpdef np.ndarray init_value(self): * cdef int n_outputs = self.n_outputs * cdef double* mean_init = self.mean_init # <<<<<<<<<<<<<< @@ -4603,21 +4601,21 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v */ __pyx_v_mean_init = __pyx_v_self->mean_init; - /* "sklearn/tree/_tree.pyx":565 + /* "sklearn/tree/_tree.pyx":567 * cdef double* mean_init = self.mean_init * * cdef np.ndarray[DTYPE_t, ndim=2] value = np.zeros((n_outputs, 1), dtype=DTYPE) # <<<<<<<<<<<<<< * cdef int k * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_n_outputs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -4625,29 +4623,29 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_value.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_value = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_value.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_value.diminfo[0].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_value.diminfo[0].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_value.diminfo[1].strides = __pyx_pybuffernd_value.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_value.diminfo[1].shape = __pyx_pybuffernd_value.rcbuffer->pybuffer.shape[1]; } } @@ -4655,7 +4653,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_v_value = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; - /* "sklearn/tree/_tree.pyx":568 + /* "sklearn/tree/_tree.pyx":570 * cdef int k * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4665,7 +4663,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v __pyx_t_6 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":569 + /* "sklearn/tree/_tree.pyx":571 * * for k from 0 <= k < n_outputs: * value[k, 0] = (mean_init[k]) # <<<<<<<<<<<<<< @@ -4677,7 +4675,7 @@ static PyArrayObject *__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_v *__Pyx_BufPtrStrided2d(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, __pyx_pybuffernd_value.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_value.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_value.diminfo[1].strides) = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t)(__pyx_v_mean_init[__pyx_v_k])); } - /* "sklearn/tree/_tree.pyx":571 + /* "sklearn/tree/_tree.pyx":573 * value[k, 0] = (mean_init[k]) * * return value # <<<<<<<<<<<<<< @@ -4723,7 +4721,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_19RegressionCriterion_5init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":561 +/* "sklearn/tree/_tree.pyx":563 * pass * * cpdef np.ndarray init_value(self): # <<<<<<<<<<<<<< @@ -4740,7 +4738,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_valu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init_value", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_RegressionCriterion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.init_value(((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)__pyx_v_self), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4758,7 +4756,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_19RegressionCriterion_4init_valu return __pyx_r; } -/* "sklearn/tree/_tree.pyx":580 +/* "sklearn/tree/_tree.pyx":582 * """ * * cdef double eval(self): # <<<<<<<<<<<<<< @@ -4777,7 +4775,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ int __pyx_t_1; __Pyx_RefNannySetupContext("eval", 0); - /* "sklearn/tree/_tree.pyx":581 + /* "sklearn/tree/_tree.pyx":583 * * cdef double eval(self): * cdef double* var_left = self.var_left # <<<<<<<<<<<<<< @@ -4786,7 +4784,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_var_left = __pyx_v_self->__pyx_base.var_left; - /* "sklearn/tree/_tree.pyx":582 + /* "sklearn/tree/_tree.pyx":584 * cdef double eval(self): * cdef double* var_left = self.var_left * cdef double* var_right = self.var_right # <<<<<<<<<<<<<< @@ -4795,7 +4793,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_var_right = __pyx_v_self->__pyx_base.var_right; - /* "sklearn/tree/_tree.pyx":584 + /* "sklearn/tree/_tree.pyx":586 * cdef double* var_right = self.var_right * * cdef int n_outputs = self.n_outputs # <<<<<<<<<<<<<< @@ -4804,7 +4802,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_n_outputs = __pyx_v_self->__pyx_base.n_outputs; - /* "sklearn/tree/_tree.pyx":587 + /* "sklearn/tree/_tree.pyx":589 * * cdef int k * cdef double total = 0.0 # <<<<<<<<<<<<<< @@ -4813,7 +4811,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_total = 0.0; - /* "sklearn/tree/_tree.pyx":589 + /* "sklearn/tree/_tree.pyx":591 * cdef double total = 0.0 * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -4823,7 +4821,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ __pyx_t_1 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":590 + /* "sklearn/tree/_tree.pyx":592 * * for k from 0 <= k < n_outputs: * total += var_left[k] # <<<<<<<<<<<<<< @@ -4832,7 +4830,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ */ __pyx_v_total = (__pyx_v_total + (__pyx_v_var_left[__pyx_v_k])); - /* "sklearn/tree/_tree.pyx":591 + /* "sklearn/tree/_tree.pyx":593 * for k from 0 <= k < n_outputs: * total += var_left[k] * total += var_right[k] # <<<<<<<<<<<<<< @@ -4842,7 +4840,7 @@ static double __pyx_f_7sklearn_4tree_5_tree_3MSE_eval(struct __pyx_obj_7sklearn_ __pyx_v_total = (__pyx_v_total + (__pyx_v_var_right[__pyx_v_k])); } - /* "sklearn/tree/_tree.pyx":593 + /* "sklearn/tree/_tree.pyx":595 * total += var_right[k] * * return total / n_outputs # <<<<<<<<<<<<<< @@ -4893,17 +4891,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_total_in_bag); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_random_sample_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -4912,13 +4910,13 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } - __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_samples = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_n_total_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_total_in_bag = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_total_in_bag == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_random_state = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_random_sample_mask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._random_sample_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4929,7 +4927,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_1_random_sample_mask(PyObject *_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":602 +/* "sklearn/tree/_tree.pyx":604 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< @@ -4959,7 +4957,6 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE int __pyx_t_9; int __pyx_t_10; int __pyx_t_11; - int __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -4973,33 +4970,33 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_pybuffernd_sample_mask.data = NULL; __pyx_pybuffernd_sample_mask.rcbuffer = &__pyx_pybuffer_sample_mask; - /* "sklearn/tree/_tree.pyx":621 + /* "sklearn/tree/_tree.pyx":623 * """ * cdef np.ndarray[np.float64_t, ndim=1, mode="c"] rand = \ * random_state.rand(n_total_samples) # <<<<<<<<<<<<<< * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rand.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_rand = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_rand.diminfo[0].strides = __pyx_pybuffernd_rand.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rand.diminfo[0].shape = __pyx_pybuffernd_rand.rcbuffer->pybuffer.shape[0]; } } @@ -5007,51 +5004,51 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_rand = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":623 + /* "sklearn/tree/_tree.pyx":625 * random_state.rand(n_total_samples) * cdef np.ndarray[BOOL_t, ndim=1, mode="c"] sample_mask = \ * np.zeros((n_total_samples,), dtype=np.int8) # <<<<<<<<<<<<<< * * cdef int n_bagged = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_n_total_samples); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__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 = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sample_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_BOOL_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_sample_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_sample_mask.diminfo[0].strides = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sample_mask.diminfo[0].shape = __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.shape[0]; } } @@ -5059,57 +5056,56 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_v_sample_mask = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "sklearn/tree/_tree.pyx":625 + /* "sklearn/tree/_tree.pyx":627 * np.zeros((n_total_samples,), dtype=np.int8) * * cdef int n_bagged = 0 # <<<<<<<<<<<<<< * cdef int i = 0 - * for i in range(n_total_samples): + * for i from 0 <= i < n_total_samples: */ __pyx_v_n_bagged = 0; - /* "sklearn/tree/_tree.pyx":626 + /* "sklearn/tree/_tree.pyx":628 * * cdef int n_bagged = 0 * cdef int i = 0 # <<<<<<<<<<<<<< - * for i in range(n_total_samples): + * for i from 0 <= i < n_total_samples: * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":627 + /* "sklearn/tree/_tree.pyx":629 * cdef int n_bagged = 0 * cdef int i = 0 - * for i in range(n_total_samples): # <<<<<<<<<<<<<< + * for i from 0 <= i < n_total_samples: # <<<<<<<<<<<<<< * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 */ __pyx_t_8 = __pyx_v_n_total_samples; - for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { - __pyx_v_i = __pyx_t_9; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) { - /* "sklearn/tree/_tree.pyx":628 + /* "sklearn/tree/_tree.pyx":630 * cdef int i = 0 - * for i in range(n_total_samples): + * for i from 0 <= i < n_total_samples: * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): # <<<<<<<<<<<<<< * sample_mask[i] = 1 * n_bagged += 1 */ - __pyx_t_10 = __pyx_v_i; - __pyx_t_11 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_rand.diminfo[0].strides)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); - if (__pyx_t_11) { + __pyx_t_9 = __pyx_v_i; + __pyx_t_10 = (((*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_rand.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_rand.diminfo[0].strides)) * (__pyx_v_n_total_samples - __pyx_v_i)) < (__pyx_v_n_total_in_bag - __pyx_v_n_bagged)); + if (__pyx_t_10) { - /* "sklearn/tree/_tree.pyx":629 - * for i in range(n_total_samples): + /* "sklearn/tree/_tree.pyx":631 + * for i from 0 <= i < n_total_samples: * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 # <<<<<<<<<<<<<< * n_bagged += 1 * */ - __pyx_t_12 = __pyx_v_i; - *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_sample_mask.diminfo[0].strides) = 1; + __pyx_t_11 = __pyx_v_i; + *__Pyx_BufPtrCContig1d(__pyx_t_7sklearn_4tree_5_tree_BOOL_t *, __pyx_pybuffernd_sample_mask.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_sample_mask.diminfo[0].strides) = 1; - /* "sklearn/tree/_tree.pyx":630 + /* "sklearn/tree/_tree.pyx":632 * if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): * sample_mask[i] = 1 * n_bagged += 1 # <<<<<<<<<<<<<< @@ -5122,7 +5118,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE __pyx_L5:; } - /* "sklearn/tree/_tree.pyx":632 + /* "sklearn/tree/_tree.pyx":634 * n_bagged += 1 * * return sample_mask.astype(np.bool) # <<<<<<<<<<<<<< @@ -5130,19 +5126,19 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree__random_sample_mask(CYTHON_UNUSE * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_sample_mask), __pyx_n_s__astype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bool); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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 = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -5216,29 +5212,29 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__out); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -5257,17 +5253,17 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_apply_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._apply_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_out); goto __pyx_L0; __pyx_L1_error:; @@ -5277,7 +5273,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_3_apply_tree(PyObject *__pyx_sel return __pyx_r; } -/* "sklearn/tree/_tree.pyx":635 +/* "sklearn/tree/_tree.pyx":637 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5303,22 +5299,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - int __pyx_t_3; - long __pyx_t_4; + long __pyx_t_3; + int __pyx_t_4; int __pyx_t_5; - int __pyx_t_6; - long __pyx_t_7; + long __pyx_t_6; + int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; - int __pyx_t_11; - __pyx_t_5numpy_int32_t __pyx_t_12; + __pyx_t_5numpy_int32_t __pyx_t_11; + int __pyx_t_12; int __pyx_t_13; - int __pyx_t_14; - long __pyx_t_15; - int __pyx_t_16; - long __pyx_t_17; - int __pyx_t_18; + long __pyx_t_14; + int __pyx_t_15; + long __pyx_t_16; + int __pyx_t_17; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5345,31 +5340,31 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out; { __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 = 635; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; - /* "sklearn/tree/_tree.pyx":642 + /* "sklearn/tree/_tree.pyx":644 * """Finds the terminal region (=leaf node) for each sample in * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 # <<<<<<<<<<<<<< @@ -5378,45 +5373,44 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj */ __pyx_v_i = 0; - /* "sklearn/tree/_tree.pyx":643 + /* "sklearn/tree/_tree.pyx":645 * `X` and sets the corresponding element in `out` to its node id.""" * cdef int i = 0 * cdef int n = X.shape[0] # <<<<<<<<<<<<<< * cdef int node_id = 0 - * for i in xrange(n): + * for i from 0 <= i < n: */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":644 + /* "sklearn/tree/_tree.pyx":646 * cdef int i = 0 * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< - * for i in xrange(n): + * for i from 0 <= i < n: * node_id = 0 */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":645 + /* "sklearn/tree/_tree.pyx":647 * cdef int n = X.shape[0] * cdef int node_id = 0 - * for i in xrange(n): # <<<<<<<<<<<<<< + * for i from 0 <= i < n: # <<<<<<<<<<<<<< * node_id = 0 * # While node_id not a leaf */ __pyx_t_1 = __pyx_v_n; - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_v_i = __pyx_t_2; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - /* "sklearn/tree/_tree.pyx":646 + /* "sklearn/tree/_tree.pyx":648 * cdef int node_id = 0 - * for i in xrange(n): + * for i from 0 <= i < n: * node_id = 0 # <<<<<<<<<<<<<< * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":648 + /* "sklearn/tree/_tree.pyx":650 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5424,70 +5418,70 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_2_apply_tree(CYTHON_UNUSED PyObj * node_id = children[node_id, 0] */ while (1) { - __pyx_t_3 = __pyx_v_node_id; - __pyx_t_4 = 0; - __pyx_t_5 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); - if (__pyx_t_5) { - __pyx_t_6 = __pyx_v_node_id; - __pyx_t_7 = 1; - __pyx_t_8 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); - __pyx_t_9 = __pyx_t_8; + __pyx_t_2 = __pyx_v_node_id; + __pyx_t_3 = 0; + __pyx_t_4 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + if (__pyx_t_4) { + __pyx_t_5 = __pyx_v_node_id; + __pyx_t_6 = 1; + __pyx_t_7 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_children.diminfo[1].strides)) != -1); + __pyx_t_8 = __pyx_t_7; } else { - __pyx_t_9 = __pyx_t_5; + __pyx_t_8 = __pyx_t_4; } - if (!__pyx_t_9) break; + if (!__pyx_t_8) break; - /* "sklearn/tree/_tree.pyx":649 + /* "sklearn/tree/_tree.pyx":651 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< * node_id = children[node_id, 0] * else: */ - __pyx_t_10 = __pyx_v_node_id; - __pyx_t_11 = __pyx_v_i; - __pyx_t_12 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_feature.diminfo[0].strides)); - __pyx_t_13 = __pyx_v_node_id; - __pyx_t_9 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_threshold.diminfo[0].strides))); - if (__pyx_t_9) { + __pyx_t_9 = __pyx_v_node_id; + __pyx_t_10 = __pyx_v_i; + __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_feature.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_feature.diminfo[0].strides)); + __pyx_t_12 = __pyx_v_node_id; + __pyx_t_8 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_threshold.diminfo[0].strides))); + if (__pyx_t_8) { - /* "sklearn/tree/_tree.pyx":650 + /* "sklearn/tree/_tree.pyx":652 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< * else: * node_id = children[node_id, 1] */ - __pyx_t_14 = __pyx_v_node_id; - __pyx_t_15 = 0; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_t_13 = __pyx_v_node_id; + __pyx_t_14 = 0; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_children.diminfo[1].strides)); goto __pyx_L7; } /*else*/ { - /* "sklearn/tree/_tree.pyx":652 + /* "sklearn/tree/_tree.pyx":654 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< * out[i] = node_id * */ - __pyx_t_16 = __pyx_v_node_id; - __pyx_t_17 = 1; - __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_children.diminfo[1].strides)); + __pyx_t_15 = __pyx_v_node_id; + __pyx_t_16 = 1; + __pyx_v_node_id = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_children.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_children.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_children.diminfo[1].strides)); } __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":653 + /* "sklearn/tree/_tree.pyx":655 * else: * node_id = children[node_id, 1] * out[i] = node_id # <<<<<<<<<<<<<< * * */ - __pyx_t_18 = __pyx_v_i; - *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_v_node_id; + __pyx_t_17 = __pyx_v_i; + *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_out.diminfo[0].strides) = __pyx_v_node_id; } __pyx_r = Py_None; __Pyx_INCREF(Py_None); @@ -5557,35 +5551,35 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__children); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__values); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predict_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -5606,18 +5600,18 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_predict_tree", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._predict_tree", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_children), __pyx_ptype_5numpy_ndarray, 1, "children", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature), __pyx_ptype_5numpy_ndarray, 1, "feature", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_threshold), __pyx_ptype_5numpy_ndarray, 1, "threshold", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_values), __pyx_ptype_5numpy_ndarray, 1, "values", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pred), __pyx_ptype_5numpy_ndarray, 1, "pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(__pyx_self, __pyx_v_X, __pyx_v_children, __pyx_v_feature, __pyx_v_threshold, __pyx_v_values, __pyx_v_pred); goto __pyx_L0; __pyx_L1_error:; @@ -5627,7 +5621,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_5_predict_tree(PyObject *__pyx_s return __pyx_r; } -/* "sklearn/tree/_tree.pyx":656 +/* "sklearn/tree/_tree.pyx":658 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< @@ -5711,36 +5705,36 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_pybuffernd_pred.rcbuffer = &__pyx_pybuffer_pred; { __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 = 656; __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_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_children.rcbuffer->pybuffer, (PyObject*)__pyx_v_children, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_children.diminfo[0].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_children.diminfo[0].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_children.diminfo[1].strides = __pyx_pybuffernd_children.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_children.diminfo[1].shape = __pyx_pybuffernd_children.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_feature.rcbuffer->pybuffer, (PyObject*)__pyx_v_feature, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_feature.diminfo[0].strides = __pyx_pybuffernd_feature.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_feature.diminfo[0].shape = __pyx_pybuffernd_feature.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_threshold.rcbuffer->pybuffer, (PyObject*)__pyx_v_threshold, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_threshold.diminfo[0].strides = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_threshold.diminfo[0].shape = __pyx_pybuffernd_threshold.rcbuffer->pybuffer.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_values, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_values.diminfo[0].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_values.diminfo[0].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_values.diminfo[1].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_values.diminfo[1].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_values.diminfo[2].strides = __pyx_pybuffernd_values.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_values.diminfo[2].shape = __pyx_pybuffernd_values.rcbuffer->pybuffer.shape[2]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_pred.diminfo[0].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred.diminfo[0].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred.diminfo[1].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred.diminfo[1].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_pred.diminfo[2].strides = __pyx_pybuffernd_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_pred.diminfo[2].shape = __pyx_pybuffernd_pred.rcbuffer->pybuffer.shape[2]; - /* "sklearn/tree/_tree.pyx":664 + /* "sklearn/tree/_tree.pyx":666 * """Finds the terminal region (=leaf node) values for each sample. """ * cdef int i, k, c * cdef int n = X.shape[0] # <<<<<<<<<<<<<< @@ -5749,7 +5743,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_n = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":665 + /* "sklearn/tree/_tree.pyx":667 * cdef int i, k, c * cdef int n = X.shape[0] * cdef int node_id = 0 # <<<<<<<<<<<<<< @@ -5758,7 +5752,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":666 + /* "sklearn/tree/_tree.pyx":668 * cdef int n = X.shape[0] * cdef int node_id = 0 * cdef int n_outputs = values.shape[1] # <<<<<<<<<<<<<< @@ -5767,7 +5761,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_n_outputs = (__pyx_v_values->dimensions[1]); - /* "sklearn/tree/_tree.pyx":667 + /* "sklearn/tree/_tree.pyx":669 * cdef int node_id = 0 * cdef int n_outputs = values.shape[1] * cdef int n_classes = values.shape[2] # <<<<<<<<<<<<<< @@ -5776,7 +5770,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_n_classes = (__pyx_v_values->dimensions[2]); - /* "sklearn/tree/_tree.pyx":669 + /* "sklearn/tree/_tree.pyx":671 * cdef int n_classes = values.shape[2] * * for i from 0 <= i < n: # <<<<<<<<<<<<<< @@ -5786,7 +5780,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_1 = __pyx_v_n; for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - /* "sklearn/tree/_tree.pyx":670 + /* "sklearn/tree/_tree.pyx":672 * * for i from 0 <= i < n: * node_id = 0 # <<<<<<<<<<<<<< @@ -5795,7 +5789,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO */ __pyx_v_node_id = 0; - /* "sklearn/tree/_tree.pyx":672 + /* "sklearn/tree/_tree.pyx":674 * node_id = 0 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: # <<<<<<<<<<<<<< @@ -5816,7 +5810,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO } if (!__pyx_t_8) break; - /* "sklearn/tree/_tree.pyx":673 + /* "sklearn/tree/_tree.pyx":675 * # While node_id not a leaf * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: # <<<<<<<<<<<<<< @@ -5830,7 +5824,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_8 = ((*__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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_threshold.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_threshold.diminfo[0].strides))); if (__pyx_t_8) { - /* "sklearn/tree/_tree.pyx":674 + /* "sklearn/tree/_tree.pyx":676 * while children[node_id, 0] != -1 and children[node_id, 1] != -1: * if X[i, feature[node_id]] <= threshold[node_id]: * node_id = children[node_id, 0] # <<<<<<<<<<<<<< @@ -5844,7 +5838,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO } /*else*/ { - /* "sklearn/tree/_tree.pyx":676 + /* "sklearn/tree/_tree.pyx":678 * node_id = children[node_id, 0] * else: * node_id = children[node_id, 1] # <<<<<<<<<<<<<< @@ -5858,7 +5852,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_L7:; } - /* "sklearn/tree/_tree.pyx":678 + /* "sklearn/tree/_tree.pyx":680 * node_id = children[node_id, 1] * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< @@ -5868,7 +5862,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_17 = __pyx_v_n_outputs; for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_17; __pyx_v_k++) { - /* "sklearn/tree/_tree.pyx":679 + /* "sklearn/tree/_tree.pyx":681 * * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes: # <<<<<<<<<<<<<< @@ -5878,7 +5872,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_4_predict_tree(CYTHON_UNUSED PyO __pyx_t_18 = __pyx_v_n_classes; for (__pyx_v_c = 0; __pyx_v_c < __pyx_t_18; __pyx_v_c++) { - /* "sklearn/tree/_tree.pyx":680 + /* "sklearn/tree/_tree.pyx":682 * for k from 0 <= k < n_outputs: * for c from 0 <= c < n_classes: * pred[i, k, c] = values[node_id, k, c] # <<<<<<<<<<<<<< @@ -5961,23 +5955,23 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_error_at_leaf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -5990,19 +5984,19 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ __pyx_v_y = ((PyArrayObject *)values[0]); __pyx_v_sample_mask = ((PyArrayObject *)values[1]); __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[2]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_error_at_leaf", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._error_at_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(__pyx_self, __pyx_v_y, __pyx_v_sample_mask, __pyx_v_criterion, __pyx_v_n_samples); goto __pyx_L0; __pyx_L1_error:; @@ -6012,7 +6006,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_7_error_at_leaf(PyObject *__pyx_ return __pyx_r; } -/* "sklearn/tree/_tree.pyx":683 +/* "sklearn/tree/_tree.pyx":685 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< @@ -6040,11 +6034,11 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":689 + /* "sklearn/tree/_tree.pyx":691 * """Compute criterion error at leaf with terminal region defined * by `sample_mask`. """ * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -6053,7 +6047,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":690 + /* "sklearn/tree/_tree.pyx":692 * by `sample_mask`. """ * cdef DTYPE_t* y_ptr = y.data * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -6062,7 +6056,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":691 + /* "sklearn/tree/_tree.pyx":693 * cdef DTYPE_t* y_ptr = y.data * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int n_total_samples = y.shape[0] # <<<<<<<<<<<<<< @@ -6071,7 +6065,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_n_total_samples = (__pyx_v_y->dimensions[0]); - /* "sklearn/tree/_tree.pyx":692 + /* "sklearn/tree/_tree.pyx":694 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int n_total_samples = y.shape[0] * cdef BOOL_t *sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -6080,7 +6074,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":694 + /* "sklearn/tree/_tree.pyx":696 * cdef BOOL_t *sample_mask_ptr = sample_mask.data * * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -6089,7 +6083,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":696 + /* "sklearn/tree/_tree.pyx":698 * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * * return criterion.eval() # <<<<<<<<<<<<<< @@ -6097,7 +6091,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6122,7 +6116,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_6_error_at_leaf(CYTHON_UNUSED Py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":699 +/* "sklearn/tree/_tree.pyx":701 * * * cdef int smallest_sample_larger_than(int sample_idx, DTYPE_t *X_i, # <<<<<<<<<<<<<< @@ -6140,7 +6134,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v int __pyx_t_2; __Pyx_RefNannySetupContext("smallest_sample_larger_than", 0); - /* "sklearn/tree/_tree.pyx":716 + /* "sklearn/tree/_tree.pyx":718 * -1 if no such element exists. * """ * cdef int idx = 0, j # <<<<<<<<<<<<<< @@ -6149,7 +6143,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_idx = 0; - /* "sklearn/tree/_tree.pyx":717 + /* "sklearn/tree/_tree.pyx":719 * """ * cdef int idx = 0, j * cdef DTYPE_t threshold = -DBL_MAX # <<<<<<<<<<<<<< @@ -6158,7 +6152,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_threshold = (-DBL_MAX); - /* "sklearn/tree/_tree.pyx":719 + /* "sklearn/tree/_tree.pyx":721 * cdef DTYPE_t threshold = -DBL_MAX * * if sample_idx > -1: # <<<<<<<<<<<<<< @@ -6168,7 +6162,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = (__pyx_v_sample_idx > -1); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":720 + /* "sklearn/tree/_tree.pyx":722 * * if sample_idx > -1: * threshold = X_i[X_argsorted_i[sample_idx]] # <<<<<<<<<<<<<< @@ -6180,7 +6174,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":722 + /* "sklearn/tree/_tree.pyx":724 * threshold = X_i[X_argsorted_i[sample_idx]] * * for idx from sample_idx < idx < n_total_samples: # <<<<<<<<<<<<<< @@ -6190,7 +6184,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_2 = __pyx_v_n_total_samples; for (__pyx_v_idx = __pyx_v_sample_idx+1; __pyx_v_idx < __pyx_t_2; __pyx_v_idx++) { - /* "sklearn/tree/_tree.pyx":723 + /* "sklearn/tree/_tree.pyx":725 * * for idx from sample_idx < idx < n_total_samples: * j = X_argsorted_i[idx] # <<<<<<<<<<<<<< @@ -6199,7 +6193,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v */ __pyx_v_j = (__pyx_v_X_argsorted_i[__pyx_v_idx]); - /* "sklearn/tree/_tree.pyx":725 + /* "sklearn/tree/_tree.pyx":727 * j = X_argsorted_i[idx] * * if sample_mask[j] == 0: # <<<<<<<<<<<<<< @@ -6209,7 +6203,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_sample_mask[__pyx_v_j]) == 0); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":726 + /* "sklearn/tree/_tree.pyx":728 * * if sample_mask[j] == 0: * continue # <<<<<<<<<<<<<< @@ -6221,7 +6215,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v } __pyx_L6:; - /* "sklearn/tree/_tree.pyx":728 + /* "sklearn/tree/_tree.pyx":730 * continue * * if X_i[j] > threshold + 1.e-7: # <<<<<<<<<<<<<< @@ -6231,7 +6225,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_t_1 = ((__pyx_v_X_i[__pyx_v_j]) > (__pyx_v_threshold + 1.e-7)); if (__pyx_t_1) { - /* "sklearn/tree/_tree.pyx":729 + /* "sklearn/tree/_tree.pyx":731 * * if X_i[j] > threshold + 1.e-7: * return idx # <<<<<<<<<<<<<< @@ -6246,7 +6240,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int __pyx_v __pyx_L4_continue:; } - /* "sklearn/tree/_tree.pyx":731 + /* "sklearn/tree/_tree.pyx":733 * return idx * * return -1 # <<<<<<<<<<<<<< @@ -6309,53 +6303,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -6374,25 +6368,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -6402,7 +6396,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_9_find_best_split(PyObject *__py return __pyx_r; } -/* "sklearn/tree/_tree.pyx":734 +/* "sklearn/tree/_tree.pyx":736 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< @@ -6446,21 +6440,20 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __Pyx_Buffer __pyx_pybuffer_y; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; - PyArrayObject *__pyx_t_4 = NULL; - int __pyx_t_5; + PyArrayObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; + int __pyx_t_12; int __pyx_t_13; - int __pyx_t_14; - __pyx_t_5numpy_int32_t __pyx_t_15; + __pyx_t_5numpy_int32_t __pyx_t_14; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -6483,21 +6476,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":793 + /* "sklearn/tree/_tree.pyx":795 * """ * # Variables declarations * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -6506,7 +6499,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":794 + /* "sklearn/tree/_tree.pyx":796 * # Variables declarations * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -6515,7 +6508,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":795 + /* "sklearn/tree/_tree.pyx":797 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 # <<<<<<<<<<<<<< @@ -6524,7 +6517,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":796 + /* "sklearn/tree/_tree.pyx":798 * cdef int n_features = X.shape[1] * cdef int i, a, b, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< @@ -6533,50 +6526,36 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":797 + /* "sklearn/tree/_tree.pyx":799 * cdef int i, a, b, best_i = -1 * cdef np.int32_t feature_idx = -1 * cdef int n_left = 0 # <<<<<<<<<<<<<< * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + * cdef DTYPE_t best_error = inf, best_t = inf */ __pyx_v_n_left = 0; - /* "sklearn/tree/_tree.pyx":799 + /* "sklearn/tree/_tree.pyx":801 * cdef int n_left = 0 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< + * cdef DTYPE_t best_error = inf, best_t = inf # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_best_t = __pyx_t_3; + __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_inf; + __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_inf; - /* "sklearn/tree/_tree.pyx":800 + /* "sklearn/tree/_tree.pyx":802 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + * cdef DTYPE_t best_error = inf, best_t = inf * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":801 - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + /* "sklearn/tree/_tree.pyx":803 + * cdef DTYPE_t best_error = inf, best_t = inf * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< * cdef DTYPE_t* y_ptr = y.data @@ -6584,7 +6563,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":802 + /* "sklearn/tree/_tree.pyx":804 * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -6593,7 +6572,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":803 + /* "sklearn/tree/_tree.pyx":805 * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -6602,27 +6581,27 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":804 + /* "sklearn/tree/_tree.pyx":806 * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< * * # Compute the column strides (increment in pointer elements to get */ - __pyx_t_4 = ((PyArrayObject *)Py_None); + __pyx_t_1 = ((PyArrayObject *)Py_None); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } - __pyx_t_4 = 0; + __pyx_t_1 = 0; __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":808 + /* "sklearn/tree/_tree.pyx":810 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -6631,7 +6610,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":809 + /* "sklearn/tree/_tree.pyx":811 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -6640,7 +6619,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":810 + /* "sklearn/tree/_tree.pyx":812 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -6649,7 +6628,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":811 + /* "sklearn/tree/_tree.pyx":813 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -6658,7 +6637,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":812 + /* "sklearn/tree/_tree.pyx":814 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -6667,7 +6646,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":813 + /* "sklearn/tree/_tree.pyx":815 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -6676,7 +6655,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":814 + /* "sklearn/tree/_tree.pyx":816 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -6685,7 +6664,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":817 + /* "sklearn/tree/_tree.pyx":819 * * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -6694,7 +6673,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":818 + /* "sklearn/tree/_tree.pyx":820 * # Compute the initial criterion value in the node * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -6703,7 +6682,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":819 + /* "sklearn/tree/_tree.pyx":821 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -6712,17 +6691,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":821 + /* "sklearn/tree/_tree.pyx":823 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< * return best_i, best_t, initial_error, initial_error * */ - __pyx_t_5 = (__pyx_v_initial_error == 0.0); - if (__pyx_t_5) { + __pyx_t_2 = (__pyx_v_initial_error == 0.0); + if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":822 + /* "sklearn/tree/_tree.pyx":824 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, initial_error, initial_error # <<<<<<<<<<<<<< @@ -6730,36 +6709,36 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; __pyx_t_6 = 0; + __pyx_r = ((PyObject *)__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = ((PyObject *)__pyx_t_8); - __pyx_t_8 = 0; goto __pyx_L0; goto __pyx_L3; } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":824 + /* "sklearn/tree/_tree.pyx":826 * return best_i, best_t, initial_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -6768,79 +6747,79 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":827 + /* "sklearn/tree/_tree.pyx":829 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__arange); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); + __pyx_t_7 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 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 = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_t_3); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_9 < 0)) { - PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); + Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); + PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11); } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_features)); - __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_features)); + __pyx_v_features = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; - /* "sklearn/tree/_tree.pyx":828 + /* "sklearn/tree/_tree.pyx":830 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< * max_features = n_features * else: */ - __pyx_t_5 = (__pyx_v_max_features < 0); - if (!__pyx_t_5) { - __pyx_t_13 = (__pyx_v_max_features >= __pyx_v_n_features); - __pyx_t_14 = __pyx_t_13; + __pyx_t_2 = (__pyx_v_max_features < 0); + if (!__pyx_t_2) { + __pyx_t_12 = (__pyx_v_max_features >= __pyx_v_n_features); + __pyx_t_13 = __pyx_t_12; } else { - __pyx_t_14 = __pyx_t_5; + __pyx_t_13 = __pyx_t_2; } - if (__pyx_t_14) { + if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":829 + /* "sklearn/tree/_tree.pyx":831 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -6852,73 +6831,73 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } /*else*/ { - /* "sklearn/tree/_tree.pyx":831 + /* "sklearn/tree/_tree.pyx":833 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(((PyObject *)__pyx_v_features)); - PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __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_7)); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_5, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__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 = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_t_7); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_9 < 0)) { - PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10); + PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9); } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = 0; + __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); - __pyx_v_features = ((PyArrayObject *)__pyx_t_8); - __pyx_t_8 = 0; + __pyx_v_features = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":834 + /* "sklearn/tree/_tree.pyx":836 * * # Look for the best split * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< * i = features[feature_idx] * # Get i-th col of X and X_sorted */ - __pyx_t_9 = __pyx_v_max_features; - for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { + __pyx_t_8 = __pyx_v_max_features; + for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_8; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":835 + /* "sklearn/tree/_tree.pyx":837 * # Look for the best split * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i */ - __pyx_t_15 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_t_14 = __pyx_v_feature_idx; + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":837 + /* "sklearn/tree/_tree.pyx":839 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -6927,7 +6906,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":838 + /* "sklearn/tree/_tree.pyx":840 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -6936,7 +6915,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":841 + /* "sklearn/tree/_tree.pyx":843 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -6945,7 +6924,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":844 + /* "sklearn/tree/_tree.pyx":846 * * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 # <<<<<<<<<<<<<< @@ -6954,7 +6933,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":845 + /* "sklearn/tree/_tree.pyx":847 * # Index of smallest sample in X_argsorted_i that is in the sample mask * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -6962,10 +6941,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * */ while (1) { - __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); - if (!__pyx_t_14) break; + __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); + if (!__pyx_t_13) break; - /* "sklearn/tree/_tree.pyx":846 + /* "sklearn/tree/_tree.pyx":848 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -6975,7 +6954,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":849 + /* "sklearn/tree/_tree.pyx":851 * * # Consider splits between two consecutive samples * while True: # <<<<<<<<<<<<<< @@ -6985,7 +6964,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":852 + /* "sklearn/tree/_tree.pyx":854 * # Find the following larger sample * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) # <<<<<<<<<<<<<< @@ -6994,17 +6973,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_b = __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(__pyx_v_a, __pyx_v_X_i, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":853 + /* "sklearn/tree/_tree.pyx":855 * b = smallest_sample_larger_than(a, X_i, X_argsorted_i, * sample_mask_ptr, n_total_samples) * if b == -1: # <<<<<<<<<<<<<< * break * */ - __pyx_t_14 = (__pyx_v_b == -1); - if (__pyx_t_14) { + __pyx_t_13 = (__pyx_v_b == -1); + if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":854 + /* "sklearn/tree/_tree.pyx":856 * sample_mask_ptr, n_total_samples) * if b == -1: * break # <<<<<<<<<<<<<< @@ -7016,7 +6995,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":857 + /* "sklearn/tree/_tree.pyx":859 * * # Better split than the best so far? * n_left = criterion.update(a, b, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -7025,23 +7004,23 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, __pyx_v_a, __pyx_v_b, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":860 + /* "sklearn/tree/_tree.pyx":862 * * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< * a = b * continue */ - __pyx_t_14 = (__pyx_v_n_left < __pyx_v_min_leaf); - if (!__pyx_t_14) { - __pyx_t_5 = ((__pyx_v_n_samples - __pyx_v_n_left) < __pyx_v_min_leaf); - __pyx_t_13 = __pyx_t_5; + __pyx_t_13 = (__pyx_v_n_left < __pyx_v_min_leaf); + if (!__pyx_t_13) { + __pyx_t_2 = ((__pyx_v_n_samples - __pyx_v_n_left) < __pyx_v_min_leaf); + __pyx_t_12 = __pyx_t_2; } else { - __pyx_t_13 = __pyx_t_14; + __pyx_t_12 = __pyx_t_13; } - if (__pyx_t_13) { + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":861 + /* "sklearn/tree/_tree.pyx":863 * # Only consider splits that respect min_leaf * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b # <<<<<<<<<<<<<< @@ -7050,7 +7029,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_a = __pyx_v_b; - /* "sklearn/tree/_tree.pyx":862 + /* "sklearn/tree/_tree.pyx":864 * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * a = b * continue # <<<<<<<<<<<<<< @@ -7062,7 +7041,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":864 + /* "sklearn/tree/_tree.pyx":866 * continue * * error = criterion.eval() # <<<<<<<<<<<<<< @@ -7071,17 +7050,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":866 + /* "sklearn/tree/_tree.pyx":868 * error = criterion.eval() * * if error < best_error: # <<<<<<<<<<<<<< * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) */ - __pyx_t_13 = (__pyx_v_error < __pyx_v_best_error); - if (__pyx_t_13) { + __pyx_t_12 = (__pyx_v_error < __pyx_v_best_error); + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":868 + /* "sklearn/tree/_tree.pyx":870 * if error < best_error: * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) # <<<<<<<<<<<<<< @@ -7090,17 +7069,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_t = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) + (((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])) / 2.0)); - /* "sklearn/tree/_tree.pyx":869 + /* "sklearn/tree/_tree.pyx":871 * t = X_i[X_argsorted_i[a]] + \ * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< * t = X_i[X_argsorted_i[a]] * best_i = i */ - __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); - if (__pyx_t_13) { + __pyx_t_12 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":870 + /* "sklearn/tree/_tree.pyx":872 * ((X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]]) / 2.0) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -7112,7 +7091,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L14:; - /* "sklearn/tree/_tree.pyx":871 + /* "sklearn/tree/_tree.pyx":873 * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] * best_i = i # <<<<<<<<<<<<<< @@ -7121,7 +7100,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":872 + /* "sklearn/tree/_tree.pyx":874 * t = X_i[X_argsorted_i[a]] * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -7130,7 +7109,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":873 + /* "sklearn/tree/_tree.pyx":875 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -7142,7 +7121,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED } __pyx_L13:; - /* "sklearn/tree/_tree.pyx":876 + /* "sklearn/tree/_tree.pyx":878 * * # Proceed to the next interval * a = b # <<<<<<<<<<<<<< @@ -7155,7 +7134,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_L10_break:; } - /* "sklearn/tree/_tree.pyx":878 + /* "sklearn/tree/_tree.pyx":880 * a = b * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -7163,40 +7142,40 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_7); + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_8 = 0; - __pyx_t_6 = 0; - __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); __pyx_t_7 = 0; - __pyx_r = ((PyObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_5 = 0; + __pyx_t_3 = 0; + __pyx_t_6 = 0; + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); @@ -7266,53 +7245,53 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X_argsorted); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_mask); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_samples); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_leaf); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_features); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__criterion); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__random_state); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_best_random_split") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; @@ -7331,25 +7310,25 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje __pyx_v_y = ((PyArrayObject *)values[1]); __pyx_v_X_argsorted = ((PyArrayObject *)values[2]); __pyx_v_sample_mask = ((PyArrayObject *)values[3]); - __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n_samples = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_n_samples == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_min_leaf = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_min_leaf == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_max_features = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_max_features == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_criterion = ((struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *)values[7]); __pyx_v_random_state = values[8]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_find_best_random_split", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("sklearn.tree._tree._find_best_random_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X), __pyx_ptype_5numpy_ndarray, 1, "X", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_X_argsorted), __pyx_ptype_5numpy_ndarray, 1, "X_argsorted", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sample_mask), __pyx_ptype_5numpy_ndarray, 1, "sample_mask", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_criterion), __pyx_ptype_7sklearn_4tree_5_tree_Criterion, 1, "criterion", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_X_argsorted, __pyx_v_sample_mask, __pyx_v_n_samples, __pyx_v_min_leaf, __pyx_v_max_features, __pyx_v_criterion, __pyx_v_random_state); goto __pyx_L0; __pyx_L1_error:; @@ -7359,7 +7338,7 @@ static PyObject *__pyx_pw_7sklearn_4tree_5_tree_11_find_best_random_split(PyObje return __pyx_r; } -/* "sklearn/tree/_tree.pyx":880 +/* "sklearn/tree/_tree.pyx":882 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< @@ -7404,21 +7383,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __Pyx_Buffer __pyx_pybuffer_y; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; - PyArrayObject *__pyx_t_4 = NULL; - int __pyx_t_5; + PyArrayObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; + int __pyx_t_12; int __pyx_t_13; - int __pyx_t_14; - __pyx_t_5numpy_int32_t __pyx_t_15; + __pyx_t_5numpy_int32_t __pyx_t_14; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_15; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -7441,21 +7420,21 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_pybuffernd_X_argsorted.rcbuffer = &__pyx_pybuffer_X_argsorted; { __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __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_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __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]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__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 = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_y.diminfo[1].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_y.diminfo[1].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer, (PyObject*)__pyx_v_X_argsorted, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_X_argsorted.diminfo[0].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X_argsorted.diminfo[0].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_X_argsorted.diminfo[1].strides = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_X_argsorted.diminfo[1].shape = __pyx_pybuffernd_X_argsorted.rcbuffer->pybuffer.shape[1]; - /* "sklearn/tree/_tree.pyx":939 + /* "sklearn/tree/_tree.pyx":941 * """ * # Variables * cdef int n_total_samples = X.shape[0] # <<<<<<<<<<<<<< @@ -7464,7 +7443,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_total_samples = (__pyx_v_X->dimensions[0]); - /* "sklearn/tree/_tree.pyx":940 + /* "sklearn/tree/_tree.pyx":942 * # Variables * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] # <<<<<<<<<<<<<< @@ -7473,7 +7452,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_features = (__pyx_v_X->dimensions[1]); - /* "sklearn/tree/_tree.pyx":941 + /* "sklearn/tree/_tree.pyx":943 * cdef int n_total_samples = X.shape[0] * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 # <<<<<<<<<<<<<< @@ -7482,50 +7461,36 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = -1; - /* "sklearn/tree/_tree.pyx":942 + /* "sklearn/tree/_tree.pyx":944 * cdef int n_features = X.shape[1] * cdef int i, a, b, c, n_left, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + * cdef DTYPE_t best_error = inf, best_t = inf */ __pyx_v_feature_idx = -1; - /* "sklearn/tree/_tree.pyx":944 + /* "sklearn/tree/_tree.pyx":946 * cdef np.int32_t feature_idx = -1 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf # <<<<<<<<<<<<<< + * cdef DTYPE_t best_error = inf, best_t = inf # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_best_error = __pyx_t_3; - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_best_t = __pyx_t_3; + __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_inf; + __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_inf; - /* "sklearn/tree/_tree.pyx":945 + /* "sklearn/tree/_tree.pyx":947 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + * cdef DTYPE_t best_error = inf, best_t = inf * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data */ __pyx_v_X_i = NULL; - /* "sklearn/tree/_tree.pyx":946 - * cdef DTYPE_t best_error = np.inf, best_t = np.inf + /* "sklearn/tree/_tree.pyx":948 + * cdef DTYPE_t best_error = inf, best_t = inf * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< * cdef DTYPE_t* y_ptr = y.data @@ -7533,7 +7498,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = NULL; - /* "sklearn/tree/_tree.pyx":947 + /* "sklearn/tree/_tree.pyx":949 * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data # <<<<<<<<<<<<<< @@ -7542,7 +7507,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_y_ptr = ((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_y->data); - /* "sklearn/tree/_tree.pyx":948 + /* "sklearn/tree/_tree.pyx":950 * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data # <<<<<<<<<<<<<< @@ -7551,27 +7516,27 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_sample_mask_ptr = ((__pyx_t_7sklearn_4tree_5_tree_BOOL_t *)__pyx_v_sample_mask->data); - /* "sklearn/tree/_tree.pyx":949 + /* "sklearn/tree/_tree.pyx":951 * cdef DTYPE_t* y_ptr = y.data * cdef BOOL_t* sample_mask_ptr = sample_mask.data * cdef np.ndarray[np.int32_t, ndim=1, mode="c"] features = None # <<<<<<<<<<<<<< * * # Compute the column strides (increment in pointer elements to get */ - __pyx_t_4 = ((PyArrayObject *)Py_None); + __pyx_t_1 = ((PyArrayObject *)Py_None); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { __pyx_v_features = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_features.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; } } - __pyx_t_4 = 0; + __pyx_t_1 = 0; __Pyx_INCREF(Py_None); __pyx_v_features = ((PyArrayObject *)Py_None); - /* "sklearn/tree/_tree.pyx":953 + /* "sklearn/tree/_tree.pyx":955 * # Compute the column strides (increment in pointer elements to get * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] # <<<<<<<<<<<<<< @@ -7580,7 +7545,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_y_stride = (((int)(__pyx_v_y->strides[0])) / ((int)(__pyx_v_y->strides[1]))); - /* "sklearn/tree/_tree.pyx":954 + /* "sklearn/tree/_tree.pyx":956 * # from column i to i + 1) for `X` and `X_argsorted` * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] # <<<<<<<<<<<<<< @@ -7589,7 +7554,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_elem_stride = (__pyx_v_X->strides[0]); - /* "sklearn/tree/_tree.pyx":955 + /* "sklearn/tree/_tree.pyx":957 * cdef int y_stride = y.strides[0] / y.strides[1] * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] # <<<<<<<<<<<<<< @@ -7598,7 +7563,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_col_stride = (__pyx_v_X->strides[1]); - /* "sklearn/tree/_tree.pyx":956 + /* "sklearn/tree/_tree.pyx":958 * cdef int X_elem_stride = X.strides[0] * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride # <<<<<<<<<<<<<< @@ -7607,7 +7572,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_stride = (__pyx_v_X_col_stride / __pyx_v_X_elem_stride); - /* "sklearn/tree/_tree.pyx":957 + /* "sklearn/tree/_tree.pyx":959 * cdef int X_col_stride = X.strides[1] * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] # <<<<<<<<<<<<<< @@ -7616,7 +7581,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_elem_stride = (__pyx_v_X_argsorted->strides[0]); - /* "sklearn/tree/_tree.pyx":958 + /* "sklearn/tree/_tree.pyx":960 * cdef int X_stride = X_col_stride / X_elem_stride * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] # <<<<<<<<<<<<<< @@ -7625,7 +7590,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_col_stride = (__pyx_v_X_argsorted->strides[1]); - /* "sklearn/tree/_tree.pyx":959 + /* "sklearn/tree/_tree.pyx":961 * cdef int X_argsorted_elem_stride = X_argsorted.strides[0] * cdef int X_argsorted_col_stride = X_argsorted.strides[1] * cdef int X_argsorted_stride = X_argsorted_col_stride / X_argsorted_elem_stride # <<<<<<<<<<<<<< @@ -7634,7 +7599,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_stride = (__pyx_v_X_argsorted_col_stride / __pyx_v_X_argsorted_elem_stride); - /* "sklearn/tree/_tree.pyx":962 + /* "sklearn/tree/_tree.pyx":964 * * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data # <<<<<<<<<<<<<< @@ -7643,7 +7608,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = ((int *)__pyx_v_X_argsorted->data); - /* "sklearn/tree/_tree.pyx":963 + /* "sklearn/tree/_tree.pyx":965 * # Compute the initial criterion value * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) # <<<<<<<<<<<<<< @@ -7652,7 +7617,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->init(__pyx_v_criterion, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_sample_mask_ptr, __pyx_v_n_samples, __pyx_v_n_total_samples); - /* "sklearn/tree/_tree.pyx":964 + /* "sklearn/tree/_tree.pyx":966 * X_argsorted_i = X_argsorted.data * criterion.init(y_ptr, y_stride, sample_mask_ptr, n_samples, n_total_samples) * initial_error = criterion.eval() # <<<<<<<<<<<<<< @@ -7661,17 +7626,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_initial_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":966 + /* "sklearn/tree/_tree.pyx":968 * initial_error = criterion.eval() * * if initial_error == 0: # break early if the node is pure # <<<<<<<<<<<<<< * return best_i, best_t, best_error, initial_error * */ - __pyx_t_5 = (__pyx_v_initial_error == 0.0); - if (__pyx_t_5) { + __pyx_t_2 = (__pyx_v_initial_error == 0.0); + if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":967 + /* "sklearn/tree/_tree.pyx":969 * * if initial_error == 0: # break early if the node is pure * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< @@ -7679,36 +7644,36 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * best_error = initial_error */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_1 = 0; - __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; __pyx_t_6 = 0; + __pyx_r = ((PyObject *)__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = ((PyObject *)__pyx_t_8); - __pyx_t_8 = 0; goto __pyx_L0; goto __pyx_L3; } __pyx_L3:; - /* "sklearn/tree/_tree.pyx":969 + /* "sklearn/tree/_tree.pyx":971 * return best_i, best_t, best_error, initial_error * * best_error = initial_error # <<<<<<<<<<<<<< @@ -7717,79 +7682,79 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_error = __pyx_v_initial_error; - /* "sklearn/tree/_tree.pyx":972 + /* "sklearn/tree/_tree.pyx":974 * * # Features to consider * features = np.arange(n_features, dtype=np.int32) # <<<<<<<<<<<<<< * if max_features < 0 or max_features >= n_features: * max_features = n_features */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__arange); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_8)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); + __pyx_t_7 = PyInt_FromLong(__pyx_v_n_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_7)); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 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 = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_t_3); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_9 < 0)) { - PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); + Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); + PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11); } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_features)); - __pyx_v_features = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_features)); + __pyx_v_features = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; - /* "sklearn/tree/_tree.pyx":973 + /* "sklearn/tree/_tree.pyx":975 * # Features to consider * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: # <<<<<<<<<<<<<< * max_features = n_features * else: */ - __pyx_t_5 = (__pyx_v_max_features < 0); - if (!__pyx_t_5) { - __pyx_t_13 = (__pyx_v_max_features >= __pyx_v_n_features); - __pyx_t_14 = __pyx_t_13; + __pyx_t_2 = (__pyx_v_max_features < 0); + if (!__pyx_t_2) { + __pyx_t_12 = (__pyx_v_max_features >= __pyx_v_n_features); + __pyx_t_13 = __pyx_t_12; } else { - __pyx_t_14 = __pyx_t_5; + __pyx_t_13 = __pyx_t_2; } - if (__pyx_t_14) { + if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":974 + /* "sklearn/tree/_tree.pyx":976 * features = np.arange(n_features, dtype=np.int32) * if max_features < 0 or max_features >= n_features: * max_features = n_features # <<<<<<<<<<<<<< @@ -7801,73 +7766,73 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } /*else*/ { - /* "sklearn/tree/_tree.pyx":976 + /* "sklearn/tree/_tree.pyx":978 * max_features = n_features * else: * features = random_state.permutation(features)[:max_features] # <<<<<<<<<<<<<< * * # Look for the best random split */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__permutation); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(((PyObject *)__pyx_v_features)); - PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_features)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_features)); __Pyx_GIVEREF(((PyObject *)__pyx_v_features)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_t_6, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = ((PyArrayObject *)__pyx_t_8); + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __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_7)); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_t_5, 0, __pyx_v_max_features); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__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 = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyArrayObject *)__pyx_t_7); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer); - __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_9 < 0)) { - PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10); + __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_1, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_8 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10); + PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9); } } __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = 0; + __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_features)); - __pyx_v_features = ((PyArrayObject *)__pyx_t_8); - __pyx_t_8 = 0; + __pyx_v_features = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; } __pyx_L4:; - /* "sklearn/tree/_tree.pyx":979 + /* "sklearn/tree/_tree.pyx":981 * * # Look for the best random split * for feature_idx from 0 <= feature_idx < max_features: # <<<<<<<<<<<<<< * i = features[feature_idx] * # Get i-th col of X and X_sorted */ - __pyx_t_9 = __pyx_v_max_features; - for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_9; __pyx_v_feature_idx++) { + __pyx_t_8 = __pyx_v_max_features; + for (__pyx_v_feature_idx = 0; __pyx_v_feature_idx < __pyx_t_8; __pyx_v_feature_idx++) { - /* "sklearn/tree/_tree.pyx":980 + /* "sklearn/tree/_tree.pyx":982 * # Look for the best random split * for feature_idx from 0 <= feature_idx < max_features: * i = features[feature_idx] # <<<<<<<<<<<<<< * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i */ - __pyx_t_15 = __pyx_v_feature_idx; - __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_features.diminfo[0].strides)); + __pyx_t_14 = __pyx_v_feature_idx; + __pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5numpy_int32_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_features.diminfo[0].strides)); - /* "sklearn/tree/_tree.pyx":982 + /* "sklearn/tree/_tree.pyx":984 * i = features[feature_idx] * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i # <<<<<<<<<<<<<< @@ -7876,7 +7841,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_i = (((__pyx_t_7sklearn_4tree_5_tree_DTYPE_t *)__pyx_v_X->data) + (__pyx_v_X_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":983 + /* "sklearn/tree/_tree.pyx":985 * # Get i-th col of X and X_sorted * X_i = (X.data) + X_stride * i * X_argsorted_i = (X_argsorted.data) + X_argsorted_stride * i # <<<<<<<<<<<<<< @@ -7885,7 +7850,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_X_argsorted_i = (((int *)__pyx_v_X_argsorted->data) + (__pyx_v_X_argsorted_stride * __pyx_v_i)); - /* "sklearn/tree/_tree.pyx":986 + /* "sklearn/tree/_tree.pyx":988 * * # Reset the criterion for this feature * criterion.reset() # <<<<<<<<<<<<<< @@ -7894,7 +7859,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->reset(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":989 + /* "sklearn/tree/_tree.pyx":991 * * # Find min and max * a = 0 # <<<<<<<<<<<<<< @@ -7903,7 +7868,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_a = 0; - /* "sklearn/tree/_tree.pyx":990 + /* "sklearn/tree/_tree.pyx":992 * # Find min and max * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: # <<<<<<<<<<<<<< @@ -7911,10 +7876,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * */ while (1) { - __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); - if (!__pyx_t_14) break; + __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == 0); + if (!__pyx_t_13) break; - /* "sklearn/tree/_tree.pyx":991 + /* "sklearn/tree/_tree.pyx":993 * a = 0 * while sample_mask_ptr[X_argsorted_i[a]] == 0: * a = a + 1 # <<<<<<<<<<<<<< @@ -7924,7 +7889,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_a = (__pyx_v_a + 1); } - /* "sklearn/tree/_tree.pyx":993 + /* "sklearn/tree/_tree.pyx":995 * a = a + 1 * * b = n_total_samples - 1 # <<<<<<<<<<<<<< @@ -7933,7 +7898,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_b = (__pyx_v_n_total_samples - 1); - /* "sklearn/tree/_tree.pyx":994 + /* "sklearn/tree/_tree.pyx":996 * * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: # <<<<<<<<<<<<<< @@ -7941,10 +7906,10 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * */ while (1) { - __pyx_t_14 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_b])]) == 0); - if (!__pyx_t_14) break; + __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_b])]) == 0); + if (!__pyx_t_13) break; - /* "sklearn/tree/_tree.pyx":995 + /* "sklearn/tree/_tree.pyx":997 * b = n_total_samples - 1 * while sample_mask_ptr[X_argsorted_i[b]] == 0: * b = b - 1 # <<<<<<<<<<<<<< @@ -7954,23 +7919,23 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_b = (__pyx_v_b - 1); } - /* "sklearn/tree/_tree.pyx":997 + /* "sklearn/tree/_tree.pyx":999 * b = b - 1 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< * continue * */ - __pyx_t_14 = (__pyx_v_b <= __pyx_v_a); - if (!__pyx_t_14) { - __pyx_t_5 = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); - __pyx_t_13 = __pyx_t_5; + __pyx_t_13 = (__pyx_v_b <= __pyx_v_a); + if (!__pyx_t_13) { + __pyx_t_2 = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]) == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); + __pyx_t_12 = __pyx_t_2; } else { - __pyx_t_13 = __pyx_t_14; + __pyx_t_12 = __pyx_t_13; } - if (__pyx_t_13) { + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":998 + /* "sklearn/tree/_tree.pyx":1000 * * if b <= a or X_i[X_argsorted_i[a]] == X_i[X_argsorted_i[b]]: * continue # <<<<<<<<<<<<<< @@ -7982,53 +7947,53 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L11:; - /* "sklearn/tree/_tree.pyx":1001 + /* "sklearn/tree/_tree.pyx":1003 * * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * # <<<<<<<<<<<<<< * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: */ - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_7 = PyFloat_FromDouble((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyObject_GetAttr(__pyx_v_random_state, __pyx_n_s__rand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "sklearn/tree/_tree.pyx":1002 + /* "sklearn/tree/_tree.pyx":1004 * # Draw a random threshold in [a, b) * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) # <<<<<<<<<<<<<< * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] */ - __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])]) - (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_a])]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_t = __pyx_t_3; + __pyx_t_15 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_15 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_t = __pyx_t_15; - /* "sklearn/tree/_tree.pyx":1003 + /* "sklearn/tree/_tree.pyx":1005 * t = X_i[X_argsorted_i[a]] + (random_state.rand() * * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: # <<<<<<<<<<<<<< * t = X_i[X_argsorted_i[a]] * */ - __pyx_t_13 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); - if (__pyx_t_13) { + __pyx_t_12 = (__pyx_v_t == (__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_b])])); + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":1004 + /* "sklearn/tree/_tree.pyx":1006 * (X_i[X_argsorted_i[b]] - X_i[X_argsorted_i[a]])) * if t == X_i[X_argsorted_i[b]]: * t = X_i[X_argsorted_i[a]] # <<<<<<<<<<<<<< @@ -8040,7 +8005,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L12:; - /* "sklearn/tree/_tree.pyx":1007 + /* "sklearn/tree/_tree.pyx":1009 * * # Find the sample just greater than t * c = a + 1 # <<<<<<<<<<<<<< @@ -8049,7 +8014,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_c = (__pyx_v_a + 1); - /* "sklearn/tree/_tree.pyx":1009 + /* "sklearn/tree/_tree.pyx":1011 * c = a + 1 * * while True: # <<<<<<<<<<<<<< @@ -8059,33 +8024,33 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON while (1) { if (!1) break; - /* "sklearn/tree/_tree.pyx":1010 + /* "sklearn/tree/_tree.pyx":1012 * * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: # <<<<<<<<<<<<<< * if X_i[X_argsorted_i[c]] > t or c == b: * break */ - __pyx_t_13 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_c])]) != 0); - if (__pyx_t_13) { + __pyx_t_12 = ((__pyx_v_sample_mask_ptr[(__pyx_v_X_argsorted_i[__pyx_v_c])]) != 0); + if (__pyx_t_12) { - /* "sklearn/tree/_tree.pyx":1011 + /* "sklearn/tree/_tree.pyx":1013 * while True: * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: # <<<<<<<<<<<<<< * break * */ - __pyx_t_13 = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_c])]) > __pyx_v_t); - if (!__pyx_t_13) { - __pyx_t_14 = (__pyx_v_c == __pyx_v_b); - __pyx_t_5 = __pyx_t_14; + __pyx_t_12 = ((__pyx_v_X_i[(__pyx_v_X_argsorted_i[__pyx_v_c])]) > __pyx_v_t); + if (!__pyx_t_12) { + __pyx_t_13 = (__pyx_v_c == __pyx_v_b); + __pyx_t_2 = __pyx_t_13; } else { - __pyx_t_5 = __pyx_t_13; + __pyx_t_2 = __pyx_t_12; } - if (__pyx_t_5) { + if (__pyx_t_2) { - /* "sklearn/tree/_tree.pyx":1012 + /* "sklearn/tree/_tree.pyx":1014 * if sample_mask_ptr[X_argsorted_i[c]] != 0: * if X_i[X_argsorted_i[c]] > t or c == b: * break # <<<<<<<<<<<<<< @@ -8100,7 +8065,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L15:; - /* "sklearn/tree/_tree.pyx":1014 + /* "sklearn/tree/_tree.pyx":1016 * break * * c += 1 # <<<<<<<<<<<<<< @@ -8111,7 +8076,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L14_break:; - /* "sklearn/tree/_tree.pyx":1017 + /* "sklearn/tree/_tree.pyx":1019 * * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) # <<<<<<<<<<<<<< @@ -8120,7 +8085,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_n_left = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->update(__pyx_v_criterion, 0, __pyx_v_c, __pyx_v_y_ptr, __pyx_v_y_stride, __pyx_v_X_argsorted_i, __pyx_v_sample_mask_ptr); - /* "sklearn/tree/_tree.pyx":1018 + /* "sklearn/tree/_tree.pyx":1020 * # Better than the best so far? * n_left = criterion.update(0, c, y_ptr, y_stride, X_argsorted_i, sample_mask_ptr) * error = criterion.eval() # <<<<<<<<<<<<<< @@ -8129,23 +8094,23 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_error = ((struct __pyx_vtabstruct_7sklearn_4tree_5_tree_Criterion *)__pyx_v_criterion->__pyx_vtab)->eval(__pyx_v_criterion); - /* "sklearn/tree/_tree.pyx":1020 + /* "sklearn/tree/_tree.pyx":1022 * error = criterion.eval() * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: # <<<<<<<<<<<<<< * continue * */ - __pyx_t_5 = (__pyx_v_n_left < __pyx_v_min_leaf); - if (!__pyx_t_5) { - __pyx_t_13 = ((__pyx_v_n_samples - __pyx_v_n_left) < __pyx_v_min_leaf); - __pyx_t_14 = __pyx_t_13; + __pyx_t_2 = (__pyx_v_n_left < __pyx_v_min_leaf); + if (!__pyx_t_2) { + __pyx_t_12 = ((__pyx_v_n_samples - __pyx_v_n_left) < __pyx_v_min_leaf); + __pyx_t_13 = __pyx_t_12; } else { - __pyx_t_14 = __pyx_t_5; + __pyx_t_13 = __pyx_t_2; } - if (__pyx_t_14) { + if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":1021 + /* "sklearn/tree/_tree.pyx":1023 * * if n_left < min_leaf or (n_samples - n_left) < min_leaf: * continue # <<<<<<<<<<<<<< @@ -8157,17 +8122,17 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON } __pyx_L17:; - /* "sklearn/tree/_tree.pyx":1023 + /* "sklearn/tree/_tree.pyx":1025 * continue * * if error < best_error: # <<<<<<<<<<<<<< * best_i = i * best_t = t */ - __pyx_t_14 = (__pyx_v_error < __pyx_v_best_error); - if (__pyx_t_14) { + __pyx_t_13 = (__pyx_v_error < __pyx_v_best_error); + if (__pyx_t_13) { - /* "sklearn/tree/_tree.pyx":1024 + /* "sklearn/tree/_tree.pyx":1026 * * if error < best_error: * best_i = i # <<<<<<<<<<<<<< @@ -8176,7 +8141,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_i = __pyx_v_i; - /* "sklearn/tree/_tree.pyx":1025 + /* "sklearn/tree/_tree.pyx":1027 * if error < best_error: * best_i = i * best_t = t # <<<<<<<<<<<<<< @@ -8185,7 +8150,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON */ __pyx_v_best_t = __pyx_v_t; - /* "sklearn/tree/_tree.pyx":1026 + /* "sklearn/tree/_tree.pyx":1028 * best_i = i * best_t = t * best_error = error # <<<<<<<<<<<<<< @@ -8199,46 +8164,46 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_L5_continue:; } - /* "sklearn/tree/_tree.pyx":1028 + /* "sklearn/tree/_tree.pyx":1030 * best_error = error * * return best_i, best_t, best_error, initial_error # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_best_i); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_t); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_best_error); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_initial_error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_8 = 0; - __pyx_t_1 = 0; - __pyx_r = ((PyObject *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer); @@ -11329,7 +11294,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__t, __pyx_k__t, sizeof(__pyx_k__t), 0, 0, 1, 1}, {&__pyx_n_s__threshold, __pyx_k__threshold, sizeof(__pyx_k__threshold), 0, 0, 1, 1}, {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1}, - {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1}, {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, {&__pyx_n_s__y_ptr, __pyx_k__y_ptr, sizeof(__pyx_k__y_ptr), 0, 0, 1, 1}, {&__pyx_n_s__y_stride, __pyx_k__y_stride, sizeof(__pyx_k__y_stride), 0, 0, 1, 1}, @@ -11337,13 +11301,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #if PY_MAJOR_VERSION >= 3 - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; @@ -11438,14 +11397,14 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_11)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); - /* "sklearn/tree/_tree.pyx":602 + /* "sklearn/tree/_tree.pyx":604 * * * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_13 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_13); __Pyx_INCREF(((PyObject *)__pyx_n_s__n_total_samples)); PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_n_s__n_total_samples)); @@ -11469,16 +11428,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_13, 6, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); - __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 602, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_14 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___random_sample_mask, 604, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":635 + /* "sklearn/tree/_tree.pyx":637 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_17 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_17); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_n_s__X)); @@ -11505,16 +11464,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_17, 7, ((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__node_id)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); - __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 635, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___apply_tree, 637, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":656 + /* "sklearn/tree/_tree.pyx":658 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_k_tuple_19 = PyTuple_New(13); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_19 = PyTuple_New(13); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_19); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_n_s__X)); @@ -11556,16 +11515,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_19, 12, ((PyObject *)__pyx_n_s__n_classes)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_classes)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 656, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_20 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___predict_tree, 658, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":683 + /* "sklearn/tree/_tree.pyx":685 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< * np.ndarray sample_mask, * Criterion criterion, */ - __pyx_k_tuple_21 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_21 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_INCREF(((PyObject *)__pyx_n_s__y)); PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__y)); @@ -11592,16 +11551,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_21, 7, ((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sample_mask_ptr)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 683, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_22 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___error_at_leaf, 685, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":734 + /* "sklearn/tree/_tree.pyx":736 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_25 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_25 = PyTuple_New(34); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_25); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__X)); @@ -11706,16 +11665,16 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_25, 33, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); - __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 734, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_26 = (PyObject*)__Pyx_PyCode_New(9, 0, 34, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s___find_best_split, 736, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "sklearn/tree/_tree.pyx":880 + /* "sklearn/tree/_tree.pyx":882 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_k_tuple_27 = PyTuple_New(35); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_27 = PyTuple_New(35); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_27); __Pyx_INCREF(((PyObject *)__pyx_n_s__X)); PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__X)); @@ -11823,7 +11782,7 @@ static int __Pyx_InitCachedConstants(void) { PyTuple_SET_ITEM(__pyx_k_tuple_27, 34, ((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X_argsorted_stride)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); - __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 880, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_codeobj_28 = (PyObject*)__Pyx_PyCode_New(9, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_15, __pyx_n_s_29, 882, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -11850,6 +11809,7 @@ PyMODINIT_FUNC PyInit__tree(void) { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_t_3; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); @@ -11912,9 +11872,9 @@ PyMODINIT_FUNC PyInit__tree(void) __pyx_vtable_7sklearn_4tree_5_tree_Criterion.update = (int (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int, int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_update; __pyx_vtable_7sklearn_4tree_5_tree_Criterion.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_9Criterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_Criterion.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_9Criterion_init_value; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Criterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Criterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Criterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Criterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Criterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Criterion = &__pyx_type_7sklearn_4tree_5_tree_Criterion; __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; @@ -11924,25 +11884,25 @@ PyMODINIT_FUNC PyInit__tree(void) __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_ClassificationCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_23ClassificationCriterion_init_value; __pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "ClassificationCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ClassificationCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion = &__pyx_type_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtabptr_7sklearn_4tree_5_tree_Gini = &__pyx_vtable_7sklearn_4tree_5_tree_Gini; __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Gini.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_4Gini_eval; __pyx_type_7sklearn_4tree_5_tree_Gini.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Gini.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Gini", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Gini) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Gini = &__pyx_type_7sklearn_4tree_5_tree_Gini; __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy = &__pyx_vtable_7sklearn_4tree_5_tree_Entropy; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_ClassificationCriterion; __pyx_vtable_7sklearn_4tree_5_tree_Entropy.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_7Entropy_eval; __pyx_type_7sklearn_4tree_5_tree_Entropy.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_ClassificationCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_Entropy.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Entropy", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_Entropy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_Entropy = &__pyx_type_7sklearn_4tree_5_tree_Entropy; __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_Criterion; @@ -11952,17 +11912,17 @@ PyMODINIT_FUNC PyInit__tree(void) __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_eval; __pyx_vtable_7sklearn_4tree_5_tree_RegressionCriterion.__pyx_base.init_value = (PyArrayObject *(*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *, int __pyx_skip_dispatch))__pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_init_value; __pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_Criterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "RegressionCriterion", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = &__pyx_type_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtabptr_7sklearn_4tree_5_tree_MSE = &__pyx_vtable_7sklearn_4tree_5_tree_MSE; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base = *__pyx_vtabptr_7sklearn_4tree_5_tree_RegressionCriterion; __pyx_vtable_7sklearn_4tree_5_tree_MSE.__pyx_base.__pyx_base.eval = (double (*)(struct __pyx_obj_7sklearn_4tree_5_tree_Criterion *))__pyx_f_7sklearn_4tree_5_tree_3MSE_eval; __pyx_type_7sklearn_4tree_5_tree_MSE.tp_base = __pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion; - if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_7sklearn_4tree_5_tree_MSE.tp_dict, __pyx_vtabptr_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "MSE", (PyObject *)&__pyx_type_7sklearn_4tree_5_tree_MSE) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_7sklearn_4tree_5_tree_MSE = &__pyx_type_7sklearn_4tree_5_tree_MSE; /*--- Type import code ---*/ __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -12001,87 +11961,103 @@ PyMODINIT_FUNC PyInit__tree(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "sklearn/tree/_tree.pyx":602 + /* "sklearn/tree/_tree.pyx":32 + * cdef extern double DBL_MAX * + * cdef DTYPE_t inf = np.inf # <<<<<<<<<<<<<< * - * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< - * """Create a random sample mask where ``n_total_in_bag`` elements are set. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_7sklearn_4tree_5_tree_inf = __pyx_t_3; + + /* "sklearn/tree/_tree.pyx":604 + * + * + * def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): # <<<<<<<<<<<<<< + * """Create a random sample mask where ``n_total_in_bag`` elements are set. + * + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_1_random_sample_mask, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___random_sample_mask, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":635 + /* "sklearn/tree/_tree.pyx":637 * * * def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_3_apply_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___apply_tree, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":656 + /* "sklearn/tree/_tree.pyx":658 * * * def _predict_tree(np.ndarray[DTYPE_t, ndim=2] X, # <<<<<<<<<<<<<< * np.ndarray[np.int32_t, ndim=2] children, * np.ndarray[np.int32_t, ndim=1] feature, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_5_predict_tree, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___predict_tree, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":683 + /* "sklearn/tree/_tree.pyx":685 * * * def _error_at_leaf(np.ndarray[DTYPE_t, ndim=2, mode="c"] y, # <<<<<<<<<<<<<< * np.ndarray sample_mask, * Criterion criterion, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_7_error_at_leaf, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___error_at_leaf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":734 + /* "sklearn/tree/_tree.pyx":736 * * * def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_9_find_best_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___find_best_split, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "sklearn/tree/_tree.pyx":880 + /* "sklearn/tree/_tree.pyx":882 * return best_i, best_t, best_error, initial_error * * def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t, ndim=2, mode="c"] y, * np.ndarray[np.int32_t, ndim=2, mode="fortran"] X_argsorted, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7sklearn_4tree_5_tree_11_find_best_random_split, NULL, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_29, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "sklearn/tree/_tree.pyx":1 * # encoding: utf-8 # <<<<<<<<<<<<<< * # cython: cdivision=True * # cython: boundscheck=False */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; /* "numpy.pxd":974 * arr.base = baseptr @@ -12126,21 +12102,6 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif /* CYTHON_REFNANNY */ -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { - PyObject *result; - result = PyObject_GetAttr(dict, name); - if (!result) { - if (dict != __pyx_b) { - PyErr_Clear(); - result = PyObject_GetAttr(__pyx_b, name); - } - if (!result) { - PyErr_SetObject(PyExc_NameError, name); - } - } - return result; -} - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_Format(PyExc_SystemError, "Missing type object"); @@ -12270,6 +12231,21 @@ static int __Pyx_ParseOptionalKeywords( +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) { + if (dict != __pyx_b) { + PyErr_Clear(); + result = PyObject_GetAttr(__pyx_b, name); + } + if (!result) { + PyErr_SetObject(PyExc_NameError, name); + } + } + return result; +} + static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index 4920eb4324e05..cfd4694e1d8e3 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -29,6 +29,8 @@ cdef extern from "math.h": cdef extern from "float.h": cdef extern double DBL_MAX +cdef DTYPE_t inf = np.inf + ################################################################################ # Classification entropy measures @@ -624,7 +626,7 @@ def _random_sample_mask(int n_total_samples, int n_total_in_bag, random_state): cdef int n_bagged = 0 cdef int i = 0 - for i in range(n_total_samples): + for i from 0 <= i < n_total_samples: if rand[i] * (n_total_samples - i) < (n_total_in_bag - n_bagged): sample_mask[i] = 1 n_bagged += 1 @@ -642,7 +644,7 @@ def _apply_tree(np.ndarray[DTYPE_t, ndim=2] X, cdef int i = 0 cdef int n = X.shape[0] cdef int node_id = 0 - for i in xrange(n): + for i from 0 <= i < n: node_id = 0 # While node_id not a leaf while children[node_id, 0] != -1 and children[node_id, 1] != -1: @@ -796,7 +798,7 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef np.int32_t feature_idx = -1 cdef int n_left = 0 cdef DTYPE_t t, initial_error, error - cdef DTYPE_t best_error = np.inf, best_t = np.inf + cdef DTYPE_t best_error = inf, best_t = inf cdef DTYPE_t* X_i = NULL cdef int* X_argsorted_i = NULL cdef DTYPE_t* y_ptr = y.data @@ -941,7 +943,7 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef int i, a, b, c, n_left, best_i = -1 cdef np.int32_t feature_idx = -1 cdef DTYPE_t t, initial_error, error - cdef DTYPE_t best_error = np.inf, best_t = np.inf + cdef DTYPE_t best_error = inf, best_t = inf cdef DTYPE_t* X_i = NULL cdef int* X_argsorted_i = NULL cdef DTYPE_t* y_ptr = y.data From 5333afa441f0c9922ee233481fe39dd04f3904a8 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Tue, 3 Jul 2012 08:48:16 +0200 Subject: [PATCH 21/33] DOC: narrative documentation --- doc/modules/tree.rst | 4 +++- sklearn/tree/_tree.c | 32 ++++++++++++++++---------------- sklearn/tree/_tree.pyx | 6 +++--- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index 7670052a48407..e65eed031f847 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -195,7 +195,9 @@ this kind of problems is to build n independent models, i.e. one for each output, and then to use those models to independently predict each one of the n outputs. However, because it is likely that the output values related to the same input are themselves correlated, an often better way is to build a single -model capable of predicting simultaneously all n outputs. +model capable of predicting simultaneously all n outputs. First, it requires +lower training time since only a single estimator is built. Second, the +generalization accuracy of the resulting estimator may often be increased. With regard to decision trees, this strategy can readily be used to support multi-output problems. This indeed amounts to: diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index 37756c0d1ad62..a6c24696b3941 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Mon Jul 2 16:31:14 2012 */ +/* Generated by Cython 0.16 on Tue Jul 3 08:43:22 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -1256,7 +1256,7 @@ static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Gini = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_Entropy = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_RegressionCriterion = 0; static PyTypeObject *__pyx_ptype_7sklearn_4tree_5_tree_MSE = 0; -static __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_7sklearn_4tree_5_tree_inf; +static __pyx_t_7sklearn_4tree_5_tree_DTYPE_t __pyx_v_7sklearn_4tree_5_tree_INFINITY; static int __pyx_f_7sklearn_4tree_5_tree_smallest_sample_larger_than(int, __pyx_t_7sklearn_4tree_5_tree_DTYPE_t *, int *, __pyx_t_7sklearn_4tree_5_tree_BOOL_t *, int); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7sklearn_4tree_5_tree_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_7sklearn_4tree_5_tree_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), { 0 }, 0, 'R', 0, 0 }; @@ -6531,23 +6531,23 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED * cdef np.int32_t feature_idx = -1 * cdef int n_left = 0 # <<<<<<<<<<<<<< * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY */ __pyx_v_n_left = 0; /* "sklearn/tree/_tree.pyx":801 * cdef int n_left = 0 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf # <<<<<<<<<<<<<< + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_inf; - __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_inf; + __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_INFINITY; + __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_INFINITY; /* "sklearn/tree/_tree.pyx":802 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data @@ -6555,7 +6555,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_8_find_best_split(CYTHON_UNUSED __pyx_v_X_i = NULL; /* "sklearn/tree/_tree.pyx":803 - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< * cdef DTYPE_t* y_ptr = y.data @@ -7466,23 +7466,23 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON * cdef int i, a, b, c, n_left, best_i = -1 * cdef np.int32_t feature_idx = -1 # <<<<<<<<<<<<<< * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY */ __pyx_v_feature_idx = -1; /* "sklearn/tree/_tree.pyx":946 * cdef np.int32_t feature_idx = -1 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf # <<<<<<<<<<<<<< + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY # <<<<<<<<<<<<<< * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL */ - __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_inf; - __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_inf; + __pyx_v_best_error = __pyx_v_7sklearn_4tree_5_tree_INFINITY; + __pyx_v_best_t = __pyx_v_7sklearn_4tree_5_tree_INFINITY; /* "sklearn/tree/_tree.pyx":947 * cdef DTYPE_t t, initial_error, error - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY * cdef DTYPE_t* X_i = NULL # <<<<<<<<<<<<<< * cdef int* X_argsorted_i = NULL * cdef DTYPE_t* y_ptr = y.data @@ -7490,7 +7490,7 @@ static PyObject *__pyx_pf_7sklearn_4tree_5_tree_10_find_best_random_split(CYTHON __pyx_v_X_i = NULL; /* "sklearn/tree/_tree.pyx":948 - * cdef DTYPE_t best_error = inf, best_t = inf + * cdef DTYPE_t best_error = INFINITY, best_t = INFINITY * cdef DTYPE_t* X_i = NULL * cdef int* X_argsorted_i = NULL # <<<<<<<<<<<<<< * cdef DTYPE_t* y_ptr = y.data @@ -11964,7 +11964,7 @@ PyMODINIT_FUNC PyInit__tree(void) /* "sklearn/tree/_tree.pyx":32 * cdef extern double DBL_MAX * - * cdef DTYPE_t inf = np.inf # <<<<<<<<<<<<<< + * cdef DTYPE_t INFINITY = np.inf # <<<<<<<<<<<<<< * * */ @@ -11975,7 +11975,7 @@ PyMODINIT_FUNC PyInit__tree(void) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_3 == (npy_float32)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_7sklearn_4tree_5_tree_inf = __pyx_t_3; + __pyx_v_7sklearn_4tree_5_tree_INFINITY = __pyx_t_3; /* "sklearn/tree/_tree.pyx":604 * diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index cfd4694e1d8e3..e6f11a2b8b58b 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -29,7 +29,7 @@ cdef extern from "math.h": cdef extern from "float.h": cdef extern double DBL_MAX -cdef DTYPE_t inf = np.inf +cdef DTYPE_t INFINITY = np.inf ################################################################################ @@ -798,7 +798,7 @@ def _find_best_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef np.int32_t feature_idx = -1 cdef int n_left = 0 cdef DTYPE_t t, initial_error, error - cdef DTYPE_t best_error = inf, best_t = inf + cdef DTYPE_t best_error = INFINITY, best_t = INFINITY cdef DTYPE_t* X_i = NULL cdef int* X_argsorted_i = NULL cdef DTYPE_t* y_ptr = y.data @@ -943,7 +943,7 @@ def _find_best_random_split(np.ndarray[DTYPE_t, ndim=2, mode="fortran"] X, cdef int i, a, b, c, n_left, best_i = -1 cdef np.int32_t feature_idx = -1 cdef DTYPE_t t, initial_error, error - cdef DTYPE_t best_error = inf, best_t = inf + cdef DTYPE_t best_error = INFINITY, best_t = INFINITY cdef DTYPE_t* X_i = NULL cdef int* X_argsorted_i = NULL cdef DTYPE_t* y_ptr = y.data From f178fe6a7f19e55fd13cb3a5a993e276170d9411 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Tue, 3 Jul 2012 09:26:22 +0200 Subject: [PATCH 22/33] FIX: use and modify own y --- sklearn/ensemble/forest.py | 1 + sklearn/tree/tree.py | 1 + 2 files changed, 2 insertions(+) diff --git a/sklearn/ensemble/forest.py b/sklearn/ensemble/forest.py index d73a3410216d6..a2a400f8b551f 100644 --- a/sklearn/ensemble/forest.py +++ b/sklearn/ensemble/forest.py @@ -247,6 +247,7 @@ def fit(self, X, y): X_argsorted = np.asfortranarray(np.hstack(all_X_argsorted)) + y = np.copy(y) y = np.atleast_1d(y) if y.ndim == 1: y = y[:, np.newaxis] diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 5a746ea91562a..41d4cba9463a3 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -481,6 +481,7 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): is_classification = isinstance(self, ClassifierMixin) + y = np.copy(y) y = np.atleast_1d(y) if y.ndim == 1: y = y[:, np.newaxis] From b14c23aca17a2acbffa0f8ae1f18efd0a823ebb5 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Tue, 3 Jul 2012 09:47:10 +0200 Subject: [PATCH 23/33] COSMIT --- sklearn/tree/tree.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 41d4cba9463a3..310b6f6ff68f4 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -516,24 +516,18 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): if self.max_features == "auto": if is_classification: max_features = max(1, int(np.sqrt(self.n_features_))) - else: max_features = self.n_features_ - elif self.max_features == "sqrt": max_features = max(1, int(np.sqrt(self.n_features_))) - elif self.max_features == "log2": max_features = max(1, int(np.log2(self.n_features_))) - else: raise ValueError( 'Invalid value for max_features. Allowed string ' 'values are "auto", "sqrt" or "log2".') - elif self.max_features is None: max_features = self.n_features_ - else: max_features = self.max_features From f1bdd994f4a6951981cf2620b8856168b18d7cdc Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 11:11:17 +0200 Subject: [PATCH 24/33] FIX: segfault --- sklearn/tree/_tree.c | 12 ++++++------ sklearn/tree/_tree.pyx | 2 +- sklearn/tree/tree.py | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index a6c24696b3941..a7cdee3fbdfe2 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Tue Jul 3 08:43:22 2012 */ +/* Generated by Cython 0.16 on Wed Jul 4 11:10:27 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -4375,7 +4375,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p * continue * * for k from 0 <= k < n_outputs: # <<<<<<<<<<<<<< - * y_idx = y[k * y_stride + j] + * y_idx = y[j * y_stride + k] * sq_sum_left[k] += (y_idx * y_idx) */ __pyx_t_3 = __pyx_v_n_outputs; @@ -4384,15 +4384,15 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p /* "sklearn/tree/_tree.pyx":542 * * for k from 0 <= k < n_outputs: - * y_idx = y[k * y_stride + j] # <<<<<<<<<<<<<< + * y_idx = y[j * y_stride + k] # <<<<<<<<<<<<<< * sq_sum_left[k] += (y_idx * y_idx) * sq_sum_right[k] -= (y_idx * y_idx) */ - __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_k * __pyx_v_y_stride) + __pyx_v_j)]); + __pyx_v_y_idx = (__pyx_v_y[((__pyx_v_j * __pyx_v_y_stride) + __pyx_v_k)]); /* "sklearn/tree/_tree.pyx":543 * for k from 0 <= k < n_outputs: - * y_idx = y[k * y_stride + j] + * y_idx = y[j * y_stride + k] * sq_sum_left[k] += (y_idx * y_idx) # <<<<<<<<<<<<<< * sq_sum_right[k] -= (y_idx * y_idx) * @@ -4401,7 +4401,7 @@ static int __pyx_f_7sklearn_4tree_5_tree_19RegressionCriterion_update(struct __p (__pyx_v_sq_sum_left[__pyx_t_4]) = ((__pyx_v_sq_sum_left[__pyx_t_4]) + (__pyx_v_y_idx * __pyx_v_y_idx)); /* "sklearn/tree/_tree.pyx":544 - * y_idx = y[k * y_stride + j] + * y_idx = y[j * y_stride + k] * sq_sum_left[k] += (y_idx * y_idx) * sq_sum_right[k] -= (y_idx * y_idx) # <<<<<<<<<<<<<< * diff --git a/sklearn/tree/_tree.pyx b/sklearn/tree/_tree.pyx index e6f11a2b8b58b..202ca22bf6dde 100644 --- a/sklearn/tree/_tree.pyx +++ b/sklearn/tree/_tree.pyx @@ -539,7 +539,7 @@ cdef class RegressionCriterion(Criterion): continue for k from 0 <= k < n_outputs: - y_idx = y[k * y_stride + j] + y_idx = y[j * y_stride + k] sq_sum_left[k] += (y_idx * y_idx) sq_sum_right[k] -= (y_idx * y_idx) diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 310b6f6ff68f4..0485b403a800d 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -503,6 +503,8 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): y = np.asarray(y, dtype=DTYPE, order="C") + print y.strides + if is_classification: criterion = CLASSIFICATION[self.criterion](self.n_outputs_, self.n_classes_) From f11ff94d4c654df4a89881cecf5ccd98251670bf Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 12:02:22 +0200 Subject: [PATCH 25/33] DOC: Example --- doc/modules/tree.rst | 2 + .../ensemble/plot_forest_importances_faces.py | 2 +- examples/ensemble/plot_forest_multioutput.py | 73 +++++++++++++++++++ sklearn/tree/_tree.c | 2 +- sklearn/tree/tree.py | 2 - 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 examples/ensemble/plot_forest_multioutput.py diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index e65eed031f847..389cec049d76b 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -215,6 +215,8 @@ of size ``[n_samples, n_outputs]`` then the resulting estimator will: - Output a list of n_output arrays of class probabilities upon ``predict_proba``. + * :ref:`example_ensemble_plot_forest_multioutput.py` + .. _tree_complexity: diff --git a/examples/ensemble/plot_forest_importances_faces.py b/examples/ensemble/plot_forest_importances_faces.py index 3e71d67c4f9e8..60ebaec1bb8fe 100644 --- a/examples/ensemble/plot_forest_importances_faces.py +++ b/examples/ensemble/plot_forest_importances_faces.py @@ -21,7 +21,7 @@ # Number of cores to use to perform parallel fitting of the forest model n_jobs = 1 -# Loading the digits dataset +# Load the faces dataset data = fetch_olivetti_faces() X = data.images.reshape((len(data.images), -1)) y = data.target diff --git a/examples/ensemble/plot_forest_multioutput.py b/examples/ensemble/plot_forest_multioutput.py new file mode 100644 index 0000000000000..2c182ebfab5c0 --- /dev/null +++ b/examples/ensemble/plot_forest_multioutput.py @@ -0,0 +1,73 @@ +""" +========================================= +Face completion with multi-output forests +========================================= + +This example shows the use of multi-output forests to complete images. +The goal is to predict the lower half of a face given its upper half. + +The first row of images show the true faces. The second half show the completed +faces. + +""" +print __doc__ + +import numpy as np +import pylab as pl + +from sklearn.datasets import fetch_olivetti_faces +from sklearn.ensemble import ExtraTreesRegressor +from sklearn.tree import DecisionTreeRegressor + +# Number of cores to use to perform parallel fitting of the forest model +n_jobs = 2 + +# Loading the faces datasets +data = fetch_olivetti_faces() +targets = data.target + +data = data.images.reshape((len(data.images), -1)) +train = data[targets < 30] +test = data[targets >= 30] # Test on independent people +n_pixels = data.shape[1] + +X_train = train[:, :int(0.5*n_pixels)] # Upper half of the faces +Y_train = train[:, int(0.5*n_pixels):] # Lower half of the faces +X_test = test[:, :int(0.5*n_pixels)] +Y_test = test[:, int(0.5*n_pixels):] + +# # Build a multi-output forest +forest = ExtraTreesRegressor(n_estimators=10, + max_features=32, + n_jobs=n_jobs, + random_state=0) + +forest.fit(X_train, Y_train) +Y_test_predict = forest.predict(X_test) + +# Plot the completed faces +n_faces = 5 +image_shape = (64, 64) + +pl.figure(figsize=(2. * n_faces, 2.26 * 2)) +pl.suptitle("Face completion with multi-output forests", size=16) + +for i in xrange(1, 1 + n_faces): + face_id = np.random.randint(X_test.shape[0]) + + true_face = np.hstack((X_test[face_id], Y_test[face_id])) + completed_face = np.hstack((X_test[face_id], Y_test_predict[face_id])) + + pl.subplot(2, n_faces, i) + pl.axis("off") + pl.imshow(true_face.reshape(image_shape), + cmap=pl.cm.gray, + interpolation="nearest") + + pl.subplot(2, n_faces, n_faces + i) + pl.axis("off") + pl.imshow(completed_face.reshape(image_shape), + cmap=pl.cm.gray, + interpolation="nearest") + +pl.show() diff --git a/sklearn/tree/_tree.c b/sklearn/tree/_tree.c index a7cdee3fbdfe2..6ceeb0ca591ab 100644 --- a/sklearn/tree/_tree.c +++ b/sklearn/tree/_tree.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.16 on Wed Jul 4 11:10:27 2012 */ +/* Generated by Cython 0.16 on Wed Jul 4 11:24:05 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" diff --git a/sklearn/tree/tree.py b/sklearn/tree/tree.py index 0485b403a800d..310b6f6ff68f4 100644 --- a/sklearn/tree/tree.py +++ b/sklearn/tree/tree.py @@ -503,8 +503,6 @@ def fit(self, X, y, sample_mask=None, X_argsorted=None): y = np.asarray(y, dtype=DTYPE, order="C") - print y.strides - if is_classification: criterion = CLASSIFICATION[self.criterion](self.n_outputs_, self.n_classes_) From 264737ed117255db8fb0f0282c500acd965e5583 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 12:04:42 +0200 Subject: [PATCH 26/33] DOC: typo --- examples/ensemble/plot_forest_multioutput.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ensemble/plot_forest_multioutput.py b/examples/ensemble/plot_forest_multioutput.py index 2c182ebfab5c0..1f30b60ce54c7 100644 --- a/examples/ensemble/plot_forest_multioutput.py +++ b/examples/ensemble/plot_forest_multioutput.py @@ -6,8 +6,8 @@ This example shows the use of multi-output forests to complete images. The goal is to predict the lower half of a face given its upper half. -The first row of images show the true faces. The second half show the completed -faces. +The first row of images shows true faces. The second half illustrates +how the forest completes the lower half of those faces. """ print __doc__ From 386631e46cab307e148f870512cf486cad1673b6 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 13:02:48 +0200 Subject: [PATCH 27/33] DOC: example --- doc/modules/ensemble.rst | 2 ++ examples/ensemble/plot_forest_multioutput.py | 13 +++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/modules/ensemble.rst b/doc/modules/ensemble.rst index 3cebdf7f969a3..51998a2f5f838 100644 --- a/doc/modules/ensemble.rst +++ b/doc/modules/ensemble.rst @@ -54,6 +54,8 @@ Like :ref:`decision trees `, forests of trees also extend to :ref:`multi-output problems ` (if Y is an array of size ``[n_samples, n_outputs]``). + * :ref:`example_ensemble_plot_forest_multioutput.py` + Random Forests -------------- diff --git a/examples/ensemble/plot_forest_multioutput.py b/examples/ensemble/plot_forest_multioutput.py index 1f30b60ce54c7..947e82bd4cb73 100644 --- a/examples/ensemble/plot_forest_multioutput.py +++ b/examples/ensemble/plot_forest_multioutput.py @@ -19,8 +19,6 @@ from sklearn.ensemble import ExtraTreesRegressor from sklearn.tree import DecisionTreeRegressor -# Number of cores to use to perform parallel fitting of the forest model -n_jobs = 2 # Loading the faces datasets data = fetch_olivetti_faces() @@ -28,18 +26,17 @@ data = data.images.reshape((len(data.images), -1)) train = data[targets < 30] -test = data[targets >= 30] # Test on independent people +test = data[targets >= 30] # Test on independent people n_pixels = data.shape[1] -X_train = train[:, :int(0.5*n_pixels)] # Upper half of the faces -Y_train = train[:, int(0.5*n_pixels):] # Lower half of the faces -X_test = test[:, :int(0.5*n_pixels)] -Y_test = test[:, int(0.5*n_pixels):] +X_train = train[:, :int(0.5 * n_pixels)] # Upper half of the faces +Y_train = train[:, int(0.5 * n_pixels):] # Lower half of the faces +X_test = test[:, :int(0.5 * n_pixels)] +Y_test = test[:, int(0.5 * n_pixels):] # # Build a multi-output forest forest = ExtraTreesRegressor(n_estimators=10, max_features=32, - n_jobs=n_jobs, random_state=0) forest.fit(X_train, Y_train) From 91963b8293108ed2f611549a6b8c1caaa5da801e Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 13:10:28 +0200 Subject: [PATCH 28/33] DOC: typo --- examples/ensemble/plot_forest_multioutput.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ensemble/plot_forest_multioutput.py b/examples/ensemble/plot_forest_multioutput.py index 947e82bd4cb73..84ab43c29f5b7 100644 --- a/examples/ensemble/plot_forest_multioutput.py +++ b/examples/ensemble/plot_forest_multioutput.py @@ -20,7 +20,7 @@ from sklearn.tree import DecisionTreeRegressor -# Loading the faces datasets +# Load the faces datasets data = fetch_olivetti_faces() targets = data.target @@ -34,7 +34,7 @@ X_test = test[:, :int(0.5 * n_pixels)] Y_test = test[:, int(0.5 * n_pixels):] -# # Build a multi-output forest +# Build a multi-output forest forest = ExtraTreesRegressor(n_estimators=10, max_features=32, random_state=0) From a08a910304503df50e61106a70814517dd00d6f6 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Wed, 4 Jul 2012 13:37:42 +0200 Subject: [PATCH 29/33] DOC: narrative documentation --- doc/modules/ensemble.rst | 3 +-- doc/modules/tree.rst | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/modules/ensemble.rst b/doc/modules/ensemble.rst index 51998a2f5f838..ac77485587a05 100644 --- a/doc/modules/ensemble.rst +++ b/doc/modules/ensemble.rst @@ -54,8 +54,6 @@ Like :ref:`decision trees `, forests of trees also extend to :ref:`multi-output problems ` (if Y is an array of size ``[n_samples, n_outputs]``). - * :ref:`example_ensemble_plot_forest_multioutput.py` - Random Forests -------------- @@ -167,6 +165,7 @@ amount of time (e.g., on large datasets). * :ref:`example_ensemble_plot_forest_iris.py` * :ref:`example_ensemble_plot_forest_importances_faces.py` + * :ref:`example_ensemble_plot_forest_multioutput.py` .. topic:: References diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index 389cec049d76b..06b2d3acd619e 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -215,6 +215,18 @@ of size ``[n_samples, n_outputs]`` then the resulting estimator will: - Output a list of n_output arrays of class probabilities upon ``predict_proba``. +The use of multi-output trees is demonstrated in +:ref:`example_ensemble_plot_forest_multioutput.py`. In this example, the inputs +X are the pixels of the upper half of faces and the outputs Y are the pixels of +the lower half of those faces. + +.. figure:: ../auto_examples/ensemble/images/plot_forest_multioutput_1.png + :target: ../auto_examples/ensemble/plot_forest_multioutput.html + :scale: 75 + :align: center + +.. topic:: Examples: + * :ref:`example_ensemble_plot_forest_multioutput.py` From 637ab8274e10f2adeb3749dcfdaf06cb7dc1494f Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 9 Jul 2012 12:48:34 +0100 Subject: [PATCH 30/33] added multi-ouput tree example --- .../tree/plot_tree_regression_multioutput.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/tree/plot_tree_regression_multioutput.py diff --git a/examples/tree/plot_tree_regression_multioutput.py b/examples/tree/plot_tree_regression_multioutput.py new file mode 100644 index 0000000000000..6d7f4aca2372c --- /dev/null +++ b/examples/tree/plot_tree_regression_multioutput.py @@ -0,0 +1,53 @@ +""" +=================================================================== +Decision Tree Regression +=================================================================== + +1D multi-output regression with :ref:`decision trees `: the decision tree +is used to predict simultaneously the noisy x and y observations of a circle given +the underlying feature. As a result, it learns local linear regressions +approximating the sine curve. + +We can see that if the maximum depth of the tree (controlled by the +`max_depth` parameter) is set too high, the decision trees learn too fine +details of the training data and learn from the noise, i.e. they overfit. +""" +print __doc__ + +import numpy as np + +# Create a random dataset +rng = np.random.RandomState(1) +X = np.sort(200 * rng.rand(100, 1) - 100, axis=0) +y = np.array([np.pi * np.sin(X).ravel(), np.pi * np.cos(X).ravel()]).T +y[::5,:] += 3 * (0.5 - rng.rand(20,2)) + +# Fit regression model +from sklearn.tree import DecisionTreeRegressor + +clf_1 = DecisionTreeRegressor(max_depth=2) +clf_2 = DecisionTreeRegressor(max_depth=5) +clf_3 = DecisionTreeRegressor(max_depth=10) +clf_1.fit(X, y) +clf_2.fit(X, y) +clf_3.fit(X, y) + +# Predict +X_test = np.arange(-100.0, 100.0, 0.01)[:, np.newaxis] +y_1 = clf_1.predict(X_test) +y_2 = clf_2.predict(X_test) +y_3 = clf_3.predict(X_test) + +# Plot the results +import pylab as pl + +pl.figure() +pl.scatter(y[:,0], y[:,1], c="k", label="data") +pl.scatter(y_1[:,0], y_1[:,1], c="g", label="max_depth=2", linewidth=2) +pl.scatter(y_2[:,0], y_2[:,1], c="r", label="max_depth=5", linewidth=2) +pl.scatter(y_3[:,0], y_3[:,1], c="b", label="max_depth=10", linewidth=2) +pl.xlabel("data") +pl.ylabel("target") +pl.title("Multi-output Decision Tree Regression") +pl.legend() +pl.show() \ No newline at end of file From 81a1f90a924b1b5d64c0a630cb5c4dce310ee9b6 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 9 Jul 2012 13:24:49 +0100 Subject: [PATCH 31/33] updated documentation to reflect multi-output DT regression --- doc/modules/tree.rst | 15 ++++++++++--- .../tree/plot_tree_regression_multioutput.py | 22 ++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index 06b2d3acd619e..7354a49ec2faf 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -191,7 +191,7 @@ A multi-output problem is a supervised learning problem with several outputs to predict, that is when Y is a 2d array of size ``[n_samples, n_outputs]``. When there is no correlation between the outputs, a very simple way to solve -this kind of problems is to build n independent models, i.e. one for each +this kind of problem is to build n independent models, i.e. one for each output, and then to use those models to independently predict each one of the n outputs. However, because it is likely that the output values related to the same input are themselves correlated, an often better way is to build a single @@ -200,7 +200,7 @@ lower training time since only a single estimator is built. Second, the generalization accuracy of the resulting estimator may often be increased. With regard to decision trees, this strategy can readily be used to support -multi-output problems. This indeed amounts to: +multi-output problems. This requires the following changes: - Store n output values in leaves, instead of 1; - Use splitting criteria that compute the average reduction across all @@ -215,7 +215,16 @@ of size ``[n_samples, n_outputs]`` then the resulting estimator will: - Output a list of n_output arrays of class probabilities upon ``predict_proba``. -The use of multi-output trees is demonstrated in +The use of multi-output trees for regression is demonstrated in +:ref:`example_tree_plot_tree_regression_multioutput.py`. In this example, the input +X is a single real value and the outputs Y are the sine and cosine of X. + +.. figure:: ../auto_examples/tree/images/plot_tree_regression_multioutput_1.png + :target: ../auto_examples/tree/plot_tree_regression_multioutput.html + :scale: 75 + :align: center + +The use of multi-output trees for classification is demonstrated in :ref:`example_ensemble_plot_forest_multioutput.py`. In this example, the inputs X are the pixels of the upper half of faces and the outputs Y are the pixels of the lower half of those faces. diff --git a/examples/tree/plot_tree_regression_multioutput.py b/examples/tree/plot_tree_regression_multioutput.py index 6d7f4aca2372c..3c7d37fdb3467 100644 --- a/examples/tree/plot_tree_regression_multioutput.py +++ b/examples/tree/plot_tree_regression_multioutput.py @@ -1,12 +1,12 @@ """ =================================================================== -Decision Tree Regression +Multi-output Decision Tree Regression =================================================================== -1D multi-output regression with :ref:`decision trees `: the decision tree -is used to predict simultaneously the noisy x and y observations of a circle given -the underlying feature. As a result, it learns local linear regressions -approximating the sine curve. +Multi-output regression with :ref:`decision trees `: the decision tree +is used to predict simultaneously the noisy x and y observations of a circle +given a single underlying feature. As a result, it learns local linear +regressions approximating the circle. We can see that if the maximum depth of the tree (controlled by the `max_depth` parameter) is set too high, the decision trees learn too fine @@ -20,14 +20,14 @@ rng = np.random.RandomState(1) X = np.sort(200 * rng.rand(100, 1) - 100, axis=0) y = np.array([np.pi * np.sin(X).ravel(), np.pi * np.cos(X).ravel()]).T -y[::5,:] += 3 * (0.5 - rng.rand(20,2)) +y[::5,:] += (0.5 - rng.rand(20,2)) # Fit regression model from sklearn.tree import DecisionTreeRegressor clf_1 = DecisionTreeRegressor(max_depth=2) clf_2 = DecisionTreeRegressor(max_depth=5) -clf_3 = DecisionTreeRegressor(max_depth=10) +clf_3 = DecisionTreeRegressor(max_depth=8) clf_1.fit(X, y) clf_2.fit(X, y) clf_3.fit(X, y) @@ -43,9 +43,11 @@ pl.figure() pl.scatter(y[:,0], y[:,1], c="k", label="data") -pl.scatter(y_1[:,0], y_1[:,1], c="g", label="max_depth=2", linewidth=2) -pl.scatter(y_2[:,0], y_2[:,1], c="r", label="max_depth=5", linewidth=2) -pl.scatter(y_3[:,0], y_3[:,1], c="b", label="max_depth=10", linewidth=2) +pl.scatter(y_1[:,0], y_1[:,1], c="g", label="max_depth=2") +pl.scatter(y_2[:,0], y_2[:,1], c="r", label="max_depth=5") +pl.scatter(y_3[:,0], y_3[:,1], c="b", label="max_depth=8") +pl.xlim([-6, 6]) +pl.ylim([-6, 6]) pl.xlabel("data") pl.ylabel("target") pl.title("Multi-output Decision Tree Regression") From 94a5f3ff86c80eadc84663f594a4202370960ec8 Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 9 Jul 2012 13:27:47 +0100 Subject: [PATCH 32/33] added link --- doc/modules/tree.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index 7354a49ec2faf..dc2b2b43ec660 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -236,6 +236,7 @@ the lower half of those faces. .. topic:: Examples: + * :ref:`example_tree_plot_tree_regression_multioutput.py` * :ref:`example_ensemble_plot_forest_multioutput.py` From f14601adfba92cf889677a862e6ccdb59a3617a4 Mon Sep 17 00:00:00 2001 From: Gilles Louppe Date: Mon, 9 Jul 2012 17:36:28 +0200 Subject: [PATCH 33/33] DOC: format --- doc/modules/tree.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/modules/tree.rst b/doc/modules/tree.rst index dc2b2b43ec660..a30eed4c8aff7 100644 --- a/doc/modules/tree.rst +++ b/doc/modules/tree.rst @@ -51,6 +51,7 @@ Some advantages of decision trees are: - Performs well even if its assumptions are somewhat violated by the true model from which the data were generated. + The disadvantages of decision trees include: - Decision-tree learners can create over-complex trees that do not @@ -211,10 +212,12 @@ strategy in both :class:`DecisionTreeClassifier` and :class:`DecisionTreeRegressor`. If a decision tree is fit on an output array Y of size ``[n_samples, n_outputs]`` then the resulting estimator will: - - Output n_output values upon ``predict``; - - Output a list of n_output arrays of class probabilities upon + * Output n_output values upon ``predict``; + + * Output a list of n_output arrays of class probabilities upon ``predict_proba``. + The use of multi-output trees for regression is demonstrated in :ref:`example_tree_plot_tree_regression_multioutput.py`. In this example, the input X is a single real value and the outputs Y are the sine and cosine of X.