public class Instances extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected ArffLoader |
arff
The arff.
|
static String |
ARFF_DATA
The keyword used to denote the start of the arff data section
|
static String |
ARFF_RELATION
The keyword used to denote the start of an arff header
|
protected HashMap<String,Integer> |
hsAttributesIndices
A Hash that stores the indices of features.
|
protected int[] |
indicesIrrelevants
Indices of irrelevant features.
|
protected int[] |
indicesRelevants
Indices of relevant features.
|
protected InstanceInformation |
instanceInformation
The instance information.
|
protected List<Instance> |
instances
The instances.
|
Constructor and Description |
---|
Instances()
Instantiates a new instances.
|
Instances(Instances chunk)
Instantiates a new instances.
|
Instances(Instances chunk,
int capacity)
Instantiates a new instances.
|
Instances(Instances chunk,
int first,
int toCopy)
Instantiates a new instances.
|
Instances(Reader reader,
int size,
int classAttribute)
Instantiates a new instances.
|
Instances(Reader reader,
Range range)
Instantiates a new instances.
|
Instances(String st,
Attribute[] v,
int capacity)
Instantiates a new instances.
|
Instances(String st,
List<Attribute> v,
int capacity)
Instantiates a new instances.
|
Instances(StringReader st,
int capacity)
Instantiates a new instances.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Instance inst)
Adds the.
|
Attribute |
attribute(int w)
Attribute.
|
Attribute |
attribute(String name) |
Attribute |
classAttribute()
Class attribute.
|
int |
classIndex()
Class index.
|
protected void |
copyInstances(int from,
Instances dest,
int num) |
void |
delete()
Delete.
|
void |
delete(int index)
Delete.
|
void |
deleteAttributeAt(Integer integer)
Delete attribute at.
|
Instance |
get(int k) |
int[] |
getIndicesIrrelevants()
Returns the indices of the irrelevant features indicesIrrelevants.
|
int[] |
getIndicesRelevants()
Returns the indices of the relevant features indicesRelevants.
|
String |
getRelationName()
Gets the relation name.
|
int |
indexOf(Attribute att)
Returns the index of an Attribute.
|
void |
insertAttributeAt(Attribute attribute,
int position)
Insert attribute at.
|
Instance |
instance(int num)
Instance.
|
double |
meanOrMode(int j)
Mean or mode.
|
int |
numAttributes()
Num attributes.
|
int |
numClasses()
Num classes.
|
int |
numInstances()
Num instances.
|
void |
randomize(Random random)
Randomize.
|
boolean |
readInstance(Reader fileReader)
Read instance.
|
void |
set(int i,
Instance inst) |
void |
setAttributes(Attribute[] v) |
void |
setAttributes(Attribute[] v,
int[] indexValues) |
void |
setAttributes(List<Attribute> v,
List<Integer> indexValues) |
void |
setClassIndex(int classIndex)
Sets the class index.
|
void |
setIndicesRelevants(int[] indicesRelevants)
Sets the indices of relevant features.
|
void |
setRangeOutputIndices(Range range) |
void |
setRelationName(String string)
Sets the relation name.
|
int |
size() |
void |
stratify(int numFolds)
Stratify.
|
protected void |
stratStep(int numFolds) |
protected String |
stringWithoutHeader()
Returns the instances in the dataset as a string in ARFF format.
|
void |
swap(int i,
int j)
Swap.
|
Instances |
testCV(int numFolds,
int numFold)
Test cv.
|
String |
toString()
Returns the dataset as a string in ARFF format.
|
Instances |
trainCV(int numFolds,
int numFold) |
Instances |
trainCV(int numFolds,
int numFold,
Random random)
Train cv.
|
public static final String ARFF_RELATION
public static final String ARFF_DATA
protected InstanceInformation instanceInformation
protected ArffLoader arff
protected HashMap<String,Integer> hsAttributesIndices
protected int[] indicesRelevants
protected int[] indicesIrrelevants
public Instances(Instances chunk)
chunk
- the chunkpublic Instances()
public Instances(Reader reader, int size, int classAttribute)
reader
- the readersize
- the sizeclassAttribute
- the class attributepublic Instances(Reader reader, Range range)
reader
- the readerrange
- public Instances(Instances chunk, int capacity)
chunk
- the chunkcapacity
- the capacitypublic Instances(String st, Attribute[] v, int capacity)
st
- the stv
- the vcapacity
- the capacitypublic Instances(String st, List<Attribute> v, int capacity)
st
- the stv
- the vcapacity
- the capacitypublic Instances(Instances chunk, int first, int toCopy)
chunk
- the chunkfirst
- the first instancetoCopy
- the jpublic Instances(StringReader st, int capacity)
st
- the stcapacity
- the capacitypublic void setRelationName(String string)
string
- the new relation namepublic String getRelationName()
public int classIndex()
public void setClassIndex(int classIndex)
classIndex
- the new class indexpublic Attribute classAttribute()
public int numAttributes()
public Attribute attribute(int w)
w
- the wpublic int numClasses()
public void deleteAttributeAt(Integer integer)
integer
- the integerpublic void insertAttributeAt(Attribute attribute, int position)
attribute
- the attributeposition
- the positionpublic Instance instance(int num)
num
- the numpublic int numInstances()
public void add(Instance inst)
inst
- the instpublic void randomize(Random random)
random
- the randompublic void stratify(int numFolds)
numFolds
- the num foldsprotected void stratStep(int numFolds)
public Instances trainCV(int numFolds, int numFold, Random random)
numFolds
- the num foldsnumFold
- random
- the randompublic Instances trainCV(int numFolds, int numFold)
protected void copyInstances(int from, Instances dest, int num)
public Instances testCV(int numFolds, int numFold)
numFolds
- the num foldsnumFold
- the num foldpublic double meanOrMode(int j)
j
- the jpublic boolean readInstance(Reader fileReader)
fileReader
- the file readerpublic void delete()
public void delete(int index)
public void swap(int i, int j)
i
- the ij
- the jpublic int size()
public void set(int i, Instance inst)
public Instance get(int k)
public void setRangeOutputIndices(Range range)
public void setAttributes(Attribute[] v)
public void setAttributes(Attribute[] v, int[] indexValues)
public String toString()
protected String stringWithoutHeader()
public int indexOf(Attribute att)
att,
- the attribute.public int[] getIndicesRelevants()
public int[] getIndicesIrrelevants()
public void setIndicesRelevants(int[] indicesRelevants)
indicesRelevants
- Copyright © 2019 University of Waikato, Hamilton, NZ. All Rights Reserved.