Class InstanceUtils


  • public class InstanceUtils
    extends DataContainerUtils
    Utility class for instances.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • InstanceUtils

        public InstanceUtils()
    • 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 process
        p - 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 process
        x - 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 process
        x - 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 process
        x - 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