org.opentox.util.libSVM
Class svm_scale
java.lang.Object
org.opentox.util.libSVM.svm_scale
public class svm_scale
- extends java.lang.Object
This class is used to scale the input data.
We give a simple example of how you can use this class in your code to
scale a set of data given in DSD format. Suppose that you want to scale
your data within the range [-1,1], save the range parameters in a file, say
/somewhere/range/OpenTox-0, using the
input file /somewhere/dsd/OpenTox-0 and
then save the scaled file as /somewhere/scaled/OpenTox-sc10. Then this is the
corresponding code:
// Define the options:
String[] ops=
{
"-l",
"-1",
"-u",
"1",
"-s",
"/home/chung/Documents/RESTfulWebServices/uploads/range/OpenTox-0",
"/home/chung/Documents/RESTfulWebServices/uploads/dsd/OpenTox-0"
};
// Create an svm_scale object using the default constructor:
svm_scale a = new svm_scale();
// Perform the scaling:
a.scale(ops,"/home/chung/Documents/RESTfulWebServices/uploads/dsd/OpenTox-sc10");
Important: The original source code belongs to LibSVM
Reference: Chih-Chung Chang and Chih-Jen Lin,
LIBSVM: a library for support vector machines, 2001,
Software available at
http://www.csie.ntu.edu.tw/~cjlin/libsvm
Copyright:
Copyright (c) 2000-2009 Chih-Chung Chang and Chih-Jen Lin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither name of copyright holders nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- Author:
- Sopasakis Pantelis (Minor Modifications of the original code)
Method Summary |
private static void |
exit_with_help()
|
java.lang.String |
getScaledFileName()
|
private void |
output_target(double value,
java.io.BufferedWriter out)
|
private void |
output(int index,
double value,
java.io.BufferedWriter out)
|
private java.lang.String |
readline(java.io.BufferedReader fp)
|
private java.io.BufferedReader |
rewind(java.io.BufferedReader fp,
java.lang.String filename)
|
private void |
run(java.lang.String[] argv,
java.lang.String scaledFile)
|
void |
scale(java.lang.String[] argv,
java.lang.String scaledFileName)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
line
private java.lang.String line
lower
private double lower
upper
private double upper
y_lower
private double y_lower
y_upper
private double y_upper
y_scaling
private boolean y_scaling
feature_max
private double[] feature_max
feature_min
private double[] feature_min
y_max
private double y_max
y_min
private double y_min
max_index
private int max_index
num_nonzeros
private long num_nonzeros
new_num_nonzeros
private long new_num_nonzeros
scaledFileName
private java.lang.String scaledFileName
svm_scale
public svm_scale()
getScaledFileName
public java.lang.String getScaledFileName()
exit_with_help
private static void exit_with_help()
rewind
private java.io.BufferedReader rewind(java.io.BufferedReader fp,
java.lang.String filename)
throws java.io.IOException
- Throws:
java.io.IOException
output_target
private void output_target(double value,
java.io.BufferedWriter out)
throws java.io.IOException
- Throws:
java.io.IOException
output
private void output(int index,
double value,
java.io.BufferedWriter out)
throws java.io.IOException
- Throws:
java.io.IOException
readline
private java.lang.String readline(java.io.BufferedReader fp)
throws java.io.IOException
- Throws:
java.io.IOException
run
private void run(java.lang.String[] argv,
java.lang.String scaledFile)
throws java.io.IOException
- Throws:
java.io.IOException
scale
public void scale(java.lang.String[] argv,
java.lang.String scaledFileName)
throws java.io.IOException
- Throws:
java.io.IOException