23087

How to disable the console output in libsvm (java)

I am using libsvm in <strong>java</strong> and am experiencing similar issues as described here for python.

I am getting a lot of console output during training and prediction and would like to disable it. Sadly, due to a "Service Temporary Unavaiable" I can't access the website, where it might be described (here). I couldn't find a java related way to disable this warnings (If I did oversee something I apologize)

The Output always looks quite similar to this:

optimization finished, #iter = 10000000 nu = 0.013178458659415372 obj = -11.005078334927212, rho = -2.1799731001804696 nSV = 20, nBSV = 5 Total nSV = 20

Do you know how I can disable this kind of output in java?

Thanks a lot for your help.

Answer1:

To disable output programmatically you need to do the following:

svm.svm_set_print_string_function(new libsvm.svm_print_interface(){ @Override public void print(String s) {} // Disables svm output });

Answer2:

At the command line just use the -q option.

$ ./svm-train Usage: svm-train [options] training_set_file [model_file] options: -s svm_type : set type of SVM (default 0) *** lots of stuff cut out... -q : quiet mode (no outputs)

If you have your own java trainer, set the print_func for you svm_print_null. (I think the only way to do this is to with the svm_train class is by passing "-q" with your other parameters into the main method).

Hope it helps

Answer3:

To disable libsvm output in terminal for Java I use:

import java.io.PrintStream; import java.io.OutputStream; System.setOut(new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException {} }));

Keep in mind the output to the terminal is disabled, but a logger can be used instead which does output:

import org.apache.log4j.Logger; private static final Logger LOG = Logger.getLogger(YourClass.class);

Place the log4j.properties file in your resources folder.

The log4j.properties file may look like the following:

#info,debug, error,fatal ... log4j.rootLogger=debug,stdout #console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

Recommend

  • How to create source data file for training and testing file in libsvm?
  • Your CPU does not support VT-x
  • sklearn 0.17.1: ImportError: cannot import name inplace_column_scale
  • Using SVM with HOG Features to Classify Vehicles
  • Evaluate Loss Function Value Getting From Training Set on Cross Validation Set
  • Verbose log abbriviations meaning in SVC, scikit-learn
  • Tamper-proof configuration files in .NET?
  • Display java JPanel in a JFrame
  • How can I set a binding to a Combox in a UserControl?
  • Sort List of Strings By Version
  • Problems compiling files using JOGL
  • Parsing a CSV string while ignoring commas inside the individual columns
  • Swing - Get new component under mouseReleased
  • MVC3 Razor - ListBox pre-select not working
  • Set the selected item in dropdownlist in MVC3
  • Checking free space on FTP server
  • Can I check if a recipient has an automatic reply before I send an email?
  • NHibernate Validation Localization with S#arp Architecture
  • ilmerge with a PFX file
  • how to do an event when i swipe from fragment to the other
  • Spring Data JPA custom method causing PropertyReferenceException
  • Update CALayer sublayers immediately
  • JFileChooser in front of fullscreen Swing application
  • Can I display google adwords (AdView) in javafx on android
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Eraser for UIBezierPath
  • align graphs with different xlab
  • Return words with double consecutive letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • Suggestions to manage Login/Logout transitions
  • JTable with a ScrollPane misbehaving
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Reading document lines to the user (python)
  • failed to connect to specific WiFi in android programmatically
  • Python/Django TangoWithDjango Models and Databases
  • How can I use threading to 'tick' a timer to be accessed by other threads?