David Campbell avatar David Campbell committed 80788ad

updates to svmlight.py

Comments (0)

Files changed (3)

svmlight/svmlight.py

 from ctypes import *
 
+VERSION = "V6.02"
+VERSION_DATE = "14.08.08"
+
+MAXFEATNUM = 99999999
+
+LINEAR  = 0
+POLY    = 1
+RBF     = 2
+SIGMOID = 3
+
+CLASSIFICATION = 1
+REGRESSION     = 2
+RANKING        = 3
+OPTIMIZATION   = 4
+
+MAXSHRINK = 50000
 svm = CDLL("./svmlight.so")
 
 class WORD(Structure):
 			    ("weight", c_float)]
 
 class SVECTOR(Structure):
-	_fields_ = [("words", WORD * 4),
-			    ("twonorm_sq", c_double)]
+	_fields_ = [("words", POINTER(WORD)),
+			    ("twonorm_sq", c_double),
+				("userdefined", c_char),
+				("kernel_id", c_long),
+				("next", POINTER(SVECTOR),
+				("factor", c_double)]
 
 
 class DOC(Structure):
 	_fields_ = [("docnum", c_long),
-			    ("queryid", c_long)]
+			    ("queryid", c_long),
+				("costfactor", c_double),
+				("slackid", c_long),
+				("fvec", POINTER(SVECTOR))]
 
 
 if __name__ == "__main__":
 	for word in svec.words:
 		print word.wnum
 
+def svm_learn2(*args, **kwds):
+    docs = POINTER(POINTER(DOC()))
+    target = POINTER(c_double)
+    totwords = c_int
+	totdoc = c_int
+    kernel_cache = POINTER(KERNEL_CACHE)
+    learn_parm = LEARN_PARM
+    kernel_parm = KERNEL_PARM
+    verbosity = c_long
+    #doclist = POINTER(PyObject) #FIXME
+    model = POINTER(MODEL)
+    result = POINTER(MODEL_AND_DOCS)
+	# DO THIS ONE!
+
+	# NULL: alpha in
+    if learn_parm.type == CLASSIFICATION {
+        svm.svm_learn_classification(docs, target, totdoc, totwords,
+			addressof(learn_parm), addressof(kernel_parm), kernel_cache,
+			model, None)
+    }
+
+
 '''
-def svm_learn2(*args, **kwds):
-
-
 
 static PyObject *svm_learn(PyObject *self, PyObject *args, PyObject *kwds)
 {
     else
         kernel_cache = kernel_cache_init(totdoc, learn_parm.kernel_cache_size);
 
+	# DO THIS ONE!
     if(learn_parm.type == CLASSIFICATION) {
         svm_learn_classification(docs, target, totdoc, totwords, &learn_parm,
                                  &kernel_parm, kernel_cache, model, NULL /* alpha_in */);
 void stuff(PYTEST2* pyt) {
 	int i;
 	printf("%d\n", pyt->pytest->i);
-	for (i = 0; i < pyt->pytest->i; i++)
+	for (i = 0; i < pyt->pytest->i; i++) {
 		printf("%d ", pyt->pytest->ints[i]);
+		pyt->pytest->ints[i]++;
+	}
 	printf("\n");
 }
 	py2.pytest = pointer(py1)
 	print "hi"
 	t.stuff(pointer(py2))
+	for i in ints:
+		print i
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.