An example of using LibSVM in java - java

I am considering using libsvm. Currently, I have transformed my feature vectors to SVM feature vectors format. I am using LibSVM inside a project I will need to somehow use it within my app. The problem is that at the moment all examples available use the command line to provide input to the LibSVM. I don want this.
Can you please give me an example of how I can use it within my code (no calls to the command prompt and no Weka).
Thanks

There are examples in the distribution source code https://github.com/arnaudsj/libsvm/tree/master/java

The applet doesn't use command-line input. Check libsvm-3.11.tar.gz\libsvm-3.11.tar\libsvm-3.11\java

Related

API in Java for STEP (p21) - to create STEP compliant files

I'm interested in writing Java to automate the creation of 3D STEP files (CAD format).
There seems to be something for C++ (https://github.com/stepcode/stepcode). There seem to be Java implementations of 3D CAD software (http://brlcad.org/).
However, I don't see an API / Package / Class Library anywhere to build STEP files using Java.
Ideas?
JSDAI is a java API for STEP files and is licensed AGPL.
www.jsdai.net
BIMserver and its friends in Open Source BIM](https://github.com/opensourceBIM) can easily handle this problem without writing a single line of code.

how to run svm light in java eclipse?

I have downloaded the JNI_SVM-light-6.01-64bit version for running svm in Java. I have tried searching online but did not exactly figure out the steps to run the library using eclipse IDE for java. All I want to do is know how to provide an input training file to train the model, and give a test file so that I get the corresponding results? A step by step instruction to do it using eclipse IDE would be very helpful.
Another way to run SVMLight from Java code in Eclipse is by using ClearTK. This allows for a standardized way to provide data to and get results from not only SVMLight, but also other models such as CRF.
Hey did you check out the test file? I'm trying it out now myself after importing the library by going to build path > Add External Archives.
You can find the test file here:
http://www.mpi-inf.mpg.de/~mtb/svmlight/JNI_SVMLight_Test.java
In the file it creates a random dataset, trains it, calculates the accuracy.. so it's basically giving you the standard operations that you will need.

Java program for Data Processing and Matlab code for results plotting

I am a beginner in the field of Data Mining. I have a data which i need to process before visualizing any useful results. So I do the following:
Preprocess data using Java Program ( Output : txt files) (Input: FileNames)
Convert .txt files to .xls files ( Excel file)
Import excel file in MATLAB
Write Matlab Script to draw some plots on the imported data
I wish to automate this process by just pressing run button and then it happens automatically.
Please guide me how to integrate my work so instead of doing these 4 steps each time i just provide input file names and all the work is done in one go.
Thanks!
You can use arbitrary Java classes from within MATLAB - it is supported to run user-defined classes and even pass data between them and MATLAB. This would give you the following benefits:
no need to write text files/XLS and then import them into matlab
write everything in one MATLAB script - that is what duffymo had in mind, just that you do not need any shell/batch processing. Everything is done in MATLAB
you could add a MATLAB-implemented GUI to handle the process
Have a look at this SO post for some insights.
You want a scripting language: Windows command if you're on that platform; shell scripts on Linux.
It might not be a button, because that implies a UI. You have to write what amounts to an application for that.
The java matlabcontrol library might come in handy
http://code.google.com/p/matlabcontrol/
I had a similar task some time ago. Matlabcontrol is a library which connects MATLAB to your Java program and is quite easy to use.
All steps can be done in Matlab environment.
Java code can be called in Matlab directly. Just add your java class path to Classpath.txt in Matlab and import in the script code.
Maybe CSV data file is better for your case.

Filters on Weka

I need to generate a filter in Java using the Weka API that will read in files and trigger an alert if a file contains a word from a predefined list. I am just beginning Weka so am not entirely sure how this would work in weka, please help :) I can't find any tutorials which are for beginners
Everything you need to begin with Weka API can be found in this site.
When I need to build some kind of filter, I subclass BufferedReader (java.io.BufferedReader) and override some of its methods. Weka also has some interfaces and classes that can do most of the job (like selecting only some desired attributes or normalizing data). Look inside that link to gain more knowledge about it.
As you are a beginner, the first thing you should learn is to properly use weka in your Java code. The following website will be helpful: Wekawiki

How to make graph from perf4j log file?

I have used perf4j to calculate the performance of the process. Now I want to make the graph for that file. Is it possible to make it without using Google API or any other method that can be used?
You have a couple of options:
When you use the org.perf4j.LogParser to parse your log, you can use the "--format csv" option to generate CSV output, open this up in Excel, then create a graph in Excel.
As the other poster said, I'm not sure why you're against using the Google Chart API, but if you are dead set against using it, note that the JFreeChart guys provide an implementation of the Google Chart APIs called Eastwood Charts: http://www.jfree.org/eastwood/. You could just set up an eastwood server and then proxy (or just set up in a hosts file) chart.apis.google . com to your eastwood server. Alternatively, if you look at the org.perf4j.LogParser class, you can override the newMeanTimeChartGenerator and newTpsChartGenerator methods to call the GoogleChartGenerator constructor that takes the base URL.
You can always create another implementation of the StatisticsChartGenerator interface and use this instead. Obviously this is the most involved option.
Can you explain a bit more as to why you want to avoid Google Charting APIs (I ask since I am intrigued as to why someone would not want to do something that is very simple, elegant and FREE)?
Also there is a GraphingServlet section "Exposing Performance Graphs in a Web Application" which I think internally does the same thing.
If you still want you can take the graph data (in raw csv format) and write some helper classes to create charts using libraries like jfreechart (rich client)
follow the following steps;
Go to the location where your perf4j log file exits and open command prompt there.
Hit the following command in cmd, make sure you have java(jdk) path set as environment variable and perf4j jar on this location:
java -jar perf4j-0.9.16.jar --graph perfGraphs.html perfLogFile.log
this will generate perfGraphs.html file in this location, which consists of graphs.

Categories

Resources