RandomSelector Class Reference

#include <random-selector.h>

Inheritance diagram for RandomSelector:

ExampleSelector List of all members.

Detailed Description

Chooses a random sample of each class to use as testing.


Public Member Functions

 RandomSelector (const vector< int > &labels, int num_train_per_class)
vector< LabeledIndexGetTrainingExamples ()
 Returns a vector of LabeledIndices of training instances sorted by index.
vector< LabeledIndexGetTestingExamples ()
 Returns a vector of LabeledIndices of testing instances sorted by index.
vector< int > GetUniqueLabels ()
 Returns a vector containing all the unique labels seen. Sorting is NOT guaranteed.
int GetNumExamples () const
 Returns the total number of examples there are.

Protected Member Functions

virtual void SelectExamples ()
 Responsible for calling AddTrainingExample and AddTestingExample to generate the lists.
const vector< LabeledIndex > & GetExamples () const
 Get all of the examples (in the same order as given when constructed).
vector< LabeledIndexInvertSelection (const vector< LabeledIndex > &selection) const
 Returns all instances are NOT in <selection>.
vector< LabeledIndexInvertSelection (const vector< LabeledIndex > &selection, const vector< LabeledIndex > &superset) const
 Returns all instances in <superset> that are NOT in <selection>.
vector< LabeledIndexRandomSample (int n, const vector< LabeledIndex > &selection) const
 Return a random sample of size <n> of <selection>.
vector< LabeledIndexGetInstancesWithLabel (int label, const vector< LabeledIndex > &selection) const
 Gets all elements in <selection> with the given <label>.
void AddTrainingExample (LabeledIndex index)
 Add a LabeledIndex to the list of designated training examples.
void AddTestingExample (LabeledIndex index)
 Add a LabeledIndex to the list of designated testing examples.


Constructor & Destructor Documentation

RandomSelector ( const vector< int > &  labels,
int  num_train_per_class 
)


Member Function Documentation

void SelectExamples (  )  [protected, virtual]

Responsible for calling AddTrainingExample and AddTestingExample to generate the lists.

Implements ExampleSelector.

vector< LabeledIndex > GetTrainingExamples (  )  [inherited]

Returns a vector of LabeledIndices of training instances sorted by index.

vector< LabeledIndex > GetTestingExamples (  )  [inherited]

Returns a vector of LabeledIndices of testing instances sorted by index.

vector< int > GetUniqueLabels (  )  [inherited]

Returns a vector containing all the unique labels seen. Sorting is NOT guaranteed.

int GetNumExamples (  )  const [inherited]

Returns the total number of examples there are.

const vector< LabeledIndex > & GetExamples (  )  const [protected, inherited]

Get all of the examples (in the same order as given when constructed).

vector< LabeledIndex > InvertSelection ( const vector< LabeledIndex > &  selection  )  const [protected, inherited]

Returns all instances are NOT in <selection>.

<selection> must be sorted by index. The output will be sorted by index.

vector< LabeledIndex > InvertSelection ( const vector< LabeledIndex > &  selection,
const vector< LabeledIndex > &  superset 
) const [protected, inherited]

Returns all instances in <superset> that are NOT in <selection>.

<selection> and <superset> must be sorted by index. The output will be sorted by index.

vector< LabeledIndex > RandomSample ( int  n,
const vector< LabeledIndex > &  selection 
) const [protected, inherited]

Return a random sample of size <n> of <selection>.

<selection> must be sorted by index. If the size of <selection> is less than n, this function will return a vector of size selection.size(). Output is sorted by index.

vector< LabeledIndex > GetInstancesWithLabel ( int  label,
const vector< LabeledIndex > &  selection 
) const [protected, inherited]

Gets all elements in <selection> with the given <label>.

<selection> must be sorted. The output will be sorted.

void AddTrainingExample ( LabeledIndex  index  )  [protected, inherited]

Add a LabeledIndex to the list of designated training examples.

void AddTestingExample ( LabeledIndex  index  )  [protected, inherited]

Add a LabeledIndex to the list of designated testing examples.


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 11:39:06 2007 for libpmk2 by  doxygen 1.5.1