public class RBFUtils
extends java.lang.Object
A set of useful functions to be used in EvRBF_CL.
Constructor and Description |
---|
RBFUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
array2string(double[] _a)
Creates a string from an array of doubles
|
static java.lang.String |
array2string(int[] _a)
Creates a string from an array of integer
|
static double |
avegDistance(double[][] _values)
Computes the average distance between vectors in a double[][]
|
static int |
computeMatches(int[] _a1,
int[] _a2,
int _nDatos)
Returns the number of elements that match in two arrays (of integer )
|
static java.lang.String |
createIdRbf()
Creates a unique identifier to be used for a RBF
|
static void |
createOutputFile(java.lang.String _origin,
java.lang.String _destiny)
Creates an output file following Keel rules: the header of the training/test file must be written into
the result file.
|
static double |
euclidean(double[] _a,
double[] _b)
Computes the euclidean distance between two vector of doubles with equal size.
|
static boolean |
getVerbosity()
Returns verbosity value
|
static double |
maxDistance(double[][] _values)
Computes the maximun distance between vectors in a double[][]
|
static int |
maxInVector(double[] _vector)
Returns the index of the higher value
|
static double[] |
medVect(double[][] v)
Computes the average of the rows of matrix v
|
static java.util.Hashtable |
parameters(java.lang.String fileName)
Reads a text file with parameters of the form name=value and returns a hastable containing them.
|
static void |
printArray(double[] _a)
Prints on console the elements of an array of doubles
|
static void |
printArray(int[] _a)
Prints on console the elements of an array of integers
|
static boolean |
setVerbosity(boolean _value)
Sets verbosity value from a given value
|
static boolean |
setVerbosity(java.util.Hashtable _hashtable)
Sets verbosity value from hashtable containing parameters
|
static double[] |
vector2doubles(java.util.Vector _v)
Turns vector of strings into a double array.
|
static double[] |
vector2Input(java.util.Vector _v,
int _inpDim)
Turns vector of strings into a double array containing only the inputs
|
static void |
vector2InputOutput(java.util.Vector _v,
int _inpDim,
double[] _input,
double[] _output)
Turns vector of strings into two double arrays, one for inputs and other for outputs.
|
static double[] |
vector2Output(java.util.Vector _v,
int _outDim)
Turns vector of strings into a double array containing only the outputs
|
static void |
verbose(java.lang.String _cad)
Prints the parameter without adding new line only if verbosity has been set to True.
|
static void |
verboseln(java.lang.String _cad)
Prints the parameter and adds a new line only if verbosity has been set to True.
|
public static boolean setVerbosity(java.util.Hashtable _hashtable)
Sets verbosity value from hashtable containing parameters
_hashtable
- The hashtable containing the parameters.public static boolean setVerbosity(boolean _value)
Sets verbosity value from a given value
_value
- True or falsepublic static boolean getVerbosity()
Returns verbosity value
public static void verbose(java.lang.String _cad)
Prints the parameter without adding new line only if verbosity has been set to True.
_cad
- Parameter to be printed.public static void verboseln(java.lang.String _cad)
Prints the parameter and adds a new line only if verbosity has been set to True.
_cad
- Parameter to be printed.public static double[] vector2doubles(java.util.Vector _v)
Turns vector of strings into a double array.
_v
- The vectorpublic static void vector2InputOutput(java.util.Vector _v, int _inpDim, double[] _input, double[] _output) throws java.io.IOException
Turns vector of strings into two double arrays, one for inputs and other for outputs.
_v
- The vector_inpDim
- Input dimension_input
- Array in which INPUT values are returned_output
- Array in which OUTPUT values are returnedjava.io.IOException
- if the dimension of inputs or outputs is 0public static double[] vector2Input(java.util.Vector _v, int _inpDim) throws java.io.IOException
Turns vector of strings into a double array containing only the inputs
_v
- The vector_inpDim
- Input dimensionjava.io.IOException
- if the dimension of inputs is 0public static double[] vector2Output(java.util.Vector _v, int _outDim) throws java.io.IOException
Turns vector of strings into a double array containing only the outputs
_v
- The vector_outDim
- Output dimensionjava.io.IOException
- if the dimension of outputs is 0public static void printArray(double[] _a)
Prints on console the elements of an array of doubles
_a
- The arraypublic static void printArray(int[] _a)
Prints on console the elements of an array of integers
_a
- The arraypublic static java.lang.String array2string(double[] _a)
Creates a string from an array of doubles
_a
- The arraypublic static java.lang.String array2string(int[] _a)
Creates a string from an array of integer
_a
- The arraypublic static double euclidean(double[] _a, double[] _b)
Computes the euclidean distance between two vector of doubles with equal size.
_a
- First vector_b
- Second vectorpublic static double[] medVect(double[][] v)
Computes the average of the rows of matrix v
v
- The matrixpublic static double maxDistance(double[][] _values)
Computes the maximun distance between vectors in a double[][]
_values
- The array containing the vectorspublic static double avegDistance(double[][] _values)
Computes the average distance between vectors in a double[][]
_values
- The array containing the vectorspublic static java.util.Hashtable parameters(java.lang.String fileName)
Reads a text file with parameters of the form name=value and returns a hastable containing them.
fileName
- Name of the file containing the parameters.public static void createOutputFile(java.lang.String _origin, java.lang.String _destiny)
Creates an output file following Keel rules: the header of the training/test file must be written into the result file.
_origin
- Name of the training/test file_destiny
- Name of the output filepublic static int maxInVector(double[] _vector)
Returns the index of the higher value
_vector
- Vector the datos in which higer values will be findpublic static int computeMatches(int[] _a1, int[] _a2, int _nDatos)
Returns the number of elements that match in two arrays (of integer )
_a1
- First array_a2
- Second array_nDatos
- Number of used data in the arrays (can be lower than _a1.length)public static java.lang.String createIdRbf()
Creates a unique identifier to be used for a RBF