Skip to content
Snippets Groups Projects
Commit ba758cba authored by Yaroslav Halchenko's avatar Yaroslav Halchenko
Browse files

tentative patch for runtime verbosity control of libsvm

parent 9353116c
No related branches found
No related tags found
No related merge requests found
--- a/scikits/learn/svm/src/libsvm/libsvm_helper.c
+++ b/scikits/learn/svm/src/libsvm/libsvm_helper.c
@@ -669,5 +669,33 @@ int free_param(struct svm_parameter *par
free(param);
return 0;
}
-
-
+
+/* rely on built-in facility to control verbose output
+ * in the versions of libsvm >= 2.89
+ */
+#if LIBSVM_VERSION && LIBSVM_VERSION >= 289
+
+/* borrowed from original libsvm code */
+static void print_null(const char *s) {}
+
+static void print_string_stdout(const char *s)
+{
+ fputs(s,stdout);
+ fflush(stdout);
+}
+
+/* provide convenience wrapper */
+void svm_set_verbosity(int verbosity_flag){
+ if (verbosity_flag)
+# if LIBSVM_VERSION < 291
+ svm_print_string = &print_string_stdout;
+ else
+ svm_print_string = &print_null;
+# else
+ svm_set_print_string_function(&print_string_stdout);
+ else
+ svm_set_print_string_function(&print_null);
+# endif
+}
+#endif
+
--- a/scikits/learn/svm/src/libsvm/_libsvm.pyx
+++ b/scikits/learn/svm/src/libsvm/_libsvm.pyx
@@ -93,7 +93,7 @@ cdef extern from "libsvm_helper.c":
int free_model (svm_model *)
int free_model_SV (svm_model *)
int free_param (svm_parameter *)
-
+ void svm_set_verbosity(int)
################################################################################
# Wrapper functions
deb_use_system_joblib deb_use_system_joblib
deb_use_system_libraries deb_use_system_libraries
deb_libsvm_verbosity_control
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment