Package com.yahoo.labs.samoa.instances
Class ArffLoader
- java.lang.Object
-
- com.yahoo.labs.samoa.instances.ArffLoader
-
- Direct Known Subclasses:
MultiTargetArffLoader
public class ArffLoader extends Object
The Class ArffLoader. Loads an Arff file with sparse or dense format.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Attribute>
auxAttributes
protected InstanceInformation
instanceInformation
The instance information.protected Range
range
protected InstancesHeader
streamHeader
protected StreamTokenizer
streamTokenizer
The stream tokenizer.
-
Constructor Summary
Constructors Constructor Description ArffLoader(Reader reader)
Instantiates a new arff loader.ArffLoader(Reader reader, int size, int classAttribute)
Instantiates a new arff loader.ArffLoader(Reader reader, Range range)
Instantiates a new arff loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstanceInformation
getStructure()
Gets the structure.protected Instance
newDenseInstance(int numberAttributes)
protected Instance
newSparseInstance(double d)
protected Instance
newSparseInstance(double d, double[] res)
Instance
readInstance()
Reads instance.Instance
readInstanceDense()
Reads a dense instance from the file.protected void
setValue(Instance instance, int numAttribute, double value, boolean isNumber)
-
-
-
Field Detail
-
instanceInformation
protected InstanceInformation instanceInformation
The instance information.
-
streamHeader
protected InstancesHeader streamHeader
-
streamTokenizer
protected StreamTokenizer streamTokenizer
The stream tokenizer.
-
range
protected Range range
-
-
Constructor Detail
-
ArffLoader
public ArffLoader(Reader reader, int size, int classAttribute)
Instantiates a new arff loader.- Parameters:
reader
- the readersize
- the sizeclassAttribute
- the class attribute
-
ArffLoader
public ArffLoader(Reader reader)
Instantiates a new arff loader.- Parameters:
reader
- the reader
-
-
Method Detail
-
getStructure
public InstanceInformation getStructure()
Gets the structure.- Returns:
- the structure
-
readInstance
public Instance readInstance()
Reads instance. It detects if it is dense or sparse.- Returns:
- the instance
-
readInstanceDense
public Instance readInstanceDense()
Reads a dense instance from the file.- Returns:
- the instance
-
setValue
protected void setValue(Instance instance, int numAttribute, double value, boolean isNumber)
-
newSparseInstance
protected Instance newSparseInstance(double d, double[] res)
-
newSparseInstance
protected Instance newSparseInstance(double d)
-
newDenseInstance
protected Instance newDenseInstance(int numberAttributes)
-
-