public class WeightedReservoirSample extends java.lang.Object implements weka.core.Aggregateable<WeightedReservoirSample>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
WeightedReservoirSample.InstanceHolder
Small inner class to hold an instance an its weight.
|
static class |
WeightedReservoirSample.InstanceHolderComparator
Comparator for InstanceHolder
|
Constructor and Description |
---|
WeightedReservoirSample(int size,
int seed)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(weka.core.Instance toAdd,
double weight)
(Potentially) add an instance to the reservoir
|
WeightedReservoirSample |
aggregate(WeightedReservoirSample toAggregate) |
void |
finalizeAggregation() |
java.util.PriorityQueue<WeightedReservoirSample.InstanceHolder> |
getSample()
Get the sample
|
weka.core.Instances |
getSampleAsInstances()
Get the current sample as a set of unweighted instances
|
weka.core.Instances |
getSampleAsWeightedInstances()
Get the current sample as a set of weighted instances
|
void |
reset()
Reset (clear) the reservoir
|
public WeightedReservoirSample(int size, int seed)
size
- the size of the reservoir to useseed
- the seed for random number generationpublic void add(weka.core.Instance toAdd, double weight)
toAdd
- the instance to addweight
- the weight of the instance (use 1 for all instances for
unweighted sampling)public WeightedReservoirSample aggregate(WeightedReservoirSample toAggregate) throws java.lang.Exception
aggregate
in interface weka.core.Aggregateable<WeightedReservoirSample>
java.lang.Exception
public void finalizeAggregation() throws java.lang.Exception
finalizeAggregation
in interface weka.core.Aggregateable<WeightedReservoirSample>
java.lang.Exception
public java.util.PriorityQueue<WeightedReservoirSample.InstanceHolder> getSample()
public weka.core.Instances getSampleAsInstances() throws java.lang.Exception
java.lang.Exception
- if we haven't seen any instances yetpublic weka.core.Instances getSampleAsWeightedInstances() throws java.lang.Exception
java.lang.Exception
- if we haven't seen any instances yetpublic void reset()