adams.flow.core
Class DatasetHelper

java.lang.Object
  extended by adams.flow.core.DatasetHelper

public class DatasetHelper
extends Object

Helper class for converting to and from xrff datasets

Author:
msf8

Field Summary
protected static DateFormat m_DateFormat
          for formatting dates.
 
Constructor Summary
DatasetHelper()
           
 
Method Summary
static void addAttribute(Dataset dataset, String name, Type type)
          Adds an attribute to the dataset.
static void addStatistic(Dataset dataset, String name, double value)
          Adds a statistic as key/value pair to the dataset as new data row.
static void addValue(Instance inst, int index, double value)
          Adds the double value to the Instance.
static void addValue(Instance inst, int index, String value)
          Adds the string value to the Instance.
static String datasetToString(Dataset dataset)
          For outputting the dataset in debug mode.
static Dataset evaluationToDataset(Evaluation eval)
          Turns the evaluation object into a Dataset structure.
static Dataset fromInstances(Instances inst)
          static class that converts an instances object into an xrff dataset
static DateFormat getDateFormat()
          Returns the DateFormat instance to use.
static Instances toInstances(Dataset d)
          static class that converts an xrff dataset object into a weka instances object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_DateFormat

protected static DateFormat m_DateFormat
for formatting dates.

Constructor Detail

DatasetHelper

public DatasetHelper()
Method Detail

fromInstances

public static Dataset fromInstances(Instances inst)
static class that converts an instances object into an xrff dataset

Parameters:
inst - instances object to be converted
Returns:
xrff dataset

toInstances

public static Instances toInstances(Dataset d)
static class that converts an xrff dataset object into a weka instances object

Parameters:
d - dataset to convert
Returns:
A weka instances object representing the xrff dataset

datasetToString

public static String datasetToString(Dataset dataset)
For outputting the dataset in debug mode.

Parameters:
dataset - the dataset to output

addAttribute

public static void addAttribute(Dataset dataset,
                                String name,
                                Type type)
Adds an attribute to the dataset.

Parameters:
dataset - the dataset to add the attribute to
name - the name of the attribute
type - the type of the attribute

addValue

public static void addValue(Instance inst,
                            int index,
                            String value)
Adds the string value to the Instance.

Parameters:
inst - the instance to add the value to
index - the attribute index
value - the value to set

addValue

public static void addValue(Instance inst,
                            int index,
                            double value)
Adds the double value to the Instance.

Parameters:
inst - the instance to add the value to
index - the attribute index
value - the value to set

addStatistic

public static void addStatistic(Dataset dataset,
                                String name,
                                double value)
Adds a statistic as key/value pair to the dataset as new data row.

Parameters:
dataset - the dataset to add the row to
name - the name of the statistic (key)
value - the value of the statistic

evaluationToDataset

public static Dataset evaluationToDataset(Evaluation eval)
Turns the evaluation object into a Dataset structure.

Parameters:
eval - the evaluation to convert
Returns:
the generated data structure

getDateFormat

public static DateFormat getDateFormat()
Returns the DateFormat instance to use.

Returns:
the date formatter


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.