/* Generated by Cython 0.10.3 on Fri May 22 18:28:42 2009 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #if PY_VERSION_HEX < 0x02040000 #define METH_COEXIST 0 #endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) PyInt_AsLong(o) #define PyNumber_Index(o) PyNumber_Int(o) #define PyIndex_Check(o) PyNumber_Check(o) #endif #if PY_VERSION_HEX < 0x02060000 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) #define PyVarObject_HEAD_INIT(type, size) \ PyObject_HEAD_INIT(type) size, #define PyType_Modified(t) typedef struct { void *buf; PyObject *obj; Py_ssize_t len; Py_ssize_t itemsize; int readonly; int ndim; char *format; Py_ssize_t *shape; Py_ssize_t *strides; Py_ssize_t *suboffsets; void *internal; } Py_buffer; #define PyBUF_SIMPLE 0 #define PyBUF_WRITABLE 0x0001 #define PyBUF_LOCK 0x0002 #define PyBUF_FORMAT 0x0004 #define PyBUF_ND 0x0008 #define PyBUF_STRIDES (0x0010 | PyBUF_ND) #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) #endif #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #endif #if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 #endif #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyString_Type PyBytes_Type #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define PyBytes_Type PyString_Type #endif #if PY_MAJOR_VERSION >= 3 #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #else #define _USE_MATH_DEFINES #endif #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #include #define __PYX_HAVE_API__liblinear #include "string.h" #include "stdlib.h" #include "stdio.h" #include "liblinear-1.32/linear.h" #ifdef __GNUC__ #define INLINE __inline__ #elif _WIN32 #define INLINE __inline #else #define INLINE #endif typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/ static int __pyx_skip_dispatch = 0; /* Type Conversion Predeclarations */ #if PY_MAJOR_VERSION < 3 #define __Pyx_PyBytes_FromString PyString_FromString #define __Pyx_PyBytes_AsString PyString_AsString #else #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_AsString PyBytes_AsString #endif #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) static INLINE int __Pyx_PyObject_IsTrue(PyObject* x); static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x); static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x); static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b); #define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x)) #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x); static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x); static INLINE char __pyx_PyInt_char(PyObject* x); static INLINE short __pyx_PyInt_short(PyObject* x); static INLINE int __pyx_PyInt_int(PyObject* x); static INLINE long __pyx_PyInt_long(PyObject* x); static INLINE signed char __pyx_PyInt_signed_char(PyObject* x); static INLINE signed short __pyx_PyInt_signed_short(PyObject* x); static INLINE signed int __pyx_PyInt_signed_int(PyObject* x); static INLINE signed long __pyx_PyInt_signed_long(PyObject* x); static INLINE long double __pyx_PyInt_long_double(PyObject* x); #ifdef __GNUC__ /* Test for GCC > 2.95 */ #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* __GNUC__ > 2 ... */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ > 2 ... */ #else /* __GNUC__ */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char **__pyx_f; static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) { PyObject *r; if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) { r = PyList_GET_ITEM(o, i); Py_INCREF(r); } else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) { r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); } else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0) || !is_unsigned)) r = PySequence_GetItem(o, i); else { PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i); if (!j) return 0; r = PyObject_GetItem(o, j); Py_DECREF(j); } return r; } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_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_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ static INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ static INLINE int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v, int is_unsigned) { int r; if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) { Py_DECREF(PyList_GET_ITEM(o, i)); Py_INCREF(v); PyList_SET_ITEM(o, i, v); return 1; } else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0) || !is_unsigned)) r = PySequence_SetItem(o, i, v); else { PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i); if (!j) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); } return r; } static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ #include "descrobject.h" static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static 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 { return PyObject_CallMethod(L, "append", "(O)", x); } } static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ static int __Pyx_Print(PyObject *, int); /*proto*/ #if PY_MAJOR_VERSION >= 3 static PyObject* __pyx_print = 0; static PyObject* __pyx_print_kwargs = 0; #endif static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/ static int __Pyx_EndUnpack(PyObject *); /*proto*/ static void __Pyx_WriteUnraisable(const char *name); /*proto*/ static void __Pyx_AddTraceback(const char *funcname); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Type declarations */ /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":85 * #---------------------------------------------------------------- wrapper class * * cdef class Parameter: # <<<<<<<<<<<<<< * * cdef parameter param */ struct __pyx_obj_9liblinear_Parameter { PyObject_HEAD struct parameter param; }; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":186 * #----------------------------------------------------------------- wrapper class * * cdef class LinearSVM: # <<<<<<<<<<<<<< * * cdef model * mod */ struct __pyx_obj_9liblinear_LinearSVM { PyObject_HEAD struct model *mod; }; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":116 * #----------------------------------------------------------------- wrapper class * * cdef class Problem: # <<<<<<<<<<<<<< * * """ wraps liblinears problem struct """ */ struct __pyx_obj_9liblinear_Problem { PyObject_HEAD struct problem prob; int num_feat; int num_classes; int num_all; }; /* Module declarations from liblinear_enums */ /* Module declarations from liblinear */ static PyTypeObject *__pyx_ptype_9liblinear_Parameter = 0; static PyTypeObject *__pyx_ptype_9liblinear_Problem = 0; static PyTypeObject *__pyx_ptype_9liblinear_LinearSVM = 0; static PyObject *__pyx_k_8; static PyObject *__pyx_k_9; static int __pyx_f_9liblinear_find_max_column(PyObject *); /*proto*/ static struct feature_node *__pyx_f_9liblinear_build_vector(PyObject *, int); /*proto*/ /* Implementation of liblinear */ static char __pyx_k_7[] = "1.1.5"; static PyObject *__pyx_int_0; static PyObject *__pyx_int_2; static PyObject *__pyx_int_1; static char __pyx_k___init__[] = "__init__"; static PyObject *__pyx_kp___init__; static char __pyx_k_release[] = "release"; static PyObject *__pyx_kp_release; static char __pyx_k_train[] = "train"; static PyObject *__pyx_kp_train; static char __pyx_k_1[] = "build_confusion_matrix"; static PyObject *__pyx_kp_1; static char __pyx_k_tostring[] = "tostring"; static PyObject *__pyx_kp_tostring; static char __pyx_k_fromstring[] = "fromstring"; static PyObject *__pyx_kp_fromstring; static char __pyx_k___reduce__[] = "__reduce__"; static PyObject *__pyx_kp___reduce__; static char __pyx_k_predict[] = "predict"; static PyObject *__pyx_kp_predict; static char __pyx_k_2[] = "predict_probabilites"; static PyObject *__pyx_kp_2; static char __pyx_k_predict_values[] = "predict_values"; static PyObject *__pyx_kp_predict_values; static char __pyx_k_get_weights[] = "get_weights"; static PyObject *__pyx_kp_get_weights; static char __pyx_k_get_bias[] = "get_bias"; static PyObject *__pyx_kp_get_bias; static char __pyx_k_txt[] = "txt"; static PyObject *__pyx_kp_txt; static char __pyx_k_vec[] = "vec"; static PyObject *__pyx_kp_vec; static char __pyx_k_mat[] = "mat"; static PyObject *__pyx_kp_mat; static char __pyx_k_mach[] = "mach"; static PyObject *__pyx_kp_mach; static char __pyx_k_eps[] = "eps"; static PyObject *__pyx_kp_eps; static char __pyx_k_C[] = "C"; static PyObject *__pyx_kp_C; static char __pyx_k_weights[] = "weights"; static PyObject *__pyx_kp_weights; static char __pyx_k_num_classes[] = "num_classes"; static PyObject *__pyx_kp_num_classes; static char __pyx_k_data[] = "data"; static PyObject *__pyx_kp_data; static char __pyx_k_verbose[] = "verbose"; static PyObject *__pyx_kp_verbose; static char __pyx_k_input[] = "input"; static PyObject *__pyx_kp_input; static char __pyx_k_num_folds[] = "num_folds"; static PyObject *__pyx_kp_num_folds; static char __pyx_k_zlib[] = "zlib"; static PyObject *__pyx_kp_zlib; static char __pyx_k_3[] = "L2_LR"; static PyObject *__pyx_kp_3; static char __pyx_k_4[] = "L2LOSS_SVM_DUAL"; static PyObject *__pyx_kp_4; static char __pyx_k_5[] = "L2LOSS_SVM"; static PyObject *__pyx_kp_5; static char __pyx_k_6[] = "L1LOSS_SVM_DUAL"; static PyObject *__pyx_kp_6; static char __pyx_k_MCSVM_CS[] = "MCSVM_CS"; static PyObject *__pyx_kp_MCSVM_CS; static char __pyx_k_version[] = "version"; static PyObject *__pyx_kp_version; static char __pyx_k_decompress[] = "decompress"; static PyObject *__pyx_kp_decompress; static char __pyx_k_enumerate[] = "enumerate"; static PyObject *__pyx_kp_enumerate; static char __pyx_k_ndim[] = "ndim"; static PyObject *__pyx_kp_ndim; static char __pyx_k_ValueError[] = "ValueError"; static PyObject *__pyx_kp_ValueError; static char __pyx_k_append[] = "append"; static PyObject *__pyx_kp_append; static char __pyx_k_13[] = "VERBOSE"; static PyObject *__pyx_kp_13; static char __pyx_k_14[] = "got"; static PyObject *__pyx_kp_14; static char __pyx_k_RuntimeError[] = "RuntimeError"; static PyObject *__pyx_kp_RuntimeError; static char __pyx_k___fromstring[] = "__fromstring"; static PyObject *__pyx_kp___fromstring; static char __pyx_k_compress[] = "compress"; static PyObject *__pyx_kp_compress; static char __pyx_k_range[] = "range"; static PyObject *__pyx_kp_range; static PyObject *__pyx_kp_7; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_kp_10; static char __pyx_k_10[] = "mat argument is not a matrix"; static PyObject *__pyx_kp_11; static char __pyx_k_11[] = "data and weights do not fit"; static PyObject *__pyx_kp_12; static char __pyx_k_12[] = "you should not use __init__ for training, usetrain() instead"; static PyObject *__pyx_kp_15; static PyObject *__pyx_kp_16; static PyObject *__pyx_kp_17; static PyObject *__pyx_kp_18; static PyObject *__pyx_kp_19; static PyObject *__pyx_kp_20; static PyObject *__pyx_kp_21; static PyObject *__pyx_kp_22; static char __pyx_k_15[] = "classes to learn"; static char __pyx_k_16[] = "need at least two classes"; static char __pyx_k_17[] = "data has wrong dimension, must be tuple of vector lists"; static char __pyx_k_18[] = "build Problem"; static char __pyx_k_19[] = "configure machine"; static char __pyx_k_20[] = "param invalid: "; static char __pyx_k_21[] = "start training"; static char __pyx_k_22[] = "finished training"; static PyObject *__pyx_kp_23; static char __pyx_k_23[] = "need %d classes to evaluate"; static PyObject *__pyx_kp_24; static char __pyx_k_24[] = "error when creating model from stream"; static PyObject *__pyx_kp_25; static char __pyx_k_25[] = "method only allowed for L2_LR method"; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":16 * # TODO: scipy sparse matrices !!! * * def __fromstring(txt): # <<<<<<<<<<<<<< * """ needed later on for pickling LinearSVM objects """ * return LinearSVM.fromstring(zlib.decompress(txt)) */ static PyObject *__pyx_pf_9liblinear___fromstring(PyObject *__pyx_self, PyObject *__pyx_v_txt); /*proto*/ static char __pyx_doc_9liblinear___fromstring[] = " needed later on for pickling LinearSVM objects "; static PyObject *__pyx_pf_9liblinear___fromstring(PyObject *__pyx_self, PyObject *__pyx_v_txt) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; __pyx_self = __pyx_self; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":18 * def __fromstring(txt): * """ needed later on for pickling LinearSVM objects """ * return LinearSVM.fromstring(zlib.decompress(txt)) # <<<<<<<<<<<<<< * * #=============================================================================== */ __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_LinearSVM)), __pyx_kp_fromstring); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_zlib); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_decompress); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_txt); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_txt); __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); __pyx_4 = 0; __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; __pyx_r = __pyx_2; __pyx_2 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("liblinear.__fromstring"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":29 * #=============================================================================== * * def vector2sparse(vec): # <<<<<<<<<<<<<< * """ convert list of values to its sparse representation """ * return list(enumerate(vec)) */ static PyObject *__pyx_pf_9liblinear_vector2sparse(PyObject *__pyx_self, PyObject *__pyx_v_vec); /*proto*/ static char __pyx_doc_9liblinear_vector2sparse[] = " convert list of values to its sparse representation "; static PyObject *__pyx_pf_9liblinear_vector2sparse(PyObject *__pyx_self, PyObject *__pyx_v_vec) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; __pyx_self = __pyx_self; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":31 * def vector2sparse(vec): * """ convert list of values to its sparse representation """ * return list(enumerate(vec)) # <<<<<<<<<<<<<< * * def matrix2sparse(mat): */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_vec); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_vec); __pyx_2 = PyObject_Call(__pyx_builtin_enumerate, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); __pyx_2 = 0; __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __pyx_r = __pyx_2; __pyx_2 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); __Pyx_AddTraceback("liblinear.vector2sparse"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":33 * return list(enumerate(vec)) * * def matrix2sparse(mat): # <<<<<<<<<<<<<< * """ convert matrix or list of lists to sparse representation """ * */ static PyObject *__pyx_pf_9liblinear_matrix2sparse(PyObject *__pyx_self, PyObject *__pyx_v_mat); /*proto*/ static char __pyx_doc_9liblinear_matrix2sparse[] = " convert matrix or list of lists to sparse representation "; static PyObject *__pyx_pf_9liblinear_matrix2sparse(PyObject *__pyx_self, PyObject *__pyx_v_mat) { PyObject *__pyx_v_rv; PyObject *__pyx_v_row; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; int __pyx_3; Py_ssize_t __pyx_4 = 0; PyObject *__pyx_5 = 0; __pyx_self = __pyx_self; __pyx_v_rv = Py_None; Py_INCREF(Py_None); __pyx_v_row = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":36 * """ convert matrix or list of lists to sparse representation """ * * if mat.ndim != 2: # <<<<<<<<<<<<<< * raise ValueError("mat argument is not a matrix") * rv = [] */ __pyx_1 = PyObject_GetAttr(__pyx_v_mat, __pyx_kp_ndim); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = PyObject_RichCompare(__pyx_1, __pyx_int_2, Py_NE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":37 * * if mat.ndim != 2: * raise ValueError("mat argument is not a matrix") # <<<<<<<<<<<<<< * rv = [] * for row in mat: */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_10); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_10); __pyx_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":38 * if mat.ndim != 2: * raise ValueError("mat argument is not a matrix") * rv = [] # <<<<<<<<<<<<<< * for row in mat: * rv.append(list(enumerate(row))) */ __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_rv); __pyx_v_rv = ((PyObject *)__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":39 * raise ValueError("mat argument is not a matrix") * rv = [] * for row in mat: # <<<<<<<<<<<<<< * rv.append(list(enumerate(row))) * return rv */ if (PyList_CheckExact(__pyx_v_mat) || PyTuple_CheckExact(__pyx_v_mat)) { __pyx_4 = 0; __pyx_2 = __pyx_v_mat; Py_INCREF(__pyx_2); } else { __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_mat); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } for (;;) { if (likely(PyList_CheckExact(__pyx_2))) { if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break; __pyx_1 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_1); __pyx_4++; } else if (likely(PyTuple_CheckExact(__pyx_2))) { if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break; __pyx_1 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_1); __pyx_4++; } else { __pyx_1 = PyIter_Next(__pyx_2); if (!__pyx_1) { if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } } Py_DECREF(__pyx_v_row); __pyx_v_row = __pyx_1; __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":40 * rv = [] * for row in mat: * rv.append(list(enumerate(row))) # <<<<<<<<<<<<<< * return rv * */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_row); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_row); __pyx_5 = PyObject_Call(__pyx_builtin_enumerate, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_1, 0, __pyx_5); __pyx_5 = 0; __pyx_5 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __pyx_1 = __Pyx_PyObject_Append(__pyx_v_rv, __pyx_5); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; } Py_DECREF(__pyx_2); __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":41 * for row in mat: * rv.append(list(enumerate(row))) * return rv # <<<<<<<<<<<<<< * * cdef int find_max_column(data): */ Py_INCREF(__pyx_v_rv); __pyx_r = __pyx_v_rv; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("liblinear.matrix2sparse"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_rv); Py_DECREF(__pyx_v_row); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":43 * return rv * * cdef int find_max_column(data): # <<<<<<<<<<<<<< * """ find maximal column in sparse matrix """ * */ static int __pyx_f_9liblinear_find_max_column(PyObject *__pyx_v_data) { int __pyx_v_num_data; int __pyx_v_i; int __pyx_v_j; int __pyx_v_idx; int __pyx_v_maxidx; PyObject *__pyx_v_vec; PyObject *__pyx_v_n; int __pyx_r; Py_ssize_t __pyx_1 = 0; PyObject *__pyx_2 = 0; int __pyx_3; PyObject *__pyx_4 = 0; int __pyx_5; int __pyx_6; __pyx_v_vec = Py_None; Py_INCREF(Py_None); __pyx_v_n = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":46 * """ find maximal column in sparse matrix """ * * cdef int num_data = len(data) # <<<<<<<<<<<<<< * cdef int i, j, idx * cdef int maxidx = - 1 */ __pyx_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_num_data = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":48 * cdef int num_data = len(data) * cdef int i, j, idx * cdef int maxidx = - 1 # <<<<<<<<<<<<<< * * for i from 0 <= i < num_data: */ __pyx_v_maxidx = -1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":50 * cdef int maxidx = - 1 * * for i from 0 <= i < num_data: # <<<<<<<<<<<<<< * vec = data[i] * n = len(vec) */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_data; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":51 * * for i from 0 <= i < num_data: * vec = data[i] # <<<<<<<<<<<<<< * n = len(vec) * for j from 0 <= j < n: */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_vec); __pyx_v_vec = __pyx_2; __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":52 * for i from 0 <= i < num_data: * vec = data[i] * n = len(vec) # <<<<<<<<<<<<<< * for j from 0 <= j < n: * idx = vec[j][0] */ __pyx_1 = PyObject_Length(__pyx_v_vec); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = PyInt_FromSsize_t(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_n); __pyx_v_n = __pyx_2; __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":53 * vec = data[i] * n = len(vec) * for j from 0 <= j < n: # <<<<<<<<<<<<<< * idx = vec[j][0] * idx += 1 # +1: see comment above ! */ __pyx_3 = __pyx_PyInt_int(__pyx_v_n); if (unlikely((__pyx_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; __pyx_v_j++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":54 * n = len(vec) * for j from 0 <= j < n: * idx = vec[j][0] # <<<<<<<<<<<<<< * idx += 1 # +1: see comment above ! * if idx <= 0: # invalid, not allowd to happen ! */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_vec, __pyx_v_j, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = __Pyx_GetItemInt(__pyx_2, 0, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_5 = __pyx_PyInt_int(__pyx_4); if (unlikely((__pyx_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_v_idx = __pyx_5; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":55 * for j from 0 <= j < n: * idx = vec[j][0] * idx += 1 # +1: see comment above ! # <<<<<<<<<<<<<< * if idx <= 0: # invalid, not allowd to happen ! * return - 1 */ __pyx_v_idx += 1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":56 * idx = vec[j][0] * idx += 1 # +1: see comment above ! * if idx <= 0: # invalid, not allowd to happen ! # <<<<<<<<<<<<<< * return - 1 * if idx > maxidx: maxidx = idx */ __pyx_6 = (__pyx_v_idx <= 0); if (__pyx_6) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":57 * idx += 1 # +1: see comment above ! * if idx <= 0: # invalid, not allowd to happen ! * return - 1 # <<<<<<<<<<<<<< * if idx > maxidx: maxidx = idx * return maxidx */ __pyx_r = -1; goto __pyx_L0; goto __pyx_L7; } __pyx_L7:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":58 * if idx <= 0: # invalid, not allowd to happen ! * return - 1 * if idx > maxidx: maxidx = idx # <<<<<<<<<<<<<< * return maxidx * */ __pyx_6 = (__pyx_v_idx > __pyx_v_maxidx); if (__pyx_6) { __pyx_v_maxidx = __pyx_v_idx; goto __pyx_L8; } __pyx_L8:; } } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":59 * return - 1 * if idx > maxidx: maxidx = idx * return maxidx # <<<<<<<<<<<<<< * * cdef feature_node * build_vector(list vec, int num_feat): */ __pyx_r = __pyx_v_maxidx; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); __Pyx_WriteUnraisable("liblinear.find_max_column"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_vec); Py_DECREF(__pyx_v_n); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":61 * return maxidx * * cdef feature_node * build_vector(list vec, int num_feat): # <<<<<<<<<<<<<< * """ builds vector from python list. list contains tuples (index, value), * each vector gets value 1 at its end for incorporating bias term """ */ static struct feature_node *__pyx_f_9liblinear_build_vector(PyObject *__pyx_v_vec, int __pyx_v_num_feat) { int __pyx_v_n; int __pyx_v_j; int __pyx_v_idx; struct feature_node *__pyx_v_nodes; PyObject *__pyx_v_node; struct feature_node *__pyx_r; Py_ssize_t __pyx_1 = 0; PyObject *__pyx_2 = 0; int __pyx_3; double __pyx_4; __pyx_v_node = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":66 * * cdef: * int n = len(vec) # <<<<<<<<<<<<<< * int j, idx * feature_node * nodes */ __pyx_1 = PyObject_Length(((PyObject *)__pyx_v_vec)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_n = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":70 * feature_node * nodes * * nodes = < feature_node *> malloc((n + 2) * sizeof(feature_node)) # <<<<<<<<<<<<<< * * for j from 0 <= j < n: */ __pyx_v_nodes = ((struct feature_node *)malloc(((__pyx_v_n + 2) * (sizeof(struct feature_node))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":72 * nodes = < feature_node *> malloc((n + 2) * sizeof(feature_node)) * * for j from 0 <= j < n: # <<<<<<<<<<<<<< * node = vec[j] * idx = node[0] */ for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_n; __pyx_v_j++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":73 * * for j from 0 <= j < n: * node = vec[j] # <<<<<<<<<<<<<< * idx = node[0] * nodes[j].index = idx + 1 # +1: see "important note" above */ __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_vec), __pyx_v_j, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_node); __pyx_v_node = __pyx_2; __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":74 * for j from 0 <= j < n: * node = vec[j] * idx = node[0] # <<<<<<<<<<<<<< * nodes[j].index = idx + 1 # +1: see "important note" above * nodes[j].value = node[1] */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_node, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = __pyx_PyInt_int(__pyx_2); if (unlikely((__pyx_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_v_idx = __pyx_3; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":75 * node = vec[j] * idx = node[0] * nodes[j].index = idx + 1 # +1: see "important note" above # <<<<<<<<<<<<<< * nodes[j].value = node[1] * */ (__pyx_v_nodes[__pyx_v_j]).index = (__pyx_v_idx + 1); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":76 * idx = node[0] * nodes[j].index = idx + 1 # +1: see "important note" above * nodes[j].value = node[1] # <<<<<<<<<<<<<< * * nodes[n].index = num_feat + 1 # bias node */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_node, 1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = __pyx_PyFloat_AsDouble(__pyx_2); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; (__pyx_v_nodes[__pyx_v_j]).value = __pyx_4; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":78 * nodes[j].value = node[1] * * nodes[n].index = num_feat + 1 # bias node # <<<<<<<<<<<<<< * nodes[n].value = 1 # bias "feature" * nodes[n + 1].index = - 1 # end marker */ (__pyx_v_nodes[__pyx_v_n]).index = (__pyx_v_num_feat + 1); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":79 * * nodes[n].index = num_feat + 1 # bias node * nodes[n].value = 1 # bias "feature" # <<<<<<<<<<<<<< * nodes[n + 1].index = - 1 # end marker * return nodes */ (__pyx_v_nodes[__pyx_v_n]).value = 1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":80 * nodes[n].index = num_feat + 1 # bias node * nodes[n].value = 1 # bias "feature" * nodes[n + 1].index = - 1 # end marker # <<<<<<<<<<<<<< * return nodes * */ (__pyx_v_nodes[(__pyx_v_n + 1)]).index = -1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":81 * nodes[n].value = 1 # bias "feature" * nodes[n + 1].index = - 1 # end marker * return nodes # <<<<<<<<<<<<<< * * #---------------------------------------------------------------- wrapper class */ __pyx_r = __pyx_v_nodes; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); __Pyx_WriteUnraisable("liblinear.build_vector"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_node); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":89 * cdef parameter param * * def __init__(self, mach, eps, C, weights, num_classes): # <<<<<<<<<<<<<< * * if weights is not None: */ static int __pyx_pf_9liblinear_9Parameter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pf_9liblinear_9Parameter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_mach = 0; PyObject *__pyx_v_eps = 0; PyObject *__pyx_v_C = 0; PyObject *__pyx_v_weights = 0; PyObject *__pyx_v_num_classes = 0; int __pyx_v_i; int __pyx_r; int __pyx_1; Py_ssize_t __pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; int __pyx_5; double __pyx_6; size_t __pyx_7; PyObject *__pyx_t_1 = NULL; static PyObject **__pyx_pyargnames[] = {&__pyx_kp_mach,&__pyx_kp_eps,&__pyx_kp_C,&__pyx_kp_weights,&__pyx_kp_num_classes,0}; if (unlikely(__pyx_kwds)) { PyObject* values[5] = {0,0,0,0,0}; Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); 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); 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; } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_mach); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; case 1: values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_eps); if (likely(values[1])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_C); if (likely(values[2])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_weights); if (likely(values[3])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_num_classes); if (likely(values[4])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __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), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_mach = values[0]; __pyx_v_eps = values[1]; __pyx_v_C = values[2]; __pyx_v_weights = values[3]; __pyx_v_num_classes = values[4]; } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { __pyx_v_mach = PyTuple_GET_ITEM(__pyx_args, 0); __pyx_v_eps = PyTuple_GET_ITEM(__pyx_args, 1); __pyx_v_C = PyTuple_GET_ITEM(__pyx_args, 2); __pyx_v_weights = PyTuple_GET_ITEM(__pyx_args, 3); __pyx_v_num_classes = PyTuple_GET_ITEM(__pyx_args, 4); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("liblinear.Parameter.__init__"); return -1; __pyx_L4_argument_unpacking_done:; Py_INCREF(__pyx_v_weights); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":91 * def __init__(self, mach, eps, C, weights, num_classes): * * if weights is not None: # <<<<<<<<<<<<<< * if len(weights) != num_classes: * raise ValueError("data and weights do not fit") */ __pyx_1 = (__pyx_v_weights != Py_None); if (__pyx_1) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":92 * * if weights is not None: * if len(weights) != num_classes: # <<<<<<<<<<<<<< * raise ValueError("data and weights do not fit") * else: */ __pyx_2 = PyObject_Length(__pyx_v_weights); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyInt_FromSsize_t(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyObject_RichCompare(__pyx_3, __pyx_v_num_classes, Py_NE); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_1) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":93 * if weights is not None: * if len(weights) != num_classes: * raise ValueError("data and weights do not fit") # <<<<<<<<<<<<<< * else: * weights = [1.0] * num_classes */ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_11); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_kp_11); __pyx_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; goto __pyx_L6; } /*else*/ { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":95 * raise ValueError("data and weights do not fit") * else: * weights = [1.0] * num_classes # <<<<<<<<<<<<<< * * self.param.solver_type = mach */ __pyx_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyList_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyList_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_4), __pyx_v_num_classes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0; Py_DECREF(__pyx_v_weights); __pyx_v_weights = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L6:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":97 * weights = [1.0] * num_classes * * self.param.solver_type = mach # <<<<<<<<<<<<<< * self.param.eps = eps * self.param.C = C */ __pyx_5 = __pyx_PyInt_int(__pyx_v_mach); if (unlikely((__pyx_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.solver_type = __pyx_5; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":98 * * self.param.solver_type = mach * self.param.eps = eps # <<<<<<<<<<<<<< * self.param.C = C * */ __pyx_6 = __pyx_PyFloat_AsDouble(__pyx_v_eps); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.eps = __pyx_6; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":99 * self.param.solver_type = mach * self.param.eps = eps * self.param.C = C # <<<<<<<<<<<<<< * * self.param.nr_weight = num_classes */ __pyx_6 = __pyx_PyFloat_AsDouble(__pyx_v_C); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.C = __pyx_6; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":101 * self.param.C = C * * self.param.nr_weight = num_classes # <<<<<<<<<<<<<< * self.param.weight = < double *> malloc(num_classes * sizeof(double)) * self.param.weight_label = < int *> malloc(num_classes * sizeof(int)) */ __pyx_5 = __pyx_PyInt_int(__pyx_v_num_classes); if (unlikely((__pyx_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.nr_weight = __pyx_5; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":102 * * self.param.nr_weight = num_classes * self.param.weight = < double *> malloc(num_classes * sizeof(double)) # <<<<<<<<<<<<<< * self.param.weight_label = < int *> malloc(num_classes * sizeof(int)) * */ __pyx_3 = PyInt_FromLong((sizeof(double))); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Multiply(__pyx_v_num_classes, __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_7 = PyInt_AsUnsignedLongMask(__pyx_t_1); if (unlikely((__pyx_7 == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight = ((double *)malloc(__pyx_7)); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":103 * self.param.nr_weight = num_classes * self.param.weight = < double *> malloc(num_classes * sizeof(double)) * self.param.weight_label = < int *> malloc(num_classes * sizeof(int)) # <<<<<<<<<<<<<< * * cdef int i */ __pyx_4 = PyInt_FromLong((sizeof(int))); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Multiply(__pyx_v_num_classes, __pyx_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_7 = PyInt_AsUnsignedLongMask(__pyx_t_1); if (unlikely((__pyx_7 == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; ((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight_label = ((int *)malloc(__pyx_7)); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":106 * * cdef int i * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * self.param.weight[i] = weights[i] * self.param.weight_label[i] = i */ __pyx_5 = __pyx_PyInt_int(__pyx_v_num_classes); if (unlikely((__pyx_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":107 * cdef int i * for i from 0 <= i < num_classes: * self.param.weight[i] = weights[i] # <<<<<<<<<<<<<< * self.param.weight_label[i] = i * */ __pyx_3 = __Pyx_GetItemInt(__pyx_v_weights, __pyx_v_i, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = __pyx_PyFloat_AsDouble(__pyx_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; (((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight[__pyx_v_i]) = __pyx_6; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":108 * for i from 0 <= i < num_classes: * self.param.weight[i] = weights[i] * self.param.weight_label[i] = i # <<<<<<<<<<<<<< * * def release(self): */ (((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight_label[__pyx_v_i]) = __pyx_v_i; } __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("liblinear.Parameter.__init__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_weights); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":110 * self.param.weight_label[i] = i * * def release(self): # <<<<<<<<<<<<<< * free(self.param.weight) * free(self.param.weight_label) */ static PyObject *__pyx_pf_9liblinear_9Parameter_release(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ static PyObject *__pyx_pf_9liblinear_9Parameter_release(PyObject *__pyx_v_self, PyObject *unused) { PyObject *__pyx_r; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":111 * * def release(self): * free(self.param.weight) # <<<<<<<<<<<<<< * free(self.param.weight_label) * */ free(((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":112 * def release(self): * free(self.param.weight) * free(self.param.weight_label) # <<<<<<<<<<<<<< * * #----------------------------------------------------------------- wrapper class */ free(((struct __pyx_obj_9liblinear_Parameter *)__pyx_v_self)->param.weight_label); __pyx_r = Py_None; Py_INCREF(Py_None); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":125 * cdef int num_all * * def __init__(self, data): # <<<<<<<<<<<<<< * * cdef int num_classes = len(data) */ static int __pyx_pf_9liblinear_7Problem___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pf_9liblinear_7Problem___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; int __pyx_v_num_classes; int *__pyx_v_num_in_class; int __pyx_v_num_all; int __pyx_v_num_feat; int __pyx_v_i; int __pyx_v_j; int __pyx_v_n; struct problem __pyx_v_prob; int __pyx_r; Py_ssize_t __pyx_1 = 0; PyObject *__pyx_2 = 0; int __pyx_3; int __pyx_4; PyObject *__pyx_5 = 0; static PyObject **__pyx_pyargnames[] = {&__pyx_kp_data,0}; if (unlikely(__pyx_kwds)) { PyObject* values[1] = {0}; Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); 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; } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_data); 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, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_data = values[0]; } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0); } 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 = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("liblinear.Problem.__init__"); return -1; __pyx_L4_argument_unpacking_done:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":127 * def __init__(self, data): * * cdef int num_classes = len(data) # <<<<<<<<<<<<<< * cdef int * num_in_class * cdef int num_all */ __pyx_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_num_classes = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":136 * * #----------------------------------------------------- count class sizes * num_all = 0 # <<<<<<<<<<<<<< * num_in_class = < int *> malloc(num_classes * sizeof(int)) * for i from 0 <= i < num_classes: */ __pyx_v_num_all = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":137 * #----------------------------------------------------- count class sizes * num_all = 0 * num_in_class = < int *> malloc(num_classes * sizeof(int)) # <<<<<<<<<<<<<< * for i from 0 <= i < num_classes: * num_in_class[i] = len(data[i]) */ __pyx_v_num_in_class = ((int *)malloc((__pyx_v_num_classes * (sizeof(int))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":138 * num_all = 0 * num_in_class = < int *> malloc(num_classes * sizeof(int)) * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * num_in_class[i] = len(data[i]) * num_all += num_in_class[i] */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_classes; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":139 * num_in_class = < int *> malloc(num_classes * sizeof(int)) * for i from 0 <= i < num_classes: * num_in_class[i] = len(data[i]) # <<<<<<<<<<<<<< * num_all += num_in_class[i] * */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_1 = PyObject_Length(__pyx_2); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; (__pyx_v_num_in_class[__pyx_v_i]) = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":140 * for i from 0 <= i < num_classes: * num_in_class[i] = len(data[i]) * num_all += num_in_class[i] # <<<<<<<<<<<<<< * * prob.l = num_all */ __pyx_v_num_all += (__pyx_v_num_in_class[__pyx_v_i]); } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":142 * num_all += num_in_class[i] * * prob.l = num_all # <<<<<<<<<<<<<< * * #------------------------------------------------------------ set labels */ __pyx_v_prob.l = __pyx_v_num_all; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":145 * * #------------------------------------------------------------ set labels * prob.y = < int *> malloc(num_all * sizeof(int)) # <<<<<<<<<<<<<< * n = 0 * for i from 0 <= i < num_classes: */ __pyx_v_prob.y = ((int *)malloc((__pyx_v_num_all * (sizeof(int))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":146 * #------------------------------------------------------------ set labels * prob.y = < int *> malloc(num_all * sizeof(int)) * n = 0 # <<<<<<<<<<<<<< * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: */ __pyx_v_n = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":147 * prob.y = < int *> malloc(num_all * sizeof(int)) * n = 0 * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * for j from 0 <= j < num_in_class[i]: * prob.y[n] = i */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_classes; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":148 * n = 0 * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: # <<<<<<<<<<<<<< * prob.y[n] = i * n += 1 */ __pyx_3 = (__pyx_v_num_in_class[__pyx_v_i]); for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; __pyx_v_j++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":149 * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: * prob.y[n] = i # <<<<<<<<<<<<<< * n += 1 * */ (__pyx_v_prob.y[__pyx_v_n]) = __pyx_v_i; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":150 * for j from 0 <= j < num_in_class[i]: * prob.y[n] = i * n += 1 # <<<<<<<<<<<<<< * * #----------- get max column index of sparse vectors = number of features */ __pyx_v_n += 1; } } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":153 * * #----------- get max column index of sparse vectors = number of features * num_feat = - 1 # <<<<<<<<<<<<<< * for i from 0 <= i < num_classes: * n = find_max_column(data[i]) */ __pyx_v_num_feat = -1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":154 * #----------- get max column index of sparse vectors = number of features * num_feat = - 1 * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * n = find_max_column(data[i]) * if n > num_feat: */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_classes; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":155 * num_feat = - 1 * for i from 0 <= i < num_classes: * n = find_max_column(data[i]) # <<<<<<<<<<<<<< * if n > num_feat: * num_feat = n */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_n = __pyx_f_9liblinear_find_max_column(__pyx_2); Py_DECREF(__pyx_2); __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":156 * for i from 0 <= i < num_classes: * n = find_max_column(data[i]) * if n > num_feat: # <<<<<<<<<<<<<< * num_feat = n * */ __pyx_4 = (__pyx_v_n > __pyx_v_num_feat); if (__pyx_4) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":157 * n = find_max_column(data[i]) * if n > num_feat: * num_feat = n # <<<<<<<<<<<<<< * * #------------------------------------------ build sparse feature vectors */ __pyx_v_num_feat = __pyx_v_n; goto __pyx_L14; } __pyx_L14:; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":160 * * #------------------------------------------ build sparse feature vectors * prob.x = < feature_node **> malloc(num_all * sizeof(feature_node *)) # <<<<<<<<<<<<<< * n = 0 * for i from 0 <= i < num_classes: */ __pyx_v_prob.x = ((struct feature_node **)malloc((__pyx_v_num_all * (sizeof(struct feature_node *))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":161 * #------------------------------------------ build sparse feature vectors * prob.x = < feature_node **> malloc(num_all * sizeof(feature_node *)) * n = 0 # <<<<<<<<<<<<<< * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: */ __pyx_v_n = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":162 * prob.x = < feature_node **> malloc(num_all * sizeof(feature_node *)) * n = 0 * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * for j from 0 <= j < num_in_class[i]: * prob.x[n] = build_vector(data[i][j], num_feat) */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_classes; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":163 * n = 0 * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: # <<<<<<<<<<<<<< * prob.x[n] = build_vector(data[i][j], num_feat) * n += 1 */ __pyx_3 = (__pyx_v_num_in_class[__pyx_v_i]); for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; __pyx_v_j++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":164 * for i from 0 <= i < num_classes: * for j from 0 <= j < num_in_class[i]: * prob.x[n] = build_vector(data[i][j], num_feat) # <<<<<<<<<<<<<< * n += 1 * */ __pyx_2 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = __Pyx_GetItemInt(__pyx_2, __pyx_v_j, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (!(likely(PyList_CheckExact(__pyx_5)) || (__pyx_5) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} (__pyx_v_prob.x[__pyx_v_n]) = __pyx_f_9liblinear_build_vector(((PyObject *)__pyx_5), __pyx_v_num_feat); Py_DECREF(__pyx_5); __pyx_5 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":165 * for j from 0 <= j < num_in_class[i]: * prob.x[n] = build_vector(data[i][j], num_feat) * n += 1 # <<<<<<<<<<<<<< * * prob.bias = 1 */ __pyx_v_n += 1; } } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":167 * n += 1 * * prob.bias = 1 # <<<<<<<<<<<<<< * prob.n = num_feat + 1 # +1 because bias term * */ __pyx_v_prob.bias = 1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":168 * * prob.bias = 1 * prob.n = num_feat + 1 # +1 because bias term # <<<<<<<<<<<<<< * * self.prob = prob */ __pyx_v_prob.n = (__pyx_v_num_feat + 1); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":170 * prob.n = num_feat + 1 # +1 because bias term * * self.prob = prob # <<<<<<<<<<<<<< * self.num_feat = num_feat * self.num_all = num_all */ ((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->prob = __pyx_v_prob; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":171 * * self.prob = prob * self.num_feat = num_feat # <<<<<<<<<<<<<< * self.num_all = num_all * self.num_classes = num_classes */ ((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->num_feat = __pyx_v_num_feat; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":172 * self.prob = prob * self.num_feat = num_feat * self.num_all = num_all # <<<<<<<<<<<<<< * self.num_classes = num_classes * */ ((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->num_all = __pyx_v_num_all; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":173 * self.num_feat = num_feat * self.num_all = num_all * self.num_classes = num_classes # <<<<<<<<<<<<<< * * */ ((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->num_classes = __pyx_v_num_classes; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("liblinear.Problem.__init__"); __pyx_r = -1; __pyx_L0:; return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":176 * * * def release(self): # <<<<<<<<<<<<<< * """ frees memory """ * cdef int i */ static PyObject *__pyx_pf_9liblinear_7Problem_release(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ static char __pyx_doc_9liblinear_7Problem_release[] = " frees memory "; static PyObject *__pyx_pf_9liblinear_7Problem_release(PyObject *__pyx_v_self, PyObject *unused) { int __pyx_v_i; PyObject *__pyx_r; int __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":179 * """ frees memory """ * cdef int i * free(self.prob.y) # <<<<<<<<<<<<<< * for i from 0 <= i < self.num_all: * free(self.prob.x[i]) */ free(((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->prob.y); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":180 * cdef int i * free(self.prob.y) * for i from 0 <= i < self.num_all: # <<<<<<<<<<<<<< * free(self.prob.x[i]) * free(self.prob.x) */ __pyx_1 = ((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->num_all; for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":181 * free(self.prob.y) * for i from 0 <= i < self.num_all: * free(self.prob.x[i]) # <<<<<<<<<<<<<< * free(self.prob.x) * */ free((((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->prob.x[__pyx_v_i])); } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":182 * for i from 0 <= i < self.num_all: * free(self.prob.x[i]) * free(self.prob.x) # <<<<<<<<<<<<<< * * #----------------------------------------------------------------- wrapper class */ free(((struct __pyx_obj_9liblinear_Problem *)__pyx_v_self)->prob.x); __pyx_r = Py_None; Py_INCREF(Py_None); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":190 * cdef model * mod * * def __init__(self, *a, **b): # <<<<<<<<<<<<<< * if len(a) or len(b): * raise ValueError("you should not use __init__ for training, use" */ static int __pyx_pf_9liblinear_9LinearSVM___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pf_9liblinear_9LinearSVM___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_a = 0; PyObject *__pyx_v_b = 0; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1; __pyx_v_b = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_b)) return -1; Py_INCREF(__pyx_args); __pyx_v_a = __pyx_args; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":191 * * def __init__(self, *a, **b): * if len(a) or len(b): # <<<<<<<<<<<<<< * raise ValueError("you should not use __init__ for training, use" * "train() instead") */ __pyx_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_1) { __pyx_1 = PyObject_Length(__pyx_v_b); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (__pyx_1) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":192 * def __init__(self, *a, **b): * if len(a) or len(b): * raise ValueError("you should not use __init__ for training, use" # <<<<<<<<<<<<<< * "train() instead") * self.mod = NULL */ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_12); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_12); __pyx_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":194 * raise ValueError("you should not use __init__ for training, use" * "train() instead") * self.mod = NULL # <<<<<<<<<<<<<< * * @classmethod */ ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod = NULL; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("liblinear.LinearSVM.__init__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_a); Py_DECREF(__pyx_v_b); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":197 * * @classmethod * def train(cls, data , mach=L2LOSS_SVM_DUAL, float C=1.0, float eps=0.01, \ # <<<<<<<<<<<<<< * weights=None, verbose=0): * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_train(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pf_9liblinear_9LinearSVM_train(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_mach = 0; float __pyx_v_C; float __pyx_v_eps; PyObject *__pyx_v_weights = 0; PyObject *__pyx_v_verbose = 0; struct __pyx_obj_9liblinear_LinearSVM *__pyx_v_rv = 0; int __pyx_v_num_classes; struct __pyx_obj_9liblinear_Problem *__pyx_v_prob = 0; struct __pyx_obj_9liblinear_Parameter *__pyx_v_param = 0; PyObject *__pyx_v_py_message; char *__pyx_v_message; struct model *__pyx_v_mod; PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_ssize_t __pyx_2 = 0; int __pyx_3; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; PyObject *__pyx_7 = 0; int __pyx_8; PyObject *__pyx_t_1 = NULL; static PyObject **__pyx_pyargnames[] = {&__pyx_kp_data,&__pyx_kp_mach,&__pyx_kp_C,&__pyx_kp_eps,&__pyx_kp_weights,&__pyx_kp_verbose,0}; __pyx_v_mach = __pyx_k_8; __pyx_v_C = ((float)1.0); __pyx_v_eps = ((float)0.01); __pyx_v_weights = Py_None; __pyx_v_verbose = __pyx_int_0; if (unlikely(__pyx_kwds)) { PyObject* values[6] = {0,0,0,0,0,0}; Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); 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); 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); case 0: break; default: goto __pyx_L5_argtuple_error; } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_data); 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, PyTuple_GET_SIZE(__pyx_args), "train") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_data = values[0]; if (values[1]) { __pyx_v_mach = values[1]; } if (values[2]) { __pyx_v_C = __pyx_PyFloat_AsDouble(values[2]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } if (values[3]) { __pyx_v_eps = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } if (values[4]) { __pyx_v_weights = values[4]; } if (values[5]) { __pyx_v_verbose = values[5]; } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 6: __pyx_v_verbose = PyTuple_GET_ITEM(__pyx_args, 5); case 5: __pyx_v_weights = PyTuple_GET_ITEM(__pyx_args, 4); case 4: __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} case 3: __pyx_v_C = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} case 2: __pyx_v_mach = PyTuple_GET_ITEM(__pyx_args, 1); case 1: __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("train", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("liblinear.LinearSVM.train"); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_v_py_message = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":200 * weights=None, verbose=0): * * cdef LinearSVM rv = LinearSVM() # <<<<<<<<<<<<<< * * cdef int num_classes = len(data) */ __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_LinearSVM)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_9liblinear_LinearSVM))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_rv = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":202 * cdef LinearSVM rv = LinearSVM() * * cdef int num_classes = len(data) # <<<<<<<<<<<<<< * * if verbose: */ __pyx_2 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_num_classes = __pyx_2; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":204 * cdef int num_classes = len(data) * * if verbose: # <<<<<<<<<<<<<< * print "VERBOSE" * print "got", num_classes, "classes to learn" */ __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":205 * * if verbose: * print "VERBOSE" # <<<<<<<<<<<<<< * print "got", num_classes, "classes to learn" * */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_13); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_13); if (__Pyx_Print(((PyObject *)__pyx_1), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":206 * if verbose: * print "VERBOSE" * print "got", num_classes, "classes to learn" # <<<<<<<<<<<<<< * * if num_classes<2: */ __pyx_1 = PyInt_FromLong(__pyx_v_num_classes); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_14); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_kp_14); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1); Py_INCREF(__pyx_kp_15); PyTuple_SET_ITEM(__pyx_4, 2, __pyx_kp_15); __pyx_1 = 0; if (__Pyx_Print(((PyObject *)__pyx_4), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0; goto __pyx_L6; } __pyx_L6:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":208 * print "got", num_classes, "classes to learn" * * if num_classes<2: # <<<<<<<<<<<<<< * raise RuntimeError("need at least two classes") * */ __pyx_3 = (__pyx_v_num_classes < 2); if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":209 * * if num_classes<2: * raise RuntimeError("need at least two classes") # <<<<<<<<<<<<<< * * try: */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_16); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_16); __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":211 * raise RuntimeError("need at least two classes") * * try: # <<<<<<<<<<<<<< * data[0][0][0] * except: */ { PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb; __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb); /*try:*/ { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":212 * * try: * data[0][0][0] # <<<<<<<<<<<<<< * except: * raise RuntimeError("data has wrong dimension, must be" */ __pyx_1 = __Pyx_GetItemInt(__pyx_v_data, 0, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L8_error;} __pyx_4 = __Pyx_GetItemInt(__pyx_1, 0, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L8_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_1 = __Pyx_GetItemInt(__pyx_4, 0, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L8_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; } Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0; Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0; Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0; goto __pyx_L13_try; __pyx_L8_error:; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":213 * try: * data[0][0][0] * except: # <<<<<<<<<<<<<< * raise RuntimeError("data has wrong dimension, must be" * " tuple of vector lists") */ /*except:*/ { __Pyx_AddTraceback("liblinear.train"); if (__Pyx_GetException(&__pyx_4, &__pyx_1, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;} /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":214 * data[0][0][0] * except: * raise RuntimeError("data has wrong dimension, must be" # <<<<<<<<<<<<<< * " tuple of vector lists") * */ __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;} Py_INCREF(__pyx_kp_17); PyTuple_SET_ITEM(__pyx_6, 0, __pyx_kp_17); __pyx_7 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;} Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; __Pyx_Raise(__pyx_7, 0, 0); Py_DECREF(__pyx_7); __pyx_7 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; goto __pyx_L9_exception_handled; } __pyx_L10_except_error:; Py_XDECREF(__pyx_save_exc_type); Py_XDECREF(__pyx_save_exc_value); Py_XDECREF(__pyx_save_exc_tb); goto __pyx_L1_error; __pyx_L9_exception_handled:; __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb); __pyx_L13_try:; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":217 * " tuple of vector lists") * * if verbose: # <<<<<<<<<<<<<< * print "build Problem" * cdef Problem prob = Problem(data) */ __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":218 * * if verbose: * print "build Problem" # <<<<<<<<<<<<<< * cdef Problem prob = Problem(data) * */ __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_18); PyTuple_SET_ITEM(__pyx_6, 0, __pyx_kp_18); if (__Pyx_Print(((PyObject *)__pyx_6), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; goto __pyx_L14; } __pyx_L14:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":219 * if verbose: * print "build Problem" * cdef Problem prob = Problem(data) # <<<<<<<<<<<<<< * * if verbose: */ __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_data); __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_Problem)), ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0; if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_9liblinear_Problem))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_prob = ((struct __pyx_obj_9liblinear_Problem *)__pyx_4); __pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":221 * cdef Problem prob = Problem(data) * * if verbose: # <<<<<<<<<<<<<< * print "configure machine" * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) */ __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":222 * * if verbose: * print "configure machine" # <<<<<<<<<<<<<< * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) * */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_19); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_19); if (__Pyx_Print(((PyObject *)__pyx_1), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; goto __pyx_L15; } __pyx_L15:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":223 * if verbose: * print "configure machine" * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) # <<<<<<<<<<<<<< * * #--------------------------------------------------- check configuration */ __pyx_5 = PyFloat_FromDouble(__pyx_v_eps); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyFloat_FromDouble(__pyx_v_C); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_7 = PyInt_FromLong(__pyx_v_num_classes); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyTuple_New(5); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_mach); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_mach); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5); PyTuple_SET_ITEM(__pyx_4, 2, __pyx_6); Py_INCREF(__pyx_v_weights); PyTuple_SET_ITEM(__pyx_4, 3, __pyx_v_weights); PyTuple_SET_ITEM(__pyx_4, 4, __pyx_7); __pyx_5 = 0; __pyx_6 = 0; __pyx_7 = 0; __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_Parameter)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0; if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_9liblinear_Parameter))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_param = ((struct __pyx_obj_9liblinear_Parameter *)__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":228 * cdef object py_message * cdef char * message * message = < char *> check_parameter(& prob.prob, & param.param) # <<<<<<<<<<<<<< * if message: * py_message = message */ __pyx_v_message = ((char *)check_parameter((&__pyx_v_prob->prob), (&__pyx_v_param->param))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":229 * cdef char * message * message = < char *> check_parameter(& prob.prob, & param.param) * if message: # <<<<<<<<<<<<<< * py_message = message * raise RuntimeError("param invalid: " + py_message) */ __pyx_3 = (__pyx_v_message != 0); if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":230 * message = < char *> check_parameter(& prob.prob, & param.param) * if message: * py_message = message # <<<<<<<<<<<<<< * raise RuntimeError("param invalid: " + py_message) * */ __pyx_5 = __Pyx_PyBytes_FromString(__pyx_v_message); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_py_message); __pyx_v_py_message = __pyx_5; __pyx_5 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":231 * if message: * py_message = message * raise RuntimeError("param invalid: " + py_message) # <<<<<<<<<<<<<< * * #------------------------------------------------------ train classifier */ __pyx_t_1 = PyNumber_Add(__pyx_kp_20, __pyx_v_py_message); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_6, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_7 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; __Pyx_Raise(__pyx_7, 0, 0); Py_DECREF(__pyx_7); __pyx_7 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L16; } __pyx_L16:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":234 * * #------------------------------------------------------ train classifier * if verbose: # <<<<<<<<<<<<<< * print "start training" * cdef model * mod = train(& prob.prob, & param.param, verbose) */ __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":235 * #------------------------------------------------------ train classifier * if verbose: * print "start training" # <<<<<<<<<<<<<< * cdef model * mod = train(& prob.prob, & param.param, verbose) * if verbose: */ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_21); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_kp_21); if (__Pyx_Print(((PyObject *)__pyx_4), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0; goto __pyx_L17; } __pyx_L17:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":236 * if verbose: * print "start training" * cdef model * mod = train(& prob.prob, & param.param, verbose) # <<<<<<<<<<<<<< * if verbose: * print "finished training" */ __pyx_8 = __pyx_PyInt_int(__pyx_v_verbose); if (unlikely((__pyx_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_mod = train((&__pyx_v_prob->prob), (&__pyx_v_param->param), __pyx_8); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":237 * print "start training" * cdef model * mod = train(& prob.prob, & param.param, verbose) * if verbose: # <<<<<<<<<<<<<< * print "finished training" * */ __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":238 * cdef model * mod = train(& prob.prob, & param.param, verbose) * if verbose: * print "finished training" # <<<<<<<<<<<<<< * * #--------------------------------------------------------- store results */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_22); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_22); if (__Pyx_Print(((PyObject *)__pyx_1), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; goto __pyx_L18; } __pyx_L18:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":242 * #--------------------------------------------------------- store results * * rv.mod = mod # <<<<<<<<<<<<<< * * #------------------------------------------------------- free aux memory */ __pyx_v_rv->mod = __pyx_v_mod; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":245 * * #------------------------------------------------------- free aux memory * prob.release() # <<<<<<<<<<<<<< * param.release() * */ __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_prob), __pyx_kp_release); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_6); __pyx_6 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":246 * #------------------------------------------------------- free aux memory * prob.release() * param.release() # <<<<<<<<<<<<<< * * return rv */ __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_param), __pyx_kp_release); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":248 * param.release() * * return rv # <<<<<<<<<<<<<< * * */ Py_INCREF(((PyObject *)__pyx_v_rv)); __pyx_r = ((PyObject *)__pyx_v_rv); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); Py_XDECREF(__pyx_7); __Pyx_AddTraceback("liblinear.LinearSVM.train"); __pyx_r = NULL; __pyx_L0:; Py_XDECREF(__pyx_v_rv); Py_XDECREF(__pyx_v_prob); Py_XDECREF(__pyx_v_param); Py_DECREF(__pyx_v_py_message); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":251 * * * def build_confusion_matrix(self, data): # <<<<<<<<<<<<<< * """ builds confusion matrix of 'data' with learnt model """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_build_confusion_matrix(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_build_confusion_matrix[] = " builds confusion matrix of 'data' with learnt model "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_build_confusion_matrix(PyObject *__pyx_v_self, PyObject *__pyx_v_data) { struct model *__pyx_v_mod; PyObject *__pyx_v_mat_row; PyObject *__pyx_v_confusion_matrix = 0; PyObject *__pyx_v_tobe; PyObject *__pyx_v_dataset; PyObject *__pyx_v_vec; PyObject *__pyx_v_classified_as; PyObject *__pyx_r; Py_ssize_t __pyx_1 = 0; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; Py_ssize_t __pyx_7 = 0; PyObject *__pyx_8 = 0; int __pyx_9; PyObject *__pyx_t_1 = NULL; __pyx_v_mat_row = ((PyObject *)Py_None); Py_INCREF(Py_None); __pyx_v_tobe = Py_None; Py_INCREF(Py_None); __pyx_v_dataset = Py_None; Py_INCREF(Py_None); __pyx_v_vec = Py_None; Py_INCREF(Py_None); __pyx_v_classified_as = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":254 * """ builds confusion matrix of 'data' with learnt model """ * * cdef model * mod = self.mod # <<<<<<<<<<<<<< * * if len(data) != mod.nr_class: */ __pyx_v_mod = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":256 * cdef model * mod = self.mod * * if len(data) != mod.nr_class: # <<<<<<<<<<<<<< * raise ValueError("need %d classes to evaluate" % mod.nr_class) * */ __pyx_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = (__pyx_1 != __pyx_v_mod->nr_class); if (__pyx_2) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":257 * * if len(data) != mod.nr_class: * raise ValueError("need %d classes to evaluate" % mod.nr_class) # <<<<<<<<<<<<<< * * */ __pyx_3 = PyInt_FromLong(__pyx_v_mod->nr_class); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Remainder(__pyx_kp_23, __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":261 * * cdef list mat_row * cdef list confusion_matrix = [] # <<<<<<<<<<<<<< * * for tobe, dataset in enumerate(data): */ __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_confusion_matrix = __pyx_3; __pyx_3 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":263 * cdef list confusion_matrix = [] * * for tobe, dataset in enumerate(data): # <<<<<<<<<<<<<< * mat_row = [0] * mod.nr_class * for vec in dataset: */ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_data); __pyx_3 = PyObject_Call(__pyx_builtin_enumerate, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0; if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) { __pyx_1 = 0; __pyx_4 = __pyx_3; Py_INCREF(__pyx_4); } else { __pyx_1 = -1; __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } Py_DECREF(__pyx_3); __pyx_3 = 0; for (;;) { if (likely(PyList_CheckExact(__pyx_4))) { if (__pyx_1 >= PyList_GET_SIZE(__pyx_4)) break; __pyx_3 = PyList_GET_ITEM(__pyx_4, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++; } else if (likely(PyTuple_CheckExact(__pyx_4))) { if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_4)) break; __pyx_3 = PyTuple_GET_ITEM(__pyx_4, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++; } else { __pyx_3 = PyIter_Next(__pyx_4); if (!__pyx_3) { if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } } if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) { PyObject* tuple = __pyx_3; __pyx_6 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(__pyx_6); Py_DECREF(__pyx_v_tobe); __pyx_v_tobe = __pyx_6; __pyx_6 = 0; __pyx_6 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(__pyx_6); Py_DECREF(__pyx_v_dataset); __pyx_v_dataset = __pyx_6; __pyx_6 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; } else { __pyx_5 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_tobe); __pyx_v_tobe = __pyx_6; __pyx_6 = 0; __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_dataset); __pyx_v_dataset = __pyx_6; __pyx_6 = 0; if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":264 * * for tobe, dataset in enumerate(data): * mat_row = [0] * mod.nr_class # <<<<<<<<<<<<<< * for vec in dataset: * classified_as = self.predict(vec) */ __pyx_6 = PyList_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_int_0); PyList_SET_ITEM(__pyx_6, 0, __pyx_int_0); __pyx_3 = PyInt_FromLong(__pyx_v_mod->nr_class); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_6), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (!(likely(PyList_CheckExact(__pyx_t_1)) || (__pyx_t_1) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_v_mat_row)); __pyx_v_mat_row = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":265 * for tobe, dataset in enumerate(data): * mat_row = [0] * mod.nr_class * for vec in dataset: # <<<<<<<<<<<<<< * classified_as = self.predict(vec) * mat_row[classified_as] += 1 */ if (PyList_CheckExact(__pyx_v_dataset) || PyTuple_CheckExact(__pyx_v_dataset)) { __pyx_7 = 0; __pyx_5 = __pyx_v_dataset; Py_INCREF(__pyx_5); } else { __pyx_7 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_dataset); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } for (;;) { if (likely(PyList_CheckExact(__pyx_5))) { if (__pyx_7 >= PyList_GET_SIZE(__pyx_5)) break; __pyx_6 = PyList_GET_ITEM(__pyx_5, __pyx_7); Py_INCREF(__pyx_6); __pyx_7++; } else if (likely(PyTuple_CheckExact(__pyx_5))) { if (__pyx_7 >= PyTuple_GET_SIZE(__pyx_5)) break; __pyx_6 = PyTuple_GET_ITEM(__pyx_5, __pyx_7); Py_INCREF(__pyx_6); __pyx_7++; } else { __pyx_6 = PyIter_Next(__pyx_5); if (!__pyx_6) { if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } } Py_DECREF(__pyx_v_vec); __pyx_v_vec = __pyx_6; __pyx_6 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":266 * mat_row = [0] * mod.nr_class * for vec in dataset: * classified_as = self.predict(vec) # <<<<<<<<<<<<<< * mat_row[classified_as] += 1 * confusion_matrix.append(mat_row) */ __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_predict); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_vec); PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_vec); __pyx_8 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; Py_DECREF(__pyx_v_classified_as); __pyx_v_classified_as = __pyx_8; __pyx_8 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":267 * for vec in dataset: * classified_as = self.predict(vec) * mat_row[classified_as] += 1 # <<<<<<<<<<<<<< * confusion_matrix.append(mat_row) * */ __pyx_6 = PyObject_GetItem(((PyObject *)__pyx_v_mat_row), __pyx_v_classified_as); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyNumber_InPlaceAdd(__pyx_6, __pyx_int_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_6); __pyx_6 = 0; if (PyObject_SetItem(((PyObject *)__pyx_v_mat_row), __pyx_v_classified_as, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; } Py_DECREF(__pyx_5); __pyx_5 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":268 * classified_as = self.predict(vec) * mat_row[classified_as] += 1 * confusion_matrix.append(mat_row) # <<<<<<<<<<<<<< * * return confusion_matrix */ __pyx_9 = PyList_Append(((PyObject *)__pyx_v_confusion_matrix), ((PyObject *)__pyx_v_mat_row)); if (unlikely(__pyx_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } Py_DECREF(__pyx_4); __pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":270 * confusion_matrix.append(mat_row) * * return confusion_matrix # <<<<<<<<<<<<<< * * def tostring(self): */ Py_INCREF(((PyObject *)__pyx_v_confusion_matrix)); __pyx_r = ((PyObject *)__pyx_v_confusion_matrix); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); Py_XDECREF(__pyx_8); __Pyx_AddTraceback("liblinear.LinearSVM.build_confusion_matrix"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_mat_row); Py_XDECREF(__pyx_v_confusion_matrix); Py_DECREF(__pyx_v_tobe); Py_DECREF(__pyx_v_dataset); Py_DECREF(__pyx_v_vec); Py_DECREF(__pyx_v_classified_as); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":272 * return confusion_matrix * * def tostring(self): # <<<<<<<<<<<<<< * """ converts model to text representation """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_tostring(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_tostring[] = " converts model to text representation "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_tostring(PyObject *__pyx_v_self, PyObject *unused) { char *__pyx_v_cc; PyObject *__pyx_v_res; PyObject *__pyx_r; PyObject *__pyx_1 = 0; __pyx_v_res = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":276 * * cdef char * cc * cc = to_string(self.mod) # <<<<<<<<<<<<<< * res = PyString_FromStringAndSize (cc, strlen(cc)) * free(cc) */ __pyx_v_cc = to_string(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":277 * cdef char * cc * cc = to_string(self.mod) * res = PyString_FromStringAndSize (cc, strlen(cc)) # <<<<<<<<<<<<<< * free(cc) * return res */ __pyx_1 = PyString_FromStringAndSize(__pyx_v_cc, strlen(__pyx_v_cc)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_res); __pyx_v_res = __pyx_1; __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":278 * cc = to_string(self.mod) * res = PyString_FromStringAndSize (cc, strlen(cc)) * free(cc) # <<<<<<<<<<<<<< * return res * */ free(__pyx_v_cc); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":279 * res = PyString_FromStringAndSize (cc, strlen(cc)) * free(cc) * return res # <<<<<<<<<<<<<< * * @classmethod */ Py_INCREF(__pyx_v_res); __pyx_r = __pyx_v_res; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); __Pyx_AddTraceback("liblinear.LinearSVM.tostring"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_res); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":282 * * @classmethod * def fromstring(cls, input): # <<<<<<<<<<<<<< * """ builds model from text representatino """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_fromstring(PyObject *__pyx_v_cls, PyObject *__pyx_v_input); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_fromstring[] = " builds model from text representatino "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_fromstring(PyObject *__pyx_v_cls, PyObject *__pyx_v_input) { struct __pyx_obj_9liblinear_LinearSVM *__pyx_v_rv = 0; PyObject *__pyx_r; PyObject *__pyx_1 = 0; char *__pyx_2; int __pyx_3; PyObject *__pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":285 * """ builds model from text representatino """ * * cdef LinearSVM rv = LinearSVM() # <<<<<<<<<<<<<< * rv.mod = from_string(input) * if rv.mod == NULL: */ __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_LinearSVM)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_9liblinear_LinearSVM))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_rv = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":286 * * cdef LinearSVM rv = LinearSVM() * rv.mod = from_string(input) # <<<<<<<<<<<<<< * if rv.mod == NULL: * raise ValueError("error when creating model from stream") */ __pyx_2 = __Pyx_PyBytes_AsString(__pyx_v_input); if (unlikely((!__pyx_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_rv->mod = from_string(__pyx_2); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":287 * cdef LinearSVM rv = LinearSVM() * rv.mod = from_string(input) * if rv.mod == NULL: # <<<<<<<<<<<<<< * raise ValueError("error when creating model from stream") * return rv */ __pyx_3 = (__pyx_v_rv->mod == NULL); if (__pyx_3) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":288 * rv.mod = from_string(input) * if rv.mod == NULL: * raise ValueError("error when creating model from stream") # <<<<<<<<<<<<<< * return rv * */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_24); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_24); __pyx_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":289 * if rv.mod == NULL: * raise ValueError("error when creating model from stream") * return rv # <<<<<<<<<<<<<< * * def __reduce__(self): */ Py_INCREF(((PyObject *)__pyx_v_rv)); __pyx_r = ((PyObject *)__pyx_v_rv); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("liblinear.LinearSVM.fromstring"); __pyx_r = NULL; __pyx_L0:; Py_XDECREF(__pyx_v_rv); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":291 * return rv * * def __reduce__(self): # <<<<<<<<<<<<<< * """ needed for pickling this extension class """ * return __fromstring, (zlib.compress(self.tostring()),) */ static PyObject *__pyx_pf_9liblinear_9LinearSVM___reduce__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM___reduce__[] = " needed for pickling this extension class "; static PyObject *__pyx_pf_9liblinear_9LinearSVM___reduce__(PyObject *__pyx_v_self, PyObject *unused) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":293 * def __reduce__(self): * """ needed for pickling this extension class """ * return __fromstring, (zlib.compress(self.tostring()),) # <<<<<<<<<<<<<< * * def predict(self, vec): */ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp___fromstring); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_zlib); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_compress); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_tostring); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); __pyx_4 = 0; __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); __pyx_4 = 0; __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_3)); __pyx_1 = 0; __pyx_3 = 0; __pyx_r = ((PyObject *)__pyx_2); __pyx_2 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("liblinear.LinearSVM.__reduce__"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":295 * return __fromstring, (zlib.compress(self.tostring()),) * * def predict(self, vec): # <<<<<<<<<<<<<< * """ classify vector """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict(PyObject *__pyx_v_self, PyObject *__pyx_v_vec); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_predict[] = " classify vector "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict(PyObject *__pyx_v_self, PyObject *__pyx_v_vec) { struct feature_node *__pyx_v_v; int __pyx_v_val; PyObject *__pyx_r; PyObject *__pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":298 * """ classify vector """ * * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) # <<<<<<<<<<<<<< * cdef int val = predict(self.mod, v) * free(v) */ if (!(likely(PyList_CheckExact(__pyx_v_vec)) || (__pyx_v_vec) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_v_vec)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_v = __pyx_f_9liblinear_build_vector(((PyObject *)__pyx_v_vec), ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_feature); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":299 * * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) * cdef int val = predict(self.mod, v) # <<<<<<<<<<<<<< * free(v) * return val */ __pyx_v_val = predict(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod, __pyx_v_v); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":300 * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) * cdef int val = predict(self.mod, v) * free(v) # <<<<<<<<<<<<<< * return val * */ free(__pyx_v_v); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":301 * cdef int val = predict(self.mod, v) * free(v) * return val # <<<<<<<<<<<<<< * * def predict_probabilites(self, vec): */ __pyx_1 = PyInt_FromLong(__pyx_v_val); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); __Pyx_AddTraceback("liblinear.LinearSVM.predict"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":303 * return val * * def predict_probabilites(self, vec): # <<<<<<<<<<<<<< * """ calculate class probabiliteis of vector """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict_probabilites(PyObject *__pyx_v_self, PyObject *__pyx_v_vec); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_predict_probabilites[] = " calculate class probabiliteis of vector "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict_probabilites(PyObject *__pyx_v_self, PyObject *__pyx_v_vec) { int __pyx_v_nc; struct feature_node *__pyx_v_v; double *__pyx_v_probs; PyObject *__pyx_v_rv; int __pyx_v_i; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; int __pyx_4; PyObject *__pyx_t_1 = NULL; __pyx_v_rv = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":306 * """ calculate class probabiliteis of vector """ * * if self.mod.param.solver_type != L2_LR: # <<<<<<<<<<<<<< * raise ValueError("method only allowed for L2_LR method") * */ __pyx_1 = PyInt_FromLong(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->param.solver_type); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyObject_RichCompare(__pyx_1, __pyx_2, Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_4) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":307 * * if self.mod.param.solver_type != L2_LR: * raise ValueError("method only allowed for L2_LR method") # <<<<<<<<<<<<<< * * cdef int nc = self.mod.nr_class */ __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_kp_25); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_25); __pyx_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0; __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":309 * raise ValueError("method only allowed for L2_LR method") * * cdef int nc = self.mod.nr_class # <<<<<<<<<<<<<< * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) * cdef double * probs = < double *> malloc(nc * sizeof(double)) */ __pyx_v_nc = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_class; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":310 * * cdef int nc = self.mod.nr_class * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) # <<<<<<<<<<<<<< * cdef double * probs = < double *> malloc(nc * sizeof(double)) * */ if (!(likely(PyList_CheckExact(__pyx_v_vec)) || (__pyx_v_vec) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_v_vec)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_v = __pyx_f_9liblinear_build_vector(((PyObject *)__pyx_v_vec), ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_feature); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":311 * cdef int nc = self.mod.nr_class * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) * cdef double * probs = < double *> malloc(nc * sizeof(double)) # <<<<<<<<<<<<<< * * predict_probability(self.mod, v, probs) */ __pyx_v_probs = ((double *)malloc((__pyx_v_nc * (sizeof(double))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":313 * cdef double * probs = < double *> malloc(nc * sizeof(double)) * * predict_probability(self.mod, v, probs) # <<<<<<<<<<<<<< * * rv = [0] * nc */ predict_probability(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod, __pyx_v_v, __pyx_v_probs); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":315 * predict_probability(self.mod, v, probs) * * rv = [0] * nc # <<<<<<<<<<<<<< * cdef int i * for i from 0 <= i < nc: */ __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_int_0); PyList_SET_ITEM(__pyx_3, 0, __pyx_int_0); __pyx_1 = PyInt_FromLong(__pyx_v_nc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_3), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_rv); __pyx_v_rv = __pyx_t_1; __pyx_t_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":317 * rv = [0] * nc * cdef int i * for i from 0 <= i < nc: # <<<<<<<<<<<<<< * rv[i] = probs[i] * */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nc; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":318 * cdef int i * for i from 0 <= i < nc: * rv[i] = probs[i] # <<<<<<<<<<<<<< * * free(v) */ __pyx_2 = PyFloat_FromDouble((__pyx_v_probs[__pyx_v_i])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetItemInt(__pyx_v_rv, __pyx_v_i, __pyx_2, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":320 * rv[i] = probs[i] * * free(v) # <<<<<<<<<<<<<< * free(probs) * return rv */ free(__pyx_v_v); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":321 * * free(v) * free(probs) # <<<<<<<<<<<<<< * return rv * */ free(__pyx_v_probs); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":322 * free(v) * free(probs) * return rv # <<<<<<<<<<<<<< * * def predict_values(self, vec): */ Py_INCREF(__pyx_v_rv); __pyx_r = __pyx_v_rv; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("liblinear.LinearSVM.predict_probabilites"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_rv); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":324 * return rv * * def predict_values(self, vec): # <<<<<<<<<<<<<< * """ decision values for each class * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict_values(PyObject *__pyx_v_self, PyObject *__pyx_v_vec); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_predict_values[] = " decision values for each class\n\n This function returns nr_w decision values, nr_w is 1 if\n there are two classes except multi-class svm by Crammer and\n Singer, and is the number of classes otherwise.\n "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_predict_values(PyObject *__pyx_v_self, PyObject *__pyx_v_vec) { struct feature_node *__pyx_v_v; int __pyx_v_nc; int __pyx_v_nr_w; double *__pyx_v_dec_values; PyObject *__pyx_v_dv; PyObject *__pyx_v_i; PyObject *__pyx_r; long __pyx_1; int __pyx_2; int __pyx_3; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; Py_ssize_t __pyx_7 = 0; Py_ssize_t __pyx_8 = 0; int __pyx_9; __pyx_v_dv = Py_None; Py_INCREF(Py_None); __pyx_v_i = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":332 * """ * * cdef feature_node * v = build_vector(vec, self.mod.nr_feature) # <<<<<<<<<<<<<< * * # calculate number of outputs (nr_w) */ if (!(likely(PyList_CheckExact(__pyx_v_vec)) || (__pyx_v_vec) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_v_vec)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_v = __pyx_f_9liblinear_build_vector(((PyObject *)__pyx_v_vec), ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_feature); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":335 * * # calculate number of outputs (nr_w) * cdef int nc = self.mod.nr_class # <<<<<<<<<<<<<< * * cdef int nr_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc */ __pyx_v_nc = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_class; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":337 * cdef int nc = self.mod.nr_class * * cdef int nr_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc # <<<<<<<<<<<<<< * cdef double * dec_values = < double *> malloc(nr_w * sizeof(double)) * */ __pyx_2 = (__pyx_v_nc == 2); if (__pyx_2) { __pyx_4 = PyInt_FromLong(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->param.solver_type); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_MCSVM_CS); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyObject_RichCompare(__pyx_4, __pyx_5, Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_6); __pyx_6 = 0; } if (__pyx_2) { __pyx_1 = 1; } else { __pyx_1 = __pyx_v_nc; } __pyx_v_nr_w = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":338 * * cdef int nr_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc * cdef double * dec_values = < double *> malloc(nr_w * sizeof(double)) # <<<<<<<<<<<<<< * * predict_values(self.mod, v, dec_values) */ __pyx_v_dec_values = ((double *)malloc((__pyx_v_nr_w * (sizeof(double))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":340 * cdef double * dec_values = < double *> malloc(nr_w * sizeof(double)) * * predict_values(self.mod, v, dec_values) # <<<<<<<<<<<<<< * dv = [ dec_values[i] for i in range(nr_w) ] * free(v) */ predict_values(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod, __pyx_v_v, __pyx_v_dec_values); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":341 * * predict_values(self.mod, v, dec_values) * dv = [ dec_values[i] for i in range(nr_w) ] # <<<<<<<<<<<<<< * free(v) * free(dec_values) */ __pyx_4 = PyList_New(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = PyInt_FromLong(__pyx_v_nr_w); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); __pyx_5 = 0; __pyx_5 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0; if (PyList_CheckExact(__pyx_5) || PyTuple_CheckExact(__pyx_5)) { __pyx_7 = 0; __pyx_6 = __pyx_5; Py_INCREF(__pyx_6); } else { __pyx_7 = -1; __pyx_6 = PyObject_GetIter(__pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } Py_DECREF(__pyx_5); __pyx_5 = 0; for (;;) { if (likely(PyList_CheckExact(__pyx_6))) { if (__pyx_7 >= PyList_GET_SIZE(__pyx_6)) break; __pyx_5 = PyList_GET_ITEM(__pyx_6, __pyx_7); Py_INCREF(__pyx_5); __pyx_7++; } else if (likely(PyTuple_CheckExact(__pyx_6))) { if (__pyx_7 >= PyTuple_GET_SIZE(__pyx_6)) break; __pyx_5 = PyTuple_GET_ITEM(__pyx_6, __pyx_7); Py_INCREF(__pyx_5); __pyx_7++; } else { __pyx_5 = PyIter_Next(__pyx_6); if (!__pyx_5) { if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } } Py_DECREF(__pyx_v_i); __pyx_v_i = __pyx_5; __pyx_5 = 0; __pyx_8 = __pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = PyFloat_FromDouble((__pyx_v_dec_values[__pyx_8])); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_9 = PyList_Append(__pyx_4, (PyObject*)__pyx_5); if (unlikely(__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; } Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_v_dv); __pyx_v_dv = ((PyObject *)__pyx_4); __pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":342 * predict_values(self.mod, v, dec_values) * dv = [ dec_values[i] for i in range(nr_w) ] * free(v) # <<<<<<<<<<<<<< * free(dec_values) * return dv */ free(__pyx_v_v); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":343 * dv = [ dec_values[i] for i in range(nr_w) ] * free(v) * free(dec_values) # <<<<<<<<<<<<<< * return dv * */ free(__pyx_v_dec_values); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":344 * free(v) * free(dec_values) * return dv # <<<<<<<<<<<<<< * * def get_weights(self): */ Py_INCREF(__pyx_v_dv); __pyx_r = __pyx_v_dv; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); __Pyx_AddTraceback("liblinear.LinearSVM.predict_values"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_dv); Py_DECREF(__pyx_v_i); return __pyx_r; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":346 * return dv * * def get_weights(self): # <<<<<<<<<<<<<< * """ get weights of linear svm """ * */ static PyObject *__pyx_pf_9liblinear_9LinearSVM_get_weights(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ static char __pyx_doc_9liblinear_9LinearSVM_get_weights[] = " get weights of linear svm "; static PyObject *__pyx_pf_9liblinear_9LinearSVM_get_weights(PyObject *__pyx_v_self, PyObject *unused) { int __pyx_v_nw; int __pyx_v_nc; PyObject *__pyx_v_rv = 0; int __pyx_v_i; int __pyx_v_num_w; PyObject *__pyx_v_w; PyObject *__pyx_v_j; PyObject *__pyx_r; PyObject *__pyx_1 = 0; long __pyx_2; int __pyx_3; int __pyx_4; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; Py_ssize_t __pyx_7 = 0; int __pyx_8; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __pyx_v_w = Py_None; Py_INCREF(Py_None); __pyx_v_j = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":349 * """ get weights of linear svm """ * * cdef int nw = self.mod.nr_feature # <<<<<<<<<<<<<< * cdef int nc = self.mod.nr_class * cdef list rv = [] */ __pyx_v_nw = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_feature; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":350 * * cdef int nw = self.mod.nr_feature * cdef int nc = self.mod.nr_class # <<<<<<<<<<<<<< * cdef list rv = [] * cdef int i */ __pyx_v_nc = ((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->nr_class; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":351 * cdef int nw = self.mod.nr_feature * cdef int nc = self.mod.nr_class * cdef list rv = [] # <<<<<<<<<<<<<< * cdef int i * */ __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_rv = __pyx_1; __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":354 * cdef int i * * cdef int num_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc # <<<<<<<<<<<<<< * * for i from 0<=imod->param.solver_type); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_MCSVM_CS); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyObject_RichCompare(__pyx_1, __pyx_5, Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_6); __pyx_6 = 0; } if (__pyx_3) { __pyx_2 = 1; } else { __pyx_2 = __pyx_v_nc; } __pyx_v_num_w = __pyx_2; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":356 * cdef int num_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc * * for i from 0<=imod->w[__pyx_7])); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = __Pyx_PyObject_Append(__pyx_v_w, __pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_6); __pyx_6 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":360 * for j from 0<=jmod->nr_class; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":370 * cdef int nc = self.mod.nr_class * * cdef int num_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc # <<<<<<<<<<<<<< * * cdef int offset = num_w * self.mod.nr_feature */ __pyx_3 = (__pyx_v_nc == 2); if (__pyx_3) { __pyx_1 = PyInt_FromLong(((struct __pyx_obj_9liblinear_LinearSVM *)__pyx_v_self)->mod->param.solver_type); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_MCSVM_CS); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyObject_RichCompare(__pyx_1, __pyx_5, Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_6); __pyx_6 = 0; } if (__pyx_3) { __pyx_2 = 1; } else { __pyx_2 = __pyx_v_nc; } __pyx_v_num_w = __pyx_2; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":372 * cdef int num_w = 1 if (nc == 2 and self.mod.param.solver_type != MCSVM_CS) else nc * * cdef int offset = num_w * self.mod.nr_feature # <<<<<<<<<<<<<< * for i from 0<=imod->nr_feature); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":373 * * cdef int offset = num_w * self.mod.nr_feature * for i from 0<=imod->w[__pyx_7])); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_8 = PyList_Append(((PyObject *)__pyx_v_rv), __pyx_6); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_6); __pyx_6 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":375 * for i from 0<=i 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "crossvalidation") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_data = values[0]; if (values[1]) { __pyx_v_mach = values[1]; } if (values[2]) { __pyx_v_num_folds = __pyx_PyInt_int(values[2]); if (unlikely((__pyx_v_num_folds == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } if (values[3]) { __pyx_v_C = __pyx_PyFloat_AsDouble(values[3]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } if (values[4]) { __pyx_v_eps = __pyx_PyFloat_AsDouble(values[4]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } if (values[5]) { __pyx_v_weights = values[5]; } if (values[6]) { __pyx_v_verbose = values[6]; } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 7: __pyx_v_verbose = PyTuple_GET_ITEM(__pyx_args, 6); case 6: __pyx_v_weights = PyTuple_GET_ITEM(__pyx_args, 5); case 5: __pyx_v_eps = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L3_error;} case 4: __pyx_v_C = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} case 3: __pyx_v_num_folds = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_num_folds == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} case 2: __pyx_v_mach = PyTuple_GET_ITEM(__pyx_args, 1); case 1: __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("crossvalidation", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("liblinear.crossvalidation"); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_v_tobe = Py_None; Py_INCREF(Py_None); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":386 * confusion_matrix[i][j]: true class i, classified as class j """ * * cdef int num_classes = len(data) # <<<<<<<<<<<<<< * cdef Problem prob = Problem(data) * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) */ __pyx_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_num_classes = __pyx_1; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":387 * * cdef int num_classes = len(data) * cdef Problem prob = Problem(data) # <<<<<<<<<<<<<< * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) * */ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_data); __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_Problem)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0; if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_9liblinear_Problem))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_prob = ((struct __pyx_obj_9liblinear_Problem *)__pyx_3); __pyx_3 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":388 * cdef int num_classes = len(data) * cdef Problem prob = Problem(data) * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) # <<<<<<<<<<<<<< * * cdef int * target = < int *> malloc(prob.num_all * sizeof(int)) */ __pyx_2 = PyFloat_FromDouble(__pyx_v_eps); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = PyFloat_FromDouble(__pyx_v_C); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyInt_FromLong(__pyx_v_num_classes); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_5 = PyTuple_New(5); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_v_mach); PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_mach); PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2); PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3); Py_INCREF(__pyx_v_weights); PyTuple_SET_ITEM(__pyx_5, 3, __pyx_v_weights); PyTuple_SET_ITEM(__pyx_5, 4, __pyx_4); __pyx_2 = 0; __pyx_3 = 0; __pyx_4 = 0; __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9liblinear_Parameter)), ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0; if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_9liblinear_Parameter))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_param = ((struct __pyx_obj_9liblinear_Parameter *)__pyx_2); __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":390 * cdef Parameter param = Parameter(mach, eps, C, weights, num_classes) * * cdef int * target = < int *> malloc(prob.num_all * sizeof(int)) # <<<<<<<<<<<<<< * * cross_validation(& prob.prob, & param.param, num_folds, target, verbose) */ __pyx_v_target = ((int *)malloc((__pyx_v_prob->num_all * (sizeof(int))))); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":392 * cdef int * target = < int *> malloc(prob.num_all * sizeof(int)) * * cross_validation(& prob.prob, & param.param, num_folds, target, verbose) # <<<<<<<<<<<<<< * * */ __pyx_6 = __pyx_PyInt_int(__pyx_v_verbose); if (unlikely((__pyx_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} cross_validation((&__pyx_v_prob->prob), (&__pyx_v_param->param), __pyx_v_num_folds, __pyx_v_target, __pyx_6); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":402 * # print confusion_matrix * # and you will see !! * cdef list confusion_row = [0] * num_classes # <<<<<<<<<<<<<< * cdef list confusion_matrix = [] * cdef int i */ __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_int_0); PyList_SET_ITEM(__pyx_3, 0, __pyx_int_0); __pyx_4 = PyInt_FromLong(__pyx_v_num_classes); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_3), __pyx_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; if (!(likely(PyList_CheckExact(__pyx_t_1)) || (__pyx_t_1) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected list, got %s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_confusion_row = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":403 * # and you will see !! * cdef list confusion_row = [0] * num_classes * cdef list confusion_matrix = [] # <<<<<<<<<<<<<< * cdef int i * */ __pyx_5 = PyList_New(0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_confusion_matrix = __pyx_5; __pyx_5 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":406 * cdef int i * * for i from 0 <= i < num_classes: # <<<<<<<<<<<<<< * confusion_matrix.append(confusion_row[:]) * for i from 0 <= i < prob.num_all: */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_classes; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":407 * * for i from 0 <= i < num_classes: * confusion_matrix.append(confusion_row[:]) # <<<<<<<<<<<<<< * for i from 0 <= i < prob.num_all: * tobe = prob.prob.y[i] */ __pyx_2 = PySequence_GetSlice(((PyObject *)__pyx_v_confusion_row), 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_6 = PyList_Append(((PyObject *)__pyx_v_confusion_matrix), __pyx_2); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":408 * for i from 0 <= i < num_classes: * confusion_matrix.append(confusion_row[:]) * for i from 0 <= i < prob.num_all: # <<<<<<<<<<<<<< * tobe = prob.prob.y[i] * confusion_matrix[tobe][target[i]] += 1 */ __pyx_6 = __pyx_v_prob->num_all; for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; __pyx_v_i++) { /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":409 * confusion_matrix.append(confusion_row[:]) * for i from 0 <= i < prob.num_all: * tobe = prob.prob.y[i] # <<<<<<<<<<<<<< * confusion_matrix[tobe][target[i]] += 1 * */ __pyx_3 = PyInt_FromLong((__pyx_v_prob->prob.y[__pyx_v_i])); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_v_tobe); __pyx_v_tobe = __pyx_3; __pyx_3 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":410 * for i from 0 <= i < prob.num_all: * tobe = prob.prob.y[i] * confusion_matrix[tobe][target[i]] += 1 # <<<<<<<<<<<<<< * * prob.release() */ __pyx_5 = PyObject_GetItem(((PyObject *)__pyx_v_confusion_matrix), __pyx_v_tobe); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_7 = (__pyx_v_target[__pyx_v_i]); __pyx_2 = __Pyx_GetItemInt(__pyx_5, __pyx_7, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyNumber_InPlaceAdd(__pyx_2, __pyx_int_1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (__Pyx_SetItemInt(__pyx_5, __pyx_7, __pyx_4, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; } /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":412 * confusion_matrix[tobe][target[i]] += 1 * * prob.release() # <<<<<<<<<<<<<< * param.release() * */ __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_prob), __pyx_kp_release); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":413 * * prob.release() * param.release() # <<<<<<<<<<<<<< * * return confusion_matrix */ __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_param), __pyx_kp_release); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_4 = PyObject_Call(__pyx_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":415 * param.release() * * return confusion_matrix # <<<<<<<<<<<<<< * */ Py_INCREF(((PyObject *)__pyx_v_confusion_matrix)); __pyx_r = ((PyObject *)__pyx_v_confusion_matrix); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("liblinear.crossvalidation"); __pyx_r = NULL; __pyx_L0:; Py_XDECREF(__pyx_v_prob); Py_XDECREF(__pyx_v_param); Py_XDECREF(__pyx_v_confusion_row); Py_XDECREF(__pyx_v_confusion_matrix); Py_DECREF(__pyx_v_tobe); return __pyx_r; } static PyObject *__pyx_tp_new_9liblinear_Parameter(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; return o; } static void __pyx_tp_dealloc_9liblinear_Parameter(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } static struct PyMethodDef __pyx_methods_9liblinear_Parameter[] = { {"release", (PyCFunction)__pyx_pf_9liblinear_9Parameter_release, METH_NOARGS, 0}, {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_Parameter = { 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*/ 0, /*nb_long*/ 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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX) 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_Parameter = { 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_Parameter = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_Parameter = { #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 }; PyTypeObject __pyx_type_9liblinear_Parameter = { PyVarObject_HEAD_INIT(0, 0) "liblinear.Parameter", /*tp_name*/ sizeof(struct __pyx_obj_9liblinear_Parameter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9liblinear_Parameter, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_Parameter, /*tp_as_number*/ &__pyx_tp_as_sequence_Parameter, /*tp_as_sequence*/ &__pyx_tp_as_mapping_Parameter, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Parameter, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9liblinear_Parameter, /*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*/ __pyx_pf_9liblinear_9Parameter___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9liblinear_Parameter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static PyObject *__pyx_tp_new_9liblinear_Problem(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; return o; } static void __pyx_tp_dealloc_9liblinear_Problem(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } static struct PyMethodDef __pyx_methods_9liblinear_Problem[] = { {"release", (PyCFunction)__pyx_pf_9liblinear_7Problem_release, METH_NOARGS, __pyx_doc_9liblinear_7Problem_release}, {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_Problem = { 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*/ 0, /*nb_long*/ 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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX) 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_Problem = { 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_Problem = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_Problem = { #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 }; PyTypeObject __pyx_type_9liblinear_Problem = { PyVarObject_HEAD_INIT(0, 0) "liblinear.Problem", /*tp_name*/ sizeof(struct __pyx_obj_9liblinear_Problem), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9liblinear_Problem, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_Problem, /*tp_as_number*/ &__pyx_tp_as_sequence_Problem, /*tp_as_sequence*/ &__pyx_tp_as_mapping_Problem, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Problem, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ " wraps liblinears problem struct ", /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9liblinear_Problem, /*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*/ __pyx_pf_9liblinear_7Problem___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9liblinear_Problem, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static PyObject *__pyx_tp_new_9liblinear_LinearSVM(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; return o; } static void __pyx_tp_dealloc_9liblinear_LinearSVM(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } static struct PyMethodDef __pyx_methods_9liblinear_LinearSVM[] = { {"train", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_train, METH_VARARGS|METH_KEYWORDS, 0}, {"build_confusion_matrix", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_build_confusion_matrix, METH_O, __pyx_doc_9liblinear_9LinearSVM_build_confusion_matrix}, {"tostring", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_tostring, METH_NOARGS, __pyx_doc_9liblinear_9LinearSVM_tostring}, {"fromstring", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_fromstring, METH_O, __pyx_doc_9liblinear_9LinearSVM_fromstring}, {"__reduce__", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM___reduce__, METH_NOARGS, __pyx_doc_9liblinear_9LinearSVM___reduce__}, {"predict", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_predict, METH_O, __pyx_doc_9liblinear_9LinearSVM_predict}, {"predict_probabilites", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_predict_probabilites, METH_O, __pyx_doc_9liblinear_9LinearSVM_predict_probabilites}, {"predict_values", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_predict_values, METH_O, __pyx_doc_9liblinear_9LinearSVM_predict_values}, {"get_weights", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_get_weights, METH_NOARGS, __pyx_doc_9liblinear_9LinearSVM_get_weights}, {"get_bias", (PyCFunction)__pyx_pf_9liblinear_9LinearSVM_get_bias, METH_NOARGS, __pyx_doc_9liblinear_9LinearSVM_get_bias}, {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_LinearSVM = { 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*/ 0, /*nb_long*/ 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_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX) 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_LinearSVM = { 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_LinearSVM = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_LinearSVM = { #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 }; PyTypeObject __pyx_type_9liblinear_LinearSVM = { PyVarObject_HEAD_INIT(0, 0) "liblinear.LinearSVM", /*tp_name*/ sizeof(struct __pyx_obj_9liblinear_LinearSVM), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9liblinear_LinearSVM, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_LinearSVM, /*tp_as_number*/ &__pyx_tp_as_sequence_LinearSVM, /*tp_as_sequence*/ &__pyx_tp_as_mapping_LinearSVM, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_LinearSVM, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9liblinear_LinearSVM, /*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*/ __pyx_pf_9liblinear_9LinearSVM___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9liblinear_LinearSVM, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static struct PyMethodDef __pyx_methods[] = { {"__fromstring", (PyCFunction)__pyx_pf_9liblinear___fromstring, METH_O, __pyx_doc_9liblinear___fromstring}, {"vector2sparse", (PyCFunction)__pyx_pf_9liblinear_vector2sparse, METH_O, __pyx_doc_9liblinear_vector2sparse}, {"matrix2sparse", (PyCFunction)__pyx_pf_9liblinear_matrix2sparse, METH_O, __pyx_doc_9liblinear_matrix2sparse}, {"crossvalidation", (PyCFunction)__pyx_pf_9liblinear_crossvalidation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9liblinear_crossvalidation}, {0, 0, 0, 0} }; static void __pyx_init_filenames(void); /*proto*/ #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, "liblinear", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1}, {&__pyx_kp_release, __pyx_k_release, sizeof(__pyx_k_release), 1, 1, 1}, {&__pyx_kp_train, __pyx_k_train, sizeof(__pyx_k_train), 1, 1, 1}, {&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 1, 1, 1}, {&__pyx_kp_tostring, __pyx_k_tostring, sizeof(__pyx_k_tostring), 1, 1, 1}, {&__pyx_kp_fromstring, __pyx_k_fromstring, sizeof(__pyx_k_fromstring), 1, 1, 1}, {&__pyx_kp___reduce__, __pyx_k___reduce__, sizeof(__pyx_k___reduce__), 1, 1, 1}, {&__pyx_kp_predict, __pyx_k_predict, sizeof(__pyx_k_predict), 1, 1, 1}, {&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 1, 1, 1}, {&__pyx_kp_predict_values, __pyx_k_predict_values, sizeof(__pyx_k_predict_values), 1, 1, 1}, {&__pyx_kp_get_weights, __pyx_k_get_weights, sizeof(__pyx_k_get_weights), 1, 1, 1}, {&__pyx_kp_get_bias, __pyx_k_get_bias, sizeof(__pyx_k_get_bias), 1, 1, 1}, {&__pyx_kp_txt, __pyx_k_txt, sizeof(__pyx_k_txt), 1, 1, 1}, {&__pyx_kp_vec, __pyx_k_vec, sizeof(__pyx_k_vec), 1, 1, 1}, {&__pyx_kp_mat, __pyx_k_mat, sizeof(__pyx_k_mat), 1, 1, 1}, {&__pyx_kp_mach, __pyx_k_mach, sizeof(__pyx_k_mach), 1, 1, 1}, {&__pyx_kp_eps, __pyx_k_eps, sizeof(__pyx_k_eps), 1, 1, 1}, {&__pyx_kp_C, __pyx_k_C, sizeof(__pyx_k_C), 1, 1, 1}, {&__pyx_kp_weights, __pyx_k_weights, sizeof(__pyx_k_weights), 1, 1, 1}, {&__pyx_kp_num_classes, __pyx_k_num_classes, sizeof(__pyx_k_num_classes), 1, 1, 1}, {&__pyx_kp_data, __pyx_k_data, sizeof(__pyx_k_data), 1, 1, 1}, {&__pyx_kp_verbose, __pyx_k_verbose, sizeof(__pyx_k_verbose), 1, 1, 1}, {&__pyx_kp_input, __pyx_k_input, sizeof(__pyx_k_input), 1, 1, 1}, {&__pyx_kp_num_folds, __pyx_k_num_folds, sizeof(__pyx_k_num_folds), 1, 1, 1}, {&__pyx_kp_zlib, __pyx_k_zlib, sizeof(__pyx_k_zlib), 1, 1, 1}, {&__pyx_kp_3, __pyx_k_3, sizeof(__pyx_k_3), 1, 1, 1}, {&__pyx_kp_4, __pyx_k_4, sizeof(__pyx_k_4), 1, 1, 1}, {&__pyx_kp_5, __pyx_k_5, sizeof(__pyx_k_5), 1, 1, 1}, {&__pyx_kp_6, __pyx_k_6, sizeof(__pyx_k_6), 1, 1, 1}, {&__pyx_kp_MCSVM_CS, __pyx_k_MCSVM_CS, sizeof(__pyx_k_MCSVM_CS), 1, 1, 1}, {&__pyx_kp_version, __pyx_k_version, sizeof(__pyx_k_version), 1, 1, 1}, {&__pyx_kp_decompress, __pyx_k_decompress, sizeof(__pyx_k_decompress), 1, 1, 1}, {&__pyx_kp_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 1, 1, 1}, {&__pyx_kp_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 1, 1, 1}, {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1}, {&__pyx_kp_append, __pyx_k_append, sizeof(__pyx_k_append), 1, 1, 1}, {&__pyx_kp_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 1, 0}, {&__pyx_kp_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0}, {&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1}, {&__pyx_kp___fromstring, __pyx_k___fromstring, sizeof(__pyx_k___fromstring), 1, 1, 1}, {&__pyx_kp_compress, __pyx_k_compress, sizeof(__pyx_k_compress), 1, 1, 1}, {&__pyx_kp_range, __pyx_k_range, sizeof(__pyx_k_range), 1, 1, 1}, {&__pyx_kp_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 0}, {&__pyx_kp_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 0}, {&__pyx_kp_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 0}, {&__pyx_kp_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 0}, {&__pyx_kp_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 0}, {&__pyx_kp_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 0}, {&__pyx_kp_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 0}, {&__pyx_kp_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 0}, {&__pyx_kp_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 0}, {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 0}, {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 0}, {&__pyx_kp_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 0}, {&__pyx_kp_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 0}, {&__pyx_kp_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 0}, {&__pyx_kp_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 0}, {0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_kp_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_kp_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_kp_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitGlobals(void) { __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__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;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initliblinear(void); /*proto*/ PyMODINIT_FUNC initliblinear(void) #else PyMODINIT_FUNC PyInit_liblinear(void); /*proto*/ PyMODINIT_FUNC PyInit_liblinear(void) #endif { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; __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;} /*--- Library function declarations ---*/ __pyx_init_filenames(); /*--- Initialize various global constants etc. ---*/ if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("liblinear", __pyx_methods, 0, 0, PYTHON_API_VERSION); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #if PY_MAJOR_VERSION < 3 Py_INCREF(__pyx_m); #endif __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Builtin init code ---*/ if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_skip_dispatch = 0; /*--- Global init code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_9liblinear_Parameter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "Parameter", (PyObject *)&__pyx_type_9liblinear_Parameter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_9liblinear_Parameter = &__pyx_type_9liblinear_Parameter; if (PyType_Ready(&__pyx_type_9liblinear_Problem) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "Problem", (PyObject *)&__pyx_type_9liblinear_Problem) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_9liblinear_Problem = &__pyx_type_9liblinear_Problem; if (PyType_Ready(&__pyx_type_9liblinear_LinearSVM) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttrString(__pyx_m, "LinearSVM", (PyObject *)&__pyx_type_9liblinear_LinearSVM) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_9liblinear_LinearSVM = &__pyx_type_9liblinear_LinearSVM; /*--- Type import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":4 * cimport liblinear_enums * * import zlib # <<<<<<<<<<<<<< * * L2_LR = liblinear_enums.L2_LR */ __pyx_1 = __Pyx_Import(__pyx_kp_zlib, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_zlib, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":6 * import zlib * * L2_LR = liblinear_enums.L2_LR # <<<<<<<<<<<<<< * L2LOSS_SVM_DUAL = liblinear_enums.L2LOSS_SVM_DUAL * L2LOSS_SVM = liblinear_enums.L2LOSS_SVM */ __pyx_1 = PyInt_FromLong(L2_LR); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_3, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":7 * * L2_LR = liblinear_enums.L2_LR * L2LOSS_SVM_DUAL = liblinear_enums.L2LOSS_SVM_DUAL # <<<<<<<<<<<<<< * L2LOSS_SVM = liblinear_enums.L2LOSS_SVM * L1LOSS_SVM_DUAL = liblinear_enums.L1LOSS_SVM_DUAL */ __pyx_1 = PyInt_FromLong(L2LOSS_SVM_DUAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_4, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":8 * L2_LR = liblinear_enums.L2_LR * L2LOSS_SVM_DUAL = liblinear_enums.L2LOSS_SVM_DUAL * L2LOSS_SVM = liblinear_enums.L2LOSS_SVM # <<<<<<<<<<<<<< * L1LOSS_SVM_DUAL = liblinear_enums.L1LOSS_SVM_DUAL * MCSVM_CS = liblinear_enums.MCSVM_CS */ __pyx_1 = PyInt_FromLong(L2LOSS_SVM); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_5, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":9 * L2LOSS_SVM_DUAL = liblinear_enums.L2LOSS_SVM_DUAL * L2LOSS_SVM = liblinear_enums.L2LOSS_SVM * L1LOSS_SVM_DUAL = liblinear_enums.L1LOSS_SVM_DUAL # <<<<<<<<<<<<<< * MCSVM_CS = liblinear_enums.MCSVM_CS * */ __pyx_1 = PyInt_FromLong(L1LOSS_SVM_DUAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_6, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":10 * L2LOSS_SVM = liblinear_enums.L2LOSS_SVM * L1LOSS_SVM_DUAL = liblinear_enums.L1LOSS_SVM_DUAL * MCSVM_CS = liblinear_enums.MCSVM_CS # <<<<<<<<<<<<<< * * version = "1.1.5" */ __pyx_1 = PyInt_FromLong(MCSVM_CS); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (PyObject_SetAttr(__pyx_m, __pyx_kp_MCSVM_CS, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":12 * MCSVM_CS = liblinear_enums.MCSVM_CS * * version = "1.1.5" # <<<<<<<<<<<<<< * * # TODO: scipy sparse matrices !!! */ if (PyObject_SetAttr(__pyx_m, __pyx_kp_version, __pyx_kp_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":197 * * @classmethod * def train(cls, data , mach=L2LOSS_SVM_DUAL, float C=1.0, float eps=0.01, \ # <<<<<<<<<<<<<< * weights=None, verbose=0): * */ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_k_8 = __pyx_1; __pyx_1 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":196 * self.mod = NULL * * @classmethod # <<<<<<<<<<<<<< * def train(cls, data , mach=L2LOSS_SVM_DUAL, float C=1.0, float eps=0.01, \ * weights=None, verbose=0): */ __pyx_2 = __Pyx_GetName((PyObject *)__pyx_ptype_9liblinear_LinearSVM, __pyx_kp_train); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = __Pyx_Method_ClassMethod(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (PyDict_SetItem((PyObject *)__pyx_ptype_9liblinear_LinearSVM->tp_dict, __pyx_kp_train, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyType_Modified(__pyx_ptype_9liblinear_LinearSVM); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":282 * * @classmethod * def fromstring(cls, input): # <<<<<<<<<<<<<< * """ builds model from text representatino """ * */ __pyx_2 = __Pyx_GetName((PyObject *)__pyx_ptype_9liblinear_LinearSVM, __pyx_kp_fromstring); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_3 = __Pyx_Method_ClassMethod(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (PyDict_SetItem((PyObject *)__pyx_ptype_9liblinear_LinearSVM->tp_dict, __pyx_kp_fromstring, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyType_Modified(__pyx_ptype_9liblinear_LinearSVM); /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pyx":378 * * * def crossvalidation(data, mach=L2LOSS_SVM_DUAL, int num_folds=5, float C=1.0, \ # <<<<<<<<<<<<<< * float eps=0.01, weights=None, verbose=0): * """ runs crossvalidation. before running crossvalidation, the data */ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_k_9 = __pyx_2; __pyx_2 = 0; /* "C:\cygwin\home\uschmitt\svn\public_procoders\liblinear2scipy\src\liblinear.pxd":1 * #----------------------------------------------------------- extern declarations # <<<<<<<<<<<<<< * cdef extern from "Python.h": * object PyString_FromStringAndSize (char * s, int len) */ #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif __pyx_L1_error:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("liblinear"); #if PY_MAJOR_VERSION >= 3 return NULL; #endif } static const char *__pyx_filenames[] = { "liblinear.pyx", }; /* Runtime support code */ static void __pyx_init_filenames(void) { __pyx_f = __pyx_filenames; } static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AS_STRING(kw_name)); #endif } 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 *number, *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"; } number = (num_expected == 1) ? "" : "s"; PyErr_Format(PyExc_TypeError, #if PY_VERSION_HEX < 0x02050000 "%s() takes %s %d positional argument%s (%d given)", #else "%s() takes %s %zd positional argument%s (%zd given)", #endif func_name, more_or_less, num_expected, number, num_found); } static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { #else if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { #endif goto invalid_keyword_type; } else { name = argnames; while (*name && (**name != key)) name++; if (*name) { if (name < first_kw_arg) goto arg_passed_twice; values[name-argnames] = value; } else { for (name = first_kw_arg; *name; name++) { #if PY_MAJOR_VERSION >= 3 if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && PyUnicode_Compare(**name, key) == 0) break; #else if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && strcmp(PyString_AS_STRING(**name), PyString_AS_STRING(key)) == 0) break; #endif } 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 if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; #else if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && strcmp(PyString_AS_STRING(**name), PyString_AS_STRING(key)) == 0) goto arg_passed_twice; #endif } if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } } } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, **name); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%s() got an unexpected keyword argument '%s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #else if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) #endif goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%s() keywords must be strings", function_name); return 0; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%s() got an unexpected keyword argument '%s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { PyThreadState *tstate = PyThreadState_GET(); *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { PyObject *__import__ = 0; PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); if (!__import__) goto bad; if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; module = PyObject_CallFunction(__import__, "OOOO", name, global_dict, empty_dict, list); bad: Py_XDECREF(empty_list); Py_XDECREF(__import__); Py_XDECREF(empty_dict); return module; } static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); if (!result) PyErr_SetObject(PyExc_NameError, name); return result; } static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { /* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */ /* if (!PyObject_TypeCheck(method, &PyMethodDescr_Type)) { */ if (strcmp(Py_TYPE(method)->tp_name, "method_descriptor") == 0) { /* cdef classes */ PyMethodDescrObject *descr = (PyMethodDescrObject *)method; return PyDescr_NewClassMethod(descr->d_type, descr->d_method); } else if (PyMethod_Check(method)) { /* python classes */ return PyClassMethod_New(PyMethod_GET_FUNCTION(method)); } else if (PyCFunction_Check(method)) { return PyClassMethod_New(method); } PyErr_Format(PyExc_TypeError, "Class-level classmethod() can only be called on a method_descriptor or instance method."); return NULL; } static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { 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; } else if (tb != NULL && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "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); } #if PY_VERSION_HEX < 0x02050000 if (!PyClass_Check(type)) #else 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 if (PyInstance_Check(type)) { type = (PyObject*) ((PyInstanceObject*)type)->in_class; Py_INCREF(type); } else { type = 0; PyErr_SetString(PyExc_TypeError, "raise: exception must be an old-style class or instance"); goto raise_error; } #else type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } #endif } __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { 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; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { 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; } static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (!type) { PyErr_Format(PyExc_SystemError, "Missing type object"); return 0; } if (obj == Py_None || PyObject_TypeCheck(obj, type)) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } #if PY_MAJOR_VERSION < 3 static PyObject *__Pyx_GetStdout(void) { PyObject *f = PySys_GetObject("stdout"); if (!f) { PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); } return f; } static int __Pyx_Print(PyObject *arg_tuple, int newline) { PyObject *f; PyObject* v; int i; if (!(f = __Pyx_GetStdout())) return -1; for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { if (PyFile_SoftSpace(f, 1)) { if (PyFile_WriteString(" ", f) < 0) return -1; } v = PyTuple_GET_ITEM(arg_tuple, i); if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) return -1; if (PyString_Check(v)) { char *s = PyString_AsString(v); Py_ssize_t len = PyString_Size(v); if (len > 0 && isspace(Py_CHARMASK(s[len-1])) && s[len-1] != ' ') PyFile_SoftSpace(f, 0); } } if (newline) { if (PyFile_WriteString("\n", f) < 0) return -1; PyFile_SoftSpace(f, 0); } return 0; } #else /* Python 3 has a print function */ static int __Pyx_Print(PyObject *arg_tuple, int newline) { PyObject* kwargs = 0; PyObject* result = 0; PyObject* end_string; if (!__pyx_print) { __pyx_print = PyObject_GetAttrString(__pyx_b, "print"); if (!__pyx_print) return -1; } if (!newline) { if (!__pyx_print_kwargs) { __pyx_print_kwargs = PyDict_New(); if (!__pyx_print_kwargs) return -1; end_string = PyUnicode_FromStringAndSize(" ", 1); if (!end_string) return -1; if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) { Py_DECREF(end_string); return -1; } Py_DECREF(end_string); } kwargs = __pyx_print_kwargs; } result = PyObject_Call(__pyx_print, arg_tuple, kwargs); if (!result) return -1; Py_DECREF(result); return 0; } #endif static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); __Pyx_ErrFetch(type, value, tb); PyErr_NormalizeException(type, value, tb); if (PyErr_Occurred()) goto bad; Py_INCREF(*type); Py_INCREF(*value); Py_INCREF(*tb); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; /* Make sure tstate is in a consistent state when we XDECREF these objects (XDECREF may run arbitrary code). */ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); return 0; bad: Py_XDECREF(*type); Py_XDECREF(*value); Py_XDECREF(*tb); return -1; } static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) { PyObject *item; if (!(item = PyIter_Next(iter))) { if (!PyErr_Occurred()) { PyErr_Format(PyExc_ValueError, #if PY_VERSION_HEX < 0x02050000 "need more than %d values to unpack", (int)index); #else "need more than %zd values to unpack", index); #endif } } return item; } static int __Pyx_EndUnpack(PyObject *iter) { PyObject *item; if ((item = PyIter_Next(iter))) { Py_DECREF(item); PyErr_SetString(PyExc_ValueError, "too many values to unpack"); return -1; } else if (!PyErr_Occurred()) return 0; else return -1; } static void __Pyx_WriteUnraisable(const char *name) { 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); } } #include "compile.h" #include "frameobject.h" #include "traceback.h" static void __Pyx_AddTraceback(const char *funcname) { PyObject *py_srcfile = 0; PyObject *py_funcname = 0; PyObject *py_globals = 0; PyObject *empty_string = 0; PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(__pyx_filename); #else py_srcfile = PyUnicode_FromString(__pyx_filename); #endif if (!py_srcfile) goto bad; if (__pyx_clineno) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_globals = PyModule_GetDict(__pyx_m); if (!py_globals) goto bad; #if PY_MAJOR_VERSION < 3 empty_string = PyString_FromStringAndSize("", 0); #else empty_string = PyBytes_FromStringAndSize("", 0); #endif if (!empty_string) 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,*/ empty_string, /*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,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ __pyx_lineno, /*int firstlineno,*/ empty_string /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_string); Py_XDECREF(py_code); Py_XDECREF(py_frame); } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode && (!t->is_identifier)) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else /* Python 3+ has unicode identifiers */ if (t->is_identifier || (t->is_unicode && t->intern)) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->is_unicode) { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } /* Type Conversion Functions */ static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject* x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (x == Py_True) return 1; else if (x == Py_False) return 0; else return PyObject_IsTrue(x); } static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) { if (PyInt_CheckExact(x)) { return PyInt_AS_LONG(x); } else if (PyLong_CheckExact(x)) { return PyLong_AsLongLong(x); } else { PY_LONG_LONG val; PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1; val = __pyx_PyInt_AsLongLong(tmp); Py_DECREF(tmp); return val; } } static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) { if (PyInt_CheckExact(x)) { long val = PyInt_AS_LONG(x); if (unlikely(val < 0)) { PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type."); return (unsigned PY_LONG_LONG)-1; } return val; } else if (PyLong_CheckExact(x)) { return PyLong_AsUnsignedLongLong(x); } else { PY_LONG_LONG val; PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1; val = __pyx_PyInt_AsUnsignedLongLong(tmp); Py_DECREF(tmp); return val; } } static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) { if (sizeof(unsigned char) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); unsigned char val = (unsigned char)long_val; if (unlikely((val != long_val) || (long_val < 0))) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char"); return (unsigned char)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) { if (sizeof(unsigned short) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); unsigned short val = (unsigned short)long_val; if (unlikely((val != long_val) || (long_val < 0))) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short"); return (unsigned short)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE char __pyx_PyInt_char(PyObject* x) { if (sizeof(char) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); char val = (char)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to char"); return (char)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE short __pyx_PyInt_short(PyObject* x) { if (sizeof(short) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); short val = (short)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to short"); return (short)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE int __pyx_PyInt_int(PyObject* x) { if (sizeof(int) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); int val = (int)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE long __pyx_PyInt_long(PyObject* x) { if (sizeof(long) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); long val = (long)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) { if (sizeof(signed char) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); signed char val = (signed char)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char"); return (signed char)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) { if (sizeof(signed short) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); signed short val = (signed short)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short"); return (signed short)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) { if (sizeof(signed int) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); signed int val = (signed int)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int"); return (signed int)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) { if (sizeof(signed long) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); signed long val = (signed long)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long"); return (signed long)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } } static INLINE long double __pyx_PyInt_long_double(PyObject* x) { if (sizeof(long double) < sizeof(long)) { long long_val = __pyx_PyInt_AsLong(x); long double val = (long double)long_val; if (unlikely((val != long_val) )) { PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double"); return (long double)-1; } return val; } else { return __pyx_PyInt_AsLong(x); } }