diff --git a/scikits/learn/src/liblinear.c b/scikits/learn/src/liblinear.c index 272fa78640b2b41b9243a80b6ca91d4ec0d0359b..5ba4cfc964927949e0d2eba538eeb818813f1e12 100644 --- a/scikits/learn/src/liblinear.c +++ b/scikits/learn/src/liblinear.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.12 on Mon Apr 19 15:22:58 2010 */ +/* Generated by Cython 0.12 on Mon Apr 19 15:32:36 2010 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -786,6 +786,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * struct problem *__pyx_v_problem; struct model *__pyx_v_model; char *__pyx_v_error_msg; + int __pyx_v_len_w; PyArrayObject *__pyx_v_w; int __pyx_v_nr_class; int __pyx_v_nr_feature; @@ -817,9 +818,9 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * 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; - int __pyx_t_7; + PyArrayObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; @@ -971,8 +972,8 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * __pyx_bstride_0_weight = __pyx_bstruct_weight.strides[0]; __pyx_bshape_0_weight = __pyx_bstruct_weight.shape[0]; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":50 - * cdef char *error_msg + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":51 + * cdef int len_w * * problem = set_problem(X.data, Y.data, X.shape, bias) # <<<<<<<<<<<<<< * @@ -980,7 +981,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_problem = set_problem(__pyx_v_X->data, __pyx_v_Y->data, __pyx_v_X->dimensions, __pyx_v_bias); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":52 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":53 * problem = set_problem(X.data, Y.data, X.shape, bias) * * param = set_parameter(solver_type, eps, C, nr_weight, weight_label.data, weight.data) # <<<<<<<<<<<<<< @@ -989,7 +990,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_param = set_parameter(__pyx_v_solver_type, __pyx_v_eps, __pyx_v_C, __pyx_v_nr_weight, __pyx_v_weight_label->data, __pyx_v_weight->data); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":54 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":55 * param = set_parameter(solver_type, eps, C, nr_weight, weight_label.data, weight.data) * * error_msg = check_parameter(problem, param) # <<<<<<<<<<<<<< @@ -998,7 +999,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_error_msg = check_parameter(__pyx_v_problem, __pyx_v_param); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":55 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":56 * * error_msg = check_parameter(problem, param) * if error_msg: # <<<<<<<<<<<<<< @@ -1008,7 +1009,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * __pyx_t_1 = (__pyx_v_error_msg != 0); if (__pyx_t_1) { - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":56 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":57 * error_msg = check_parameter(problem, param) * if error_msg: * free_problem(problem) # <<<<<<<<<<<<<< @@ -1017,7 +1018,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ free_problem(__pyx_v_problem); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":57 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":58 * if error_msg: * free_problem(problem) * free_parameter(param) # <<<<<<<<<<<<<< @@ -1026,31 +1027,31 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ free_parameter(__pyx_v_param); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":58 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":59 * free_problem(problem) * free_parameter(param) * raise ValueError(error_msg) # <<<<<<<<<<<<<< * * # early return */ - __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_error_msg); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_error_msg); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __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 = 58; __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 = 59; __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_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":61 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":62 * * # early return * model = train(problem, param) # <<<<<<<<<<<<<< @@ -1059,7 +1060,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_model = train(__pyx_v_problem, __pyx_v_param); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":64 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":65 * * cdef np.ndarray[np.float64_t, ndim=2, mode='c'] w * cdef int nr_class = get_nr_class(model) # <<<<<<<<<<<<<< @@ -1068,21 +1069,21 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_nr_class = get_nr_class(__pyx_v_model); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":65 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":66 * cdef np.ndarray[np.float64_t, ndim=2, mode='c'] w * cdef int nr_class = get_nr_class(model) * cdef int nr_feature = get_nr_feature(model) # <<<<<<<<<<<<<< * if bias > 0: nr_feature = nr_feature + 1 - * w = np.empty((nr_feature, nr_class)) + * if nr_class == 2: */ __pyx_v_nr_feature = get_nr_feature(__pyx_v_model); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":66 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":67 * cdef int nr_class = get_nr_class(model) * cdef int nr_feature = get_nr_feature(model) * if bias > 0: nr_feature = nr_feature + 1 # <<<<<<<<<<<<<< - * w = np.empty((nr_feature, nr_class)) - * copy_w(w.data, model, nr_class * nr_feature) + * if nr_class == 2: + * w = np.empty(nr_feature) */ __pyx_t_1 = (__pyx_v_bias > 0); if (__pyx_t_1) { @@ -1091,74 +1092,144 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * } __pyx_L7:; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":67 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":68 * cdef int nr_feature = get_nr_feature(model) * if bias > 0: nr_feature = nr_feature + 1 - * w = np.empty((nr_feature, nr_class)) # <<<<<<<<<<<<<< - * copy_w(w.data, model, nr_class * nr_feature) - * + * if nr_class == 2: # <<<<<<<<<<<<<< + * w = np.empty(nr_feature) + * copy_w(w.data, model, nr_feature) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __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_nr_feature); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyInt_FromLong(__pyx_v_nr_class); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __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); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__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 = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_bstruct_w); - __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack); - if (unlikely(__pyx_t_7 < 0)) { - PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10); + __pyx_t_1 = (__pyx_v_nr_class == 2); + if (__pyx_t_1) { + + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":69 + * if bias > 0: nr_feature = nr_feature + 1 + * if nr_class == 2: + * w = np.empty(nr_feature) # <<<<<<<<<<<<<< + * copy_w(w.data, model, nr_feature) + * else: + */ + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __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_nr_feature); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __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 = 69; __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 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__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 = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_w); + __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_6 < 0)) { + PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9); + } } + __pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; __pyx_bstride_1_w = __pyx_bstruct_w.strides[1]; + __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; __pyx_bshape_1_w = __pyx_bstruct_w.shape[1]; + if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; __pyx_bstride_1_w = __pyx_bstruct_w.strides[1]; - __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; __pyx_bshape_1_w = __pyx_bstruct_w.shape[1]; - if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_w)); + __pyx_v_w = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":70 + * if nr_class == 2: + * w = np.empty(nr_feature) + * copy_w(w.data, model, nr_feature) # <<<<<<<<<<<<<< + * else: + * len_w = nr_class * nr_feature + */ + copy_w(__pyx_v_w->data, __pyx_v_model, __pyx_v_nr_feature); + goto __pyx_L8; } - __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_w)); - __pyx_v_w = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; + /*else*/ { - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":68 - * if bias > 0: nr_feature = nr_feature + 1 - * w = np.empty((nr_feature, nr_class)) - * copy_w(w.data, model, nr_class * nr_feature) # <<<<<<<<<<<<<< + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":72 + * copy_w(w.data, model, nr_feature) + * else: + * len_w = nr_class * nr_feature # <<<<<<<<<<<<<< + * w = np.empty(len_w) + * copy_w(w.data, model, len_w) + */ + __pyx_v_len_w = (__pyx_v_nr_class * __pyx_v_nr_feature); + + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":73 + * else: + * len_w = nr_class * nr_feature + * w = np.empty(len_w) # <<<<<<<<<<<<<< + * copy_w(w.data, model, len_w) + * + */ + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __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_len_w); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __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 = 73; __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_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__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 = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_bstruct_w); + __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_6 < 0)) { + PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_w, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7); + } + } + __pyx_bstride_0_w = __pyx_bstruct_w.strides[0]; __pyx_bstride_1_w = __pyx_bstruct_w.strides[1]; + __pyx_bshape_0_w = __pyx_bstruct_w.shape[0]; __pyx_bshape_1_w = __pyx_bstruct_w.shape[1]; + if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_w)); + __pyx_v_w = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":74 + * len_w = nr_class * nr_feature + * w = np.empty(len_w) + * copy_w(w.data, model, len_w) # <<<<<<<<<<<<<< * * bias = get_bias(model) */ - copy_w(__pyx_v_w->data, __pyx_v_model, (__pyx_v_nr_class * __pyx_v_nr_feature)); + copy_w(__pyx_v_w->data, __pyx_v_model, __pyx_v_len_w); + } + __pyx_L8:; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":70 - * copy_w(w.data, model, nr_class * nr_feature) + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":76 + * copy_w(w.data, model, len_w) * * bias = get_bias(model) # <<<<<<<<<<<<<< * @@ -1166,64 +1237,64 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ __pyx_v_bias = get_bias(__pyx_v_model); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":73 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":79 * * cdef np.ndarray[np.int_t, ndim=1, mode='c'] label * label = np.empty((nr_class), dtype=np.int) # <<<<<<<<<<<<<< * copy_label(label.data, model, nr_class) * */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __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_nr_class); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __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 = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong(__pyx_v_nr_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_11 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __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 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__int); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_3, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyEval_CallObjectWithKeywords(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_12 = ((PyArrayObject *)__pyx_t_11); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_bstruct_label); - __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_label, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_7 < 0)) { - PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8); + __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_label, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_6 < 0)) { + PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_label, (PyObject*)__pyx_v_label, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); + Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); __Pyx_RaiseBufferFallbackError(); } else { - PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8); + PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9); } } __pyx_bstride_0_label = __pyx_bstruct_label.strides[0]; __pyx_bshape_0_label = __pyx_bstruct_label.shape[0]; - if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_12 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_label)); __pyx_v_label = ((PyArrayObject *)__pyx_t_11); __pyx_t_11 = 0; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":74 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":80 * cdef np.ndarray[np.int_t, ndim=1, mode='c'] label * label = np.empty((nr_class), dtype=np.int) * copy_label(label.data, model, nr_class) # <<<<<<<<<<<<<< @@ -1232,7 +1303,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ copy_label(__pyx_v_label->data, __pyx_v_model, __pyx_v_nr_class); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":77 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":83 * * ### FREE * destroy_model(model) # <<<<<<<<<<<<<< @@ -1241,7 +1312,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ destroy_model(__pyx_v_model); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":78 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":84 * ### FREE * destroy_model(model) * free_problem(problem) # <<<<<<<<<<<<<< @@ -1250,7 +1321,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ free_problem(__pyx_v_problem); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":79 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":85 * destroy_model(model) * free_problem(problem) * free_parameter(param) # <<<<<<<<<<<<<< @@ -1259,7 +1330,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * */ free_parameter(__pyx_v_param); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":82 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":88 * # destroy_param(param) don't call this or it will destroy weight_label and weight * * return w, label, bias # <<<<<<<<<<<<<< @@ -1267,21 +1338,21 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * * def predict_wrap(np.ndarray[np.float64_t, ndim=2, mode='c'] T, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_11 = PyFloat_FromDouble(__pyx_v_bias); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyFloat_FromDouble(__pyx_v_bias); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_w)); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_w)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_w)); __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); __Pyx_INCREF(((PyObject *)__pyx_v_label)); - PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_label)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_label)); __Pyx_GIVEREF(((PyObject *)__pyx_v_label)); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); @@ -1290,7 +1361,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); @@ -1323,7 +1394,7 @@ static PyObject *__pyx_pf_9liblinear_train_wrap(PyObject *__pyx_self, PyObject * return __pyx_r; } -/* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":84 +/* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":90 * return w, label, bias * * def predict_wrap(np.ndarray[np.float64_t, ndim=2, mode='c'] T, # <<<<<<<<<<<<<< @@ -1407,79 +1478,79 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__coef_); if (likely(values[1])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__solver_type); if (likely(values[2])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__eps); if (likely(values[3])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__C); if (likely(values[4])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weight_label); if (likely(values[5])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 6: values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weight); if (likely(values[6])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 7: values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__label); if (likely(values[7])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 8: values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bias); if (likely(values[8])) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __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), "predict_wrap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "predict_wrap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_T = ((PyArrayObject *)values[0]); __pyx_v_coef_ = ((PyArrayObject *)values[1]); - __pyx_v_solver_type = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_solver_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_eps = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_C = __pyx_PyFloat_AsDouble(values[4]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_solver_type = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_solver_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_eps = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_C = __pyx_PyFloat_AsDouble(values[4]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_weight_label = ((PyArrayObject *)values[5]); __pyx_v_weight = ((PyArrayObject *)values[6]); __pyx_v_label = ((PyArrayObject *)values[7]); - __pyx_v_bias = __pyx_PyFloat_AsDouble(values[8]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_bias = __pyx_PyFloat_AsDouble(values[8]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else if (PyTuple_GET_SIZE(__pyx_args) != 9) { goto __pyx_L5_argtuple_error; } else { __pyx_v_T = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0)); __pyx_v_coef_ = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1)); - __pyx_v_solver_type = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_solver_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_C = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_solver_type = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_solver_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_C = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_weight_label = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5)); __pyx_v_weight = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6)); __pyx_v_label = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7)); - __pyx_v_bias = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 8)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_bias = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 8)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("predict_wrap", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("liblinear.predict_wrap"); return NULL; @@ -1496,43 +1567,43 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject __pyx_bstruct_weight_label.buf = NULL; __pyx_bstruct_weight.buf = NULL; __pyx_bstruct_label.buf = NULL; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_T), __pyx_ptype_5numpy_ndarray, 1, "T", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coef_), __pyx_ptype_5numpy_ndarray, 1, "coef_", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weight_label), __pyx_ptype_5numpy_ndarray, 1, "weight_label", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weight), __pyx_ptype_5numpy_ndarray, 1, "weight", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_label), __pyx_ptype_5numpy_ndarray, 1, "label", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_T), __pyx_ptype_5numpy_ndarray, 1, "T", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coef_), __pyx_ptype_5numpy_ndarray, 1, "coef_", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weight_label), __pyx_ptype_5numpy_ndarray, 1, "weight_label", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_weight), __pyx_ptype_5numpy_ndarray, 1, "weight", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_label), __pyx_ptype_5numpy_ndarray, 1, "label", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_T, (PyObject*)__pyx_v_T, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_T, (PyObject*)__pyx_v_T, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_T = __pyx_bstruct_T.strides[0]; __pyx_bstride_1_T = __pyx_bstruct_T.strides[1]; __pyx_bshape_0_T = __pyx_bstruct_T.shape[0]; __pyx_bshape_1_T = __pyx_bstruct_T.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_coef_, (PyObject*)__pyx_v_coef_, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_coef_, (PyObject*)__pyx_v_coef_, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_coef_ = __pyx_bstruct_coef_.strides[0]; __pyx_bstride_1_coef_ = __pyx_bstruct_coef_.strides[1]; __pyx_bshape_0_coef_ = __pyx_bstruct_coef_.shape[0]; __pyx_bshape_1_coef_ = __pyx_bstruct_coef_.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_weight_label, (PyObject*)__pyx_v_weight_label, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_weight_label, (PyObject*)__pyx_v_weight_label, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_weight_label = __pyx_bstruct_weight_label.strides[0]; __pyx_bshape_0_weight_label = __pyx_bstruct_weight_label.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_weight, (PyObject*)__pyx_v_weight, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_weight, (PyObject*)__pyx_v_weight, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_weight = __pyx_bstruct_weight.strides[0]; __pyx_bshape_0_weight = __pyx_bstruct_weight.shape[0]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_label, (PyObject*)__pyx_v_label, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_label, (PyObject*)__pyx_v_label, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_bstride_0_label = __pyx_bstruct_label.strides[0]; __pyx_bshape_0_label = __pyx_bstruct_label.shape[0]; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":96 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":102 * cdef model *model * * param = set_parameter(solver_type, eps, C, weight.shape[0], weight_label.data, weight.data) # <<<<<<<<<<<<<< @@ -1541,7 +1612,7 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject */ __pyx_v_param = set_parameter(__pyx_v_solver_type, __pyx_v_eps, __pyx_v_C, (__pyx_v_weight->dimensions[0]), __pyx_v_weight_label->data, __pyx_v_weight->data); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":98 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":104 * param = set_parameter(solver_type, eps, C, weight.shape[0], weight_label.data, weight.data) * * model = set_model(param, coef_.data, coef_.shape, label.data, bias) # <<<<<<<<<<<<<< @@ -1550,40 +1621,40 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject */ __pyx_v_model = set_model(__pyx_v_param, __pyx_v_coef_->data, __pyx_v_coef_->dimensions, __pyx_v_label->data, __pyx_v_bias); - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":100 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":106 * model = set_model(param, coef_.data, coef_.shape, label.data, bias) * * dec_values = np.empty(T.shape[0], dtype=np.int) # <<<<<<<<<<<<<< * if copy_predict(T.data, model, T.shape, dec_values.data) < 0: * raise MemoryError("We've run out of of memory") */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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 = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_to_py_npy_intp((__pyx_v_T->dimensions[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_to_py_npy_intp((__pyx_v_T->dimensions[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __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 = 100; __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 = 106; __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_t_1 = 0; - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __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_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); { __Pyx_BufFmt_StackElem __pyx_stack[1]; @@ -1600,14 +1671,14 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject } __pyx_bstride_0_dec_values = __pyx_bstruct_dec_values.strides[0]; __pyx_bshape_0_dec_values = __pyx_bstruct_dec_values.shape[0]; - if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_dec_values)); __pyx_v_dec_values = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":101 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":107 * * dec_values = np.empty(T.shape[0], dtype=np.int) * if copy_predict(T.data, model, T.shape, dec_values.data) < 0: # <<<<<<<<<<<<<< @@ -1617,29 +1688,29 @@ static PyObject *__pyx_pf_9liblinear_predict_wrap(PyObject *__pyx_self, PyObject __pyx_t_11 = (copy_predict(__pyx_v_T->data, __pyx_v_model, __pyx_v_T->dimensions, __pyx_v_dec_values->data) < 0); if (__pyx_t_11) { - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":102 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":108 * dec_values = np.empty(T.shape[0], dtype=np.int) * if copy_predict(T.data, model, T.shape, dec_values.data) < 0: * raise MemoryError("We've run out of of memory") # <<<<<<<<<<<<<< * * ### FREE */ - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_1)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); - __pyx_t_1 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_MemoryError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_1, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":106 + /* "/volatile/fabian/dev/scikit-learn/scikits/learn/src/liblinear.pyx":112 * ### FREE * # TODO: we also have to release temp allocated by set_model * return dec_values # <<<<<<<<<<<<<< @@ -3696,8 +3767,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __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[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __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 = 218; __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 = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; diff --git a/scikits/learn/src/liblinear.pyx b/scikits/learn/src/liblinear.pyx index f9a3e03f5c1672de298121009b5311431606d340..2eeb255d5463be85a1ed0954620f6127baad5007 100644 --- a/scikits/learn/src/liblinear.pyx +++ b/scikits/learn/src/liblinear.pyx @@ -46,6 +46,7 @@ def train_wrap ( np.ndarray[np.float64_t, ndim=2, mode='c'] X, cdef problem *problem cdef model *model cdef char *error_msg + cdef int len_w problem = set_problem(X.data, Y.data, X.shape, bias) @@ -64,8 +65,13 @@ def train_wrap ( np.ndarray[np.float64_t, ndim=2, mode='c'] X, cdef int nr_class = get_nr_class(model) cdef int nr_feature = get_nr_feature(model) if bias > 0: nr_feature = nr_feature + 1 - w = np.empty((nr_feature, nr_class)) - copy_w(w.data, model, nr_class * nr_feature) + if nr_class == 2: + w = np.empty(nr_feature) + copy_w(w.data, model, nr_feature) + else: + len_w = nr_class * nr_feature + w = np.empty(len_w) + copy_w(w.data, model, len_w) bias = get_bias(model) diff --git a/scikits/learn/tests/test_logistic.py b/scikits/learn/tests/test_logistic.py index 402da4fcab05d76de2325f7b3befb9b63bd6efe9..fc821e4c5f24796963466b8060549b76e01d64ee 100644 --- a/scikits/learn/tests/test_logistic.py +++ b/scikits/learn/tests/test_logistic.py @@ -4,12 +4,6 @@ from numpy.testing import assert_array_equal, \ assert_array_almost_equal, \ assert_raises -clf = logistic.LogisticRegression() -clf.fit([[-1, 0], [0, 1]], [0, 1]) -print clf.coef_[0] -print clf.predict([[-1, 0], [0, 1],]) -# assert_array_equal(clf.predict([[-1, 0], [0, 1],]), [0, 1]) - def test_predict_2_features(): clf = logistic.LogisticRegression() clf.fit([[-1, 0], [0, 1]], [0, 1])