netkit.classifiers
Class DataSampler

java.lang.Object
  extended by netkit.classifiers.DataSampler

public final class DataSampler
extends java.lang.Object


Field Summary
 int clsIdx
           
 
Constructor Summary
DataSampler(Node[] nodes, int attribIdx)
           
DataSampler(Node[] nodes, int attribIdx, long seed)
           
DataSampler(Node[] nodes, int attribIdx, long seed, boolean replacement, boolean stratified, boolean sampleUnknown)
           
 
Method Summary
static Graph buildGraph()
           
 DataSampler clone()
           
 Node[][][] crossValidate(int numSplits)
          Create full cross-validation node sets in the form result[numsplit][0][...] is the training set for split numsplit and result[numsplit][1][...] is the test set for split numsplit.
 boolean doReplacement()
           
 boolean doStratified()
           
 double[] getDistribution()
           
static void main(java.lang.String[] args)
           
 int numMissingValues()
           
 Node[][] sample(int... sizes)
          Sample sets of the given size from the underlying distribution of nodes and return them in a a list of lists.
 Node[] sample(int size)
          Sample the given number of nodes and return a new array filled with the samples.
 void sample(Node[]... result)
          Fill the given list of arrays with sample nodes, ensuring that there is no overlap between nodes sampled in each of the sub-arrays (unless you are sampling with replacement).
 void sample(Node[] result)
          Fill the array with sampled data
 boolean sampleUnknown()
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clsIdx

public final int clsIdx
Constructor Detail

DataSampler

public DataSampler(Node[] nodes,
                   int attribIdx)

DataSampler

public DataSampler(Node[] nodes,
                   int attribIdx,
                   long seed)

DataSampler

public DataSampler(Node[] nodes,
                   int attribIdx,
                   long seed,
                   boolean replacement,
                   boolean stratified,
                   boolean sampleUnknown)
Method Detail

clone

public DataSampler clone()
Overrides:
clone in class java.lang.Object

numMissingValues

public int numMissingValues()

size

public int size()

getDistribution

public double[] getDistribution()

doReplacement

public boolean doReplacement()

sampleUnknown

public boolean sampleUnknown()

doStratified

public boolean doStratified()

sample

public void sample(Node[] result)
Fill the array with sampled data

Parameters:
result -

sample

public Node[] sample(int size)
Sample the given number of nodes and return a new array filled with the samples.

Parameters:
size -
Returns:

sample

public Node[][] sample(int... sizes)
Sample sets of the given size from the underlying distribution of nodes and return them in a a list of lists. This ensures that there is no overlap in nodes between the two arrays unless you are sampling with replacement).

NOTE: there is no guarantee of non-overlap if you are sampling with replacement.

Parameters:
sizes - The sizes of the lists to sample
Returns:
a list of lists of the given sizes.

sample

public void sample(Node[]... result)
Fill the given list of arrays with sample nodes, ensuring that there is no overlap between nodes sampled in each of the sub-arrays (unless you are sampling with replacement).

NOTE: there is no guarantee of non-overlap if you are sampling with replacement.

Parameters:
result -

crossValidate

public Node[][][] crossValidate(int numSplits)
Create full cross-validation node sets in the form result[numsplit][0][...] is the training set for split numsplit and result[numsplit][1][...] is the test set for split numsplit.

NOTE: there is no guarantee of non-overlap if you are sampling with replacement.

Parameters:
numSplits -
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

buildGraph

public static Graph buildGraph()

main

public static void main(java.lang.String[] args)