Package adams.ml.data
Class WekaConverter
- java.lang.Object
-
- adams.ml.data.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 Summary
Constructors Constructor Description WekaConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Capabilities
convertCapabilities(weka.core.Capabilities caps)
Converts Weka capabilities into ADAMS ones.static Dataset
toDataset(weka.core.Instances data)
Converts a Weka Instances object into an ADAMS Dataset.static weka.core.Instance
toInstance(weka.core.Instances data, Row row)
Turns an ADAMS dataset row into a Weka Instance.static weka.core.Instances
toInstances(Dataset data)
Converts an ADAMS Dataset to Weka Instances.protected static void
transferCapability(weka.core.Capabilities fromCaps, weka.core.Capabilities.Capability fromCap, Capabilities toCaps, Capability toCap)
Transfers the specified capability if enabled.
-
-
-
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 templaterow
- 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 capabilitiesfromCap
- the Weka capability to checktoCaps
- the ADAMS capabilitiestoCap
- 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
-
-