Package adams.data.instance
Class InstanceUtils
- java.lang.Object
-
- adams.data.container.DataContainerUtils
-
- adams.data.instance.InstanceUtils
-
public class InstanceUtils extends adams.data.container.DataContainerUtils
Utility class for instances.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected static InstancePointComparator
m_Comparator
comparator for finding X values.
-
Constructor Summary
Constructors Constructor Description InstanceUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
findClosestX(List<InstancePoint> points, int x)
Returns the index in m_Points closest to the given x value.static int[]
findEnclosingXs(List<InstancePoint> points, int x)
Returns the indices of points in m_Points that enclose the given x value.static int
findX(List<InstancePoint> points, int x)
Returns the index in m_Points of the given x value.static int
findX(List<InstancePoint> points, InstancePoint p)
Returns the index in m_Points of the given sequence point.static InstancePointComparator
getComparator()
Returns the comparator used for finding X values.static double[]
toDoubleArray(Instance c)
Returns the points as double array.static double[]
toDoubleArray(List<InstancePoint> data)
Returns the points as double array.
-
-
-
Field Detail
-
m_Comparator
protected static InstancePointComparator m_Comparator
comparator for finding X values.
-
-
Method Detail
-
getComparator
public static InstancePointComparator getComparator()
Returns the comparator used for finding X values.- Returns:
- the comparator
-
findX
public static int findX(List<InstancePoint> points, InstancePoint p)
Returns the index in m_Points of the given sequence point.- Parameters:
points
- the data to processp
- the point to get the index for- Returns:
- the index
-
findX
public static int findX(List<InstancePoint> points, int x)
Returns the index in m_Points of the given x value.- Parameters:
points
- the data to processx
- the x value to get the index for- Returns:
- the index
-
findClosestX
public static int findClosestX(List<InstancePoint> points, int x)
Returns the index in m_Points closest to the given x value.- Parameters:
points
- the data to processx
- the x value to get the closest index for- Returns:
- the index
-
findEnclosingXs
public static int[] findEnclosingXs(List<InstancePoint> points, int x)
Returns the indices of points in m_Points that enclose the given x value. If the given x value happens to be an exact point, then this points will be stored at index 0. If no index could be determined, then -1 will be stored.- Parameters:
points
- the data to processx
- the x value to get the enclosing indices for- Returns:
- the indices
-
toDoubleArray
public static double[] toDoubleArray(Instance c)
Returns the points as double array.- Parameters:
c
- the instance to turn into a double array- Returns:
- the points as double array
-
toDoubleArray
public static double[] toDoubleArray(List<InstancePoint> data)
Returns the points as double array.- Parameters:
data
- the instance points to turn into a double array- Returns:
- the points as double array
-
-