Package adams.ml.data

Class WekaConverter


  • public class WekaConverter
    extends Object
    Helper class for converting data to and fro Weka.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • WekaConverter

        public WekaConverter()
    • Method Detail

      • toInstances

        public static weka.core.Instances toInstances​(Dataset data)
                                               throws Exception
        Converts an ADAMS Dataset to Weka Instances. Only sets the class attribute if the dataset has exactly one defined.
        Parameters:
        data - the data to convert
        Returns:
        the generated data
        Throws:
        Exception - if conversion fails
      • toDataset

        public static Dataset toDataset​(weka.core.Instances data)
                                 throws Exception
        Converts a Weka Instances object into an ADAMS Dataset.
        Parameters:
        data - the data to convert
        Returns:
        the generated data
        Throws:
        Exception - if conversion fail
      • toInstance

        public static weka.core.Instance toInstance​(weka.core.Instances data,
                                                    Row row)
                                             throws Exception
        Turns an ADAMS dataset row into a Weka Instance.
        Parameters:
        data - the dataset to use as template
        row - the row to convert
        Returns:
        the generated instance
        Throws:
        Exception - if conversion fails
      • transferCapability

        protected static void transferCapability​(weka.core.Capabilities fromCaps,
                                                 weka.core.Capabilities.Capability fromCap,
                                                 Capabilities toCaps,
                                                 Capability toCap)
        Transfers the specified capability if enabled. Also checks whether dependency is flagged.
        Parameters:
        fromCaps - the Weka capabilities
        fromCap - the Weka capability to check
        toCaps - the ADAMS capabilities
        toCap - the ADAMS capability to set, if necessary
      • convertCapabilities

        public static Capabilities convertCapabilities​(weka.core.Capabilities caps)
        Converts Weka capabilities into ADAMS ones.
        Parameters:
        caps - the capabilities to convert
        Returns:
        the converted capabilities