uk.ac.ed.inf.csb.taweka2010
Class DataSetFactory
java.lang.Object
uk.ac.ed.inf.csb.taweka2010.DataSetFactory
public class DataSetFactory
- extends java.lang.Object
DataSet contains a collection of instances (rows), their attributes (column names) and their attribute values (cells)
The last attribute is the class attribute.
- Version:
- 20 Feb 2008
- Author:
- Luna De Ferrari luna.deferrari-at-ed.ac.uk
|
Constructor Summary |
DataSetFactory(java.lang.String dataSetName,
java.util.Vector<java.lang.String> instancesDataForAttributes,
java.util.Vector<java.lang.String> attributesData,
java.lang.String className,
java.util.Vector<java.lang.String> instancesDataForClass,
java.util.Vector<java.lang.String> classValues)
Constructor for a data set. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DUMMY_VALUE
public static final java.lang.String DUMMY_VALUE
- See Also:
- Constant Field Values
DataSetFactory
public DataSetFactory(java.lang.String dataSetName,
java.util.Vector<java.lang.String> instancesDataForAttributes,
java.util.Vector<java.lang.String> attributesData,
java.lang.String className,
java.util.Vector<java.lang.String> instancesDataForClass,
java.util.Vector<java.lang.String> classValues)
- Constructor for a data set. It can be visualised ad: instances (rows), attributes (columns), class (last column), values (cells)
- Parameters:
dataSetName - the data relation nameinstancesDataForAttributes - the instance part of the dataattributesData - the attribute presence/absence for a given instance as attribute nameclassName - the class to be predictedinstancesDataForClass - the given instances (with corresponding class values in the class values vector)classValues - the class values for each corresponding instance
generateDataSet
public weka.core.Instances generateDataSet()
- Create a set of instances and fill it with data
- Returns:
- the data set
generateClassAttribute
public weka.core.Attribute generateClassAttribute()
- Generates the class attribute
add a dummy start value (to work around a known weka bug)
http://www.cs.waikato.ac.nz/~ml/weka/arff.html (bottom of the web page)
From Weka documentation: "Warning: There is a known problem saving SparseInstance objects from datasets that have string attributes.
In Weka, string and nominal data values are stored as numbers; these numbers act as indexes into an array of possible attribute values (this is very efficient).
However, the first string value is assigned index 0: this means that, internally, this value is stored as a 0.
When a SparseInstance is written, string instances with internal value 0 are not output, so their string value is lost
(and when the arff file is read again, the default value 0 is the index of a different string value, so the attribute value appears to change).
To get around this problem, add a dummy string value at index 0 that is never used whenever you declare string attributes that are likely to be used in SparseInstance objects and saved as Sparse ARFF files."
- Returns:
- the class attribute
getArffFormatString
public java.lang.String getArffFormatString()
getDataSetName
public java.lang.String getDataSetName()
getAttributes
public weka.core.FastVector getAttributes()
getAttributeByName
public weka.core.Attribute getAttributeByName(java.lang.String name)
getInstanceAttributeData
public uk.ac.ed.inf.csb.utils.OneToManyMap getInstanceAttributeData()
getClassAttribute
public weka.core.Attribute getClassAttribute()
getDataSet
public weka.core.Instances getDataSet()
getInstanceClassData
public uk.ac.ed.inf.csb.utils.OneToManyMap getInstanceClassData()
isLogged
public boolean isLogged()
setDebug
public void setDebug(boolean doLogErrors)
getLog
public java.lang.String getLog()